1. 基本知识
一块硬盘可以有1-3个主分区和1个扩展分区,或者1-4个主分区。一个扩展分区可以分为若干个逻辑分区。
硬盘的容量=主分区的容量+扩展分区的容量
扩展分区的容量=各个逻辑分区的容量之和
扩展分区的容量=各个逻辑分区的容量之和
通常,在PC机上使用的硬盘有两种:
1) IDE接口:最常见的;
2) SCSI接口:比IDE性能好,但更贵!
操作系统对分区的要求。
Windows必须安装在主分区上。磁盘格式为FAT32/NTFS
Solaris(Unix)必须安装在主分区上。磁盘格式为Solaris
Ubuntu(Linux)可以安装在逻辑分区上。磁盘格式为Ext3/swap
2. Windows
Partition Diagrams
3. Linux(Ubuntu)
Linux下的磁盘设备
IDE设备:一台PC上可以有两个IDE接口(我将其称为第一IDE、第二IDE),而每个IDE接口上可以接两个IDE设备(我将其称为主盘、从盘)。其中硬盘与光驱都是IDE设备。Linux这样为其命名:
第一IDE的主盘:/dev/hda
第一IDE的从盘:/dev/hdb
第二IDE的主盘:/dev/hdc
第二IDE的从盘:/dev/hdd
SCSI设备:这个相对大家会陌生一些,它通常需要加上一块SCSI卡来驱动。
第一块SCSI设备称为:/dev/sda
第二块SCSI设备称为:/dev/sdb……
以此类推。
Linux下的分区命名
也就是主分区(或扩展分区)被命名为hda1-hda4,如果没有,就跳过。而扩展分区中的逻辑分区则从hda5开始编号,以此类推。 这里是以第一IDE的主盘为例,如果是第二硬盘,就是hdb1、hdb2、hdb5、hdb6、hdb7。
Command - View Disks
robert@laptop-ubuntu:~$ sudo fdisk -l
Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x18bc18bc
Device Boot Start End Blocks Id System
/dev/sda1 * 1 5838 46886912 7 HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2 5838 6360 4195328 c W95 FAT32 (LBA)
Partition 2 does not end on cylinder boundary.
/dev/sda3 6360 8971 20971096 bf Solaris
/dev/sda4 8972 14593 45158715 f W95 Ext'd (LBA)
/dev/sda5 11582 14593 24191968+ 7 HPFS/NTFS
/dev/sda6 8972 11087 16996707 83 Linux
/dev/sda7 11088 11581 3968023+ 82 Linux swap / Solaris
Partition table entries are not in disk order
Disk /dev/sdb: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xe6e9f997
Device Boot Start End Blocks Id System
/dev/sdb1 1 4177 33551721 c W95 FAT32 (LBA)
/dev/sdb2 4178 8354 33551752+ 7 HPFS/NTFS
/dev/sdb3 8355 9729 11044687+ c W95 FAT32 (LBA)
Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x18bc18bc
Device Boot Start End Blocks Id System
/dev/sda1 * 1 5838 46886912 7 HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2 5838 6360 4195328 c W95 FAT32 (LBA)
Partition 2 does not end on cylinder boundary.
/dev/sda3 6360 8971 20971096 bf Solaris
/dev/sda4 8972 14593 45158715 f W95 Ext'd (LBA)
/dev/sda5 11582 14593 24191968+ 7 HPFS/NTFS
/dev/sda6 8972 11087 16996707 83 Linux
/dev/sda7 11088 11581 3968023+ 82 Linux swap / Solaris
Partition table entries are not in disk order
Disk /dev/sdb: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xe6e9f997
Device Boot Start End Blocks Id System
/dev/sdb1 1 4177 33551721 c W95 FAT32 (LBA)
/dev/sdb2 4178 8354 33551752+ 7 HPFS/NTFS
/dev/sdb3 8355 9729 11044687+ c W95 FAT32 (LBA)
Command - View one Disk
robert@laptop-ubuntu:~$ sudo fdisk -l /dev/sda
Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x18bc18bc
Device Boot Start End Blocks Id System
/dev/sda1 * 1 5838 46886912 7 HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2 5838 6360 4195328 c W95 FAT32 (LBA)
Partition 2 does not end on cylinder boundary.
/dev/sda3 6360 8971 20971096 bf Solaris
/dev/sda4 8972 14593 45158715 f W95 Ext'd (LBA)
/dev/sda5 11582 14593 24191968+ 7 HPFS/NTFS
/dev/sda6 8972 11087 16996707 83 Linux
/dev/sda7 11088 11581 3968023+ 82 Linux swap / Solaris
Partition table entries are not in disk order
Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x18bc18bc
Device Boot Start End Blocks Id System
/dev/sda1 * 1 5838 46886912 7 HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2 5838 6360 4195328 c W95 FAT32 (LBA)
Partition 2 does not end on cylinder boundary.
/dev/sda3 6360 8971 20971096 bf Solaris
/dev/sda4 8972 14593 45158715 f W95 Ext'd (LBA)
/dev/sda5 11582 14593 24191968+ 7 HPFS/NTFS
/dev/sda6 8972 11087 16996707 83 Linux
/dev/sda7 11088 11581 3968023+ 82 Linux swap / Solaris
Partition table entries are not in disk order
Command - Disk Usage
robert@laptop-ubuntu:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda6 16729812 13400616 2479364 85% /
tmpfs 1023600 0 1023600 0% /lib/init/rw
varrun 1023600 120 1023480 1% /var/run
varlock 1023600 0 1023600 0% /var/lock
udev 1023600 2872 1020728 1% /dev
tmpfs 1023600 104 1023496 1% /dev/shm
lrm 1023600 2004 1021596 1% /lib/modules/2.6.27-11-generic/volatile
/dev/sdb1 33535328 99216 33436112 1% /media/Work
/dev/sdb3 11033888 7937768 3096120 72% /media/Buffer
/dev/sdb2 33551752 23135812 10415940 69% /media/Backup
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda6 16729812 13400616 2479364 85% /
tmpfs 1023600 0 1023600 0% /lib/init/rw
varrun 1023600 120 1023480 1% /var/run
varlock 1023600 0 1023600 0% /var/lock
udev 1023600 2872 1020728 1% /dev
tmpfs 1023600 104 1023496 1% /dev/shm
lrm 1023600 2004 1021596 1% /lib/modules/2.6.27-11-generic/volatile
/dev/sdb1 33535328 99216 33436112 1% /media/Work
/dev/sdb3 11033888 7937768 3096120 72% /media/Buffer
/dev/sdb2 33551752 23135812 10415940 69% /media/Backup
Mount Disks
mount ntfs, the permission is 777, however, mount fat it is 755, in addition, you can't change the permission and owner.
mount -t ntfs /dev/sda5 /media/Work
mount -t vfat /dev/sdb1 /media/Work
If you want any user to access the partition, please use the /etc/fstab to mount the disks as follows,
Add the lines to /etc/fstab,
/dev/sdb1 /media/Work vfat iocharset=utf8,umask=000 0 0
/dev/sdb2 /media/Backup ntfs iocharset=utf8,umask=000 0 0
/dev/sdb3 /media/Buffer vfat iocharset=utf8,umask=000 0 0
/dev/sdb2 /media/Backup ntfs iocharset=utf8,umask=000 0 0
/dev/sdb3 /media/Buffer vfat iocharset=utf8,umask=000 0 0
Disk Summary
sda1(Windows:C) sda2(OBI:Windows Recovery) sda3(Solaris) sda4(Extended Partition)
-----sda6(Ubuntu Ext3) sda7(Ubuntu Swap) sda5(Windows:D)
sdb1(WORK) sdb2(BACKUP) sdb3(BUFFER)
Partition Diagram
4. Solaris
Solaris(FAT32)(Only Fat32 can be mapped by default)
1). Find which file is the hard disk?
robert@laptop-opensolaris:/dev/dsk# format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c5t0d0
/pci@0,0/pci17aa,20a7@1f,2/disk@0,0
Specify disk (enter its number): ^C
So the c5t0d0 is the disk.
2). Find all of the disk files about c5t0d0.
robert@laptop-opensolaris:/dev/dsk# format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c5t0d0
/pci@0,0/pci17aa,20a7@1f,2/disk@0,0
Specify disk (enter its number): ^C
So the c5t0d0 is the disk.
2). Find all of the disk files about c5t0d0.
robert@laptop-opensolaris:/dev/dsk# ls -l | grep c5t0d0
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0p0 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:q
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0p1 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:r
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0p2 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:s
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0p3 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:t
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0p4 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:u
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0s0 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:a
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0s1 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:b
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0s10 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:k
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0s11 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:l
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0s12 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:m
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0s13 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:n
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0s14 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:o
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0s15 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:p
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0s2 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:c
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0s3 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:d
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0s4 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:e
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0s5 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:f
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0s6 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:g
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0s7 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:h
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0s8 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:i
lrwxrwxrwx 1 root root 50 2008-10-29 14:30 c5t0d0s9 -> ../../devices/pci@0,0/pci17aa,20a7@1f,2/disk@0,0:j
c5t0d0p0,c5t0d0p1,c5t0d0p2,c5t0d0p3,c5t0d0p4 are the partitions.
c5t0d0p0: While Disk
c5t0d0p1: Windows C
c5t0d0p2: OBI Recovery Partition
c5t0d0p3: Solaris OS
c5t0d0p4: Whole Extended Partition
3). Mount the Windows Partition.
mount -F pcfs /dev/dsk/c5t0d0p2 /OBI
Solaris(NTFS)(Need install softares)
wget
http://www.belenix.org/binfiles/FSWpart.tar.gz
gunzip -c FSWpart.tar.gz | tar xf -
pkgadd -d . FSWpart [点后面有个空格]
wget http://www.belenix.org/binfiles/FSWfsmisc.tar.gz
gunzip -c FSWfsmisc.tar.gz | tar xf -
pkgadd -d . FSWfsmisc[点后面有个空格]
gunzip -c FSWpart.tar.gz | tar xf -
pkgadd -d . FSWpart [点后面有个空格]
wget http://www.belenix.org/binfiles/FSWfsmisc.tar.gz
gunzip -c FSWfsmisc.tar.gz | tar xf -
pkgadd -d . FSWfsmisc[点后面有个空格]
-bash-3.2#
prtpart
Fdisk information for device /dev/rdsk/c4d0p0
Block Size : 512 bytes
Controller : ide
Disk : cmdk
Capacity : 55 GB
# start block # nblocks startCylSecHd endCylSecHd OSType
1: 0000000063 0030723777 0/ 1/ 1 ff/ff/ef IFS: NTFS
2: 0030723840 0070096320 ff/c1/ 0 ff/ff/ef WIN95 Extended(LBA)
# start block # nblocks startCylSecHd endCylSecHd OSType
5: 0000000063 0040960017 ff/ff/ef ff/ff/ef IFS: NTFS
0: 0040960080 0029136240 ff/ff/ef ff/ff/ef DOS Extended
# start block # nblocks startCylSecHd endCylSecHd OSType
6: 0000000063 0029136177 ff/ff/ef ff/ff/ef IFS: NTFS
3: 0100820223 0016390017 ff/ff/fe ff/ff/fe Solaris x86
-bash-3.2# su - nova
Sun Microsystems Inc. SunOS 5.11 snv_86 January 2008
-bash-3.2$ ls
core Desktop
-bash-3.2$ cd D*
-bash-3.2$ ls
FSWfsmisc FSWpart 新文件
FSWfsmisc.tar.gz FSWpart.tar 新文件~
-bash-3.2$ su - root
-bash-3.2# prtpart /dev/rdsk/c4d0p0 -ldevs
Fdisk information for device /dev/rdsk/c4d0p0
** NOTE **
/dev/dsk/c4d0p0 - Physical device referring to entire physical disk
/dev/dsk/c4d0p1 - p4 - Physical devices referring to the 4 primary partitions
/dev/dsk/c4d0p5 ... - Virtual devices referring to logical partitions
Virtual device names can be used to access EXT2 and NTFS on logical partitions
/dev/dsk/c4d0p1 IFS: NTFS
/dev/dsk/c4d0p2 WIN95 Extended(LBA)
/dev/dsk/c4d0p5 IFS: NTFS
/dev/dsk/c4d0p6 IFS: NTFS
/dev/dsk/c4d0p3 Solaris x86
-bash-3.2# mkdir /winnt_D
-bash-3.2# mount -F ntfs /dev/dsk/c4d0p5 /winnt_D
-bash-3.2# mkdir /winnt_E
-bash-3.2# mount -F ntfs /dev/dsk/c4d0p6 /winnt_E
-bash-3.2# df -h
rpool/ROOT/opensolaris/opt
7.1G 981M 3.3G 23% /opt
rpool/export 7.1G 19K 3.3G 1% /export
rpool/export/home 7.1G 271M 3.3G 8% /export/home
rpool 7.1G 57K 3.3G 1% /rpool
rpool/ROOT 7.1G 18K 3.3G 1% /rpool/ROOT
127.0.0.1:/ 156G 156G 0K 100% /winnt_D
127.0.0.1:/ 111G 111G 0K 100% /winnt_E
-bash-3.2# xlsmounts
PHYSICAL DEVICE LOGICAL DEVICE FS PID ADDR Mounted on
/dev/dsk/c4d0p0 /dev/dsk/c4d0p5 ntfs 1633 127.0.0.1:/ /winnt_D
/dev/dsk/c4d0p0 /dev/dsk/c4d0p6 ntfs 1645 127.0.0.1:/ /winnt_E