实例:
E10-3:~ # df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 40G 4.7G 33G 13% /
devtmpfs 12G 144K 12G 1% /dev
tmpfs 3.9G 100K 3.9G 1% /dev/shm
/dev/sda1 479M 72M 383M 16% /boot
/dev/sda5 869G 201M 824G 1% /home
/dev/sr0 2.9G 2.9G 0 100% /media/SLES-11-SP1-DVD-x86_64.0432..001
E10-3:~ # fdisk -l
Disk /dev/sda: 999.0 GB, 998999326720 bytes
255 heads, 63 sectors/track, 121454 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Disk identifier: 0x00004cb7
Device Boot Start End Blocks Id System
/dev/sda1 * 1 63 506016 83 Linux
/dev/sda2 64 5284 41937682+ 83 Linux
/dev/sda3 5285 6328 8385930 82 Linux swap / Solaris
/dev/sda4 6329 121454 924749595 f W95 Ext'd (LBA)
/dev/sda5 6329 121452 924733498+ 83 Linux
Disk /dev/sdb: 999.0 GB, 998999326720 bytes
255 heads, 63 sectors/track, 121454 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Disk identifier: 0x00000000
Disk /dev/sdb doesn't contain a validpartition table
Disk /dev/sdc: 4994.0 GB, 4993981612032 bytes
255 heads, 63 sectors/track, 607150 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Disk identifier: 0x00000000
Disk /dev/sdc doesn't contain a validpartition table
E10-3:~ # fdisk /dev/sdb
Device contains neither a valid DOS partitiontable, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with diskidentifier 0xd3f0a6aa.
Changeswill remain in memory only, until you decide to write them.
After that, of course, the previous contentwon't be recoverable.
Thenumber of cylinders for this disk is set to 121454.
There is nothing wrong with that, but this islarger than 1024,
andcould in certain setups cause problems with:
1)software that runs at boot time (e.g., old versions of LILO)
2)booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partitiontable 4 will be corrected by w(rite)
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibilityflag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOSpartition table
p print the partition table
q quit without saving changes
s create a new empty Sundisklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (expertsonly)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4): 1
First cylinder (1-121454, default 1): 1
Lastcylinder, +cylinders or +size{K,M,G} (1-121454, default 121454):
Using default value 121454
Command (m for help): p
Disk/dev/sdb: 999.0 GB, 998999326720 bytes
255heads, 63 sectors/track, 121454 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Diskidentifier: 0xd3f0a6aa
Device Boot Start End Blocks Id System
/dev/sdb1 1 121454 975579223+ 5 Extended
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
E10-3:~ # fdisk -l
Disk/dev/sda: 999.0 GB, 998999326720 bytes
255heads, 63 sectors/track, 121454 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Diskidentifier: 0x00004cb7
Device Boot Start End Blocks Id System
/dev/sda1 * 1 63 506016 83 Linux
/dev/sda2 64 5284 41937682+ 83 Linux
/dev/sda3 5285 6328 8385930 82 Linux swap / Solaris
/dev/sda4 6329 121454 924749595 f W95 Ext'd (LBA)
/dev/sda5 6329 121452 924733498+ 83 Linux
Disk/dev/sdb: 999.0 GB, 998999326720 bytes
255heads, 63 sectors/track, 121454 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Diskidentifier: 0xd3f0a6aa
Device Boot Start End Blocks Id System
/dev/sdb1 1 121454 975579223+ 5 Extended
Disk/dev/sdc: 4994.0 GB, 4993981612032 bytes
255heads, 63 sectors/track, 607150 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Diskidentifier: 0x00000000
Disk/dev/sdc doesn't contain a valid partition table
E10-3:/ # fdisk /dev/sdb
Thenumber of cylinders for this disk is set to 121454.
There is nothing wrong with that, but this islarger than 1024,
andcould in certain setups cause problems with:
1)software that runs at boot time (e.g., old versions of LILO)
2)booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibilityflag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOSpartition table
p print the partition table
q quit without saving changes
s create a new empty Sundisklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (expertsonly)
Command (m for help): p
Disk/dev/sdb: 999.0 GB, 998999326720 bytes
255heads, 63 sectors/track, 121454 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Diskidentifier: 0xd3f0a6aa
Device Boot Start End Blocks Id System
/dev/sdb1 1 121454 975579223+ 5 Extended
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (1-121454, default 1):
Using default value 1
Lastcylinder, +cylinders or +size{K,M,G} (1-121454, default 121454):
Using default value 121454
Command (m for help): p
Disk/dev/sdb: 999.0 GB, 998999326720 bytes
255heads, 63 sectors/track, 121454 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Diskidentifier: 0xd3f0a6aa
Device Boot Start End Blocks Id System
/dev/sdb1 1 121454 975579223+ 5 Extended
/dev/sdb5 1 121454 975579192 83 Linux
Command(m for help): w
Thepartition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
E10-3:/ # fdisk -l
Disk/dev/sda: 999.0 GB, 998999326720 bytes
255heads, 63 sectors/track, 121454 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Diskidentifier: 0x00004cb7
Device Boot Start End Blocks Id System
/dev/sda1 * 1 63 506016 83 Linux
/dev/sda2 64 5284 41937682+ 83 Linux
/dev/sda3 5285 6328 8385930 82 Linux swap / Solaris
/dev/sda4 6329 121454 924749595 f W95 Ext'd (LBA)
/dev/sda5 6329 121452 924733498+ 83 Linux
Disk/dev/sdb: 999.0 GB, 998999326720 bytes
255heads, 63 sectors/track, 121454 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Diskidentifier: 0xd3f0a6aa
Device Boot Start End Blocks Id System
/dev/sdb1 1 121454 975579223+ 5 Extended
/dev/sdb5 1 121454 975579192 83 Linux
Disk/dev/sdc: 4994.0 GB, 4993981612032 bytes
255 heads,63 sectors/track, 607150 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Diskidentifier: 0x00000000
Disk/dev/sdc doesn't contain a valid partition table
E10-3:/ # mkfs.ext3 -L /webroot/1 /dev/sdb5
mke2fs 1.41.9 (22-Aug-2009)
Filesystem label=/webroot/1
OStype: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
60981248 inodes, 243894798 blocks
12194739 blocks (5.00%) reserved for the superuser
First data block=0
Maximum filesystem blocks=4294967296
7444block groups
32768 blocks per group, 32768 fragments pergroup
8192inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accountinginformation: done
Thisfilesystem will be automatically checked every 39 mounts or
180days, whichever comes first. Use tune2fs-c or -i to override.
E10-3:/ # mount /dev/sdb5 /webroot/1
E10-3:/ # df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 40G 4.7G 33G 13% /
devtmpfs 12G 152K 12G 1% /dev
tmpfs 3.9G 100K 3.9G 1% /dev/shm
/dev/sda1 479M 72M 383M 16% /boot
/dev/sda5 869G 201M 824G 1% /home
/dev/sr0 2.9G 2.9G 0 100% /media/SLES-11-SP1-DVD-x86_64.0432..001
/dev/sdb5 916G 200M 870G 1% /webroot/1
E10-3:/ # vi /etc/fstab
/dev/disk/by-id/scsi-3600605b0020ecc50181c076d1680b376-part3swap swap defaults 0 0
/dev/disk/by-id/scsi-3600605b0020ecc50181c076d1680b376-part2/ ext3 acl,user_xattr 1 1
/dev/disk/by-id/scsi-3600605b0020ecc50181c076d1680b376-part1/boot ext3 acl,user_xattr 1 2
/dev/disk/by-id/scsi-3600605b0020ecc50181c076d1680b376-part5/home ext3 acl,user_xattr 1 2
proc /proc proc defaults 0 0
sysfs /sys sysfs noauto 0 0
debugfs /sys/kernel/debug debugfs noauto 0 0
usbfs /proc/bus/usb usbfs noauto 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
/dev/sdb5 /webroot/1 ext3 defaults 0 0
done!!!
命令:parted /dev/sdc
注:下面的[17:30:38]是CRT工具记录的时间戳。
(parted) mkpart
[17:30:38]Partition name? []? /dev/sdc/5
[17:30:41]File system type? [ext2]? ext3
[17:30:43]Start?
[17:30:51]Start? 0
[17:30:53]End? ?
[17:30:53]Error: Invalid number.
[17:31:25](parted) mkpart
[17:31:32]Partition name? []? /dev/sdc5
[17:31:35]File system type? [ext2]? ext3
[17:31:36]Start? 0
[17:31:57]End? 4994GB
(parted) print
[17:32:15]Model: LSI MegaRAID 8708ELP(scsi)
[17:32:15]Disk /dev/sdc: 4994GB
[17:32:15]Sector size (logical/physical):512B/512B
[17:32:15]Partition Table: gpt
[17:32:15]
[17:32:15]Number Start End Size File system Name Flags
[17:32:15] 1 17.4kB 4994GB 4994GB /dev/sdc5 , , , , , , , , , , ,
[17:32:15]
[17:33:23](parted) quit
[17:33:23]Information: You may need to update/etc/fstab.
命令:mkfs.ext3 /dev/sdc1
命令:mkdir -p /webroot/2
命令:
echo "/dev/sdc1 /webroot/2 ext3 defaults 0 0" >> /etc/fstab
命令:
mount-a
命令:
df –h
4、 挂载硬盘
1) 创建挂载点
在根目录下创建storage目录
#mkdir /storage
2) 将/dev/sdb5挂载到/storage下
#mount /dev/sdb5 /storage
5、 设置开机启动自动挂载
新创建的分区不能开机自动挂载,每次重启机器都要手动挂载。
设置开机自动挂载需要修改/etc/fstab文件
#vi /etc/fstab
在文件的最后增加一行
/dev/sdb5 /storage ext3defaults 1 2
192.168.1.14
/dev/sdb5 /mnt/data ext4 defaults 0 0