在系统上增加硬盘操作办法
[root@gyhRedHat root]# fdisk
Usage: fdisk [-l] [-b SSZ] [-u] device
E.g.: fdisk /dev/hda (for the first IDE disk)
or: fdisk /dev/sdc (for the third SCSI disk)
or: fdisk /dev/eda (for the first PS/2 ESDI drive)
or: fdisk /dev/rd/c0d0 or: fdisk /dev/ida/c0d0 (for RAID devices)
…
[root@gyhredhat root]# df -k
文件系统 1K-块 已用 可用 已用% 挂载点
/dev/sda3 3723848 705968 2828716 20% /
/dev/sda1 101089 9274 86596 10% /boot
none 14520 0 14520 0% /dev/shm
对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
[root@gyhredhat root]# fdisk /dev/hda
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won’t be recoverable.
The number of cylinders for this disk is set to 8322.
There is nothing wrong with that, but this is larger than 1024,
and could 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 partition table 4 will be corrected by w(rite)
Command (m for help): p
Disk /dev/hda: 4294 MB, 4294967296 bytes
16 heads, 63 sectors/track, 8322 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
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 (experts only)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-8322, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
Command (m for help): p
Disk /dev/hda: 4294 MB, 4294967296 bytes
16 heads, 63 sectors/track, 8322 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hda1 1 1000 503968+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
//格式化新分区
[root@gyhRedHat root]# mkfs.ext3 /dev/hda1
mke2fs 1.32 (09-Nov-2002)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
126480 inodes, 503968 blocks
25198 blocks (5.00%) reserved for the super user
First data block=1
62 block groups
8192 blocks per group, 8192 fragments per group
2040 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@gyhredhat root]# df -k
文件系统 1K-块 已用 可用 已用% 挂载点
/dev/sda3 3723848 705992 2828692 20% /
/dev/sda1 101089 9274 86596 10% /boot
none 14520 0 14520 0% /dev/shm
//挂上新分区
[root@gyhredhat root]# mount /dev/hda1 /home
[root@gyhredhat root]# df -k
文件系统 1K-块 已用 可用 已用% 挂载点
/dev/sda3 3723848 705992 2828692 20% /
/dev/sda1 101089 9274 86596 10% /boot
none 14520 0 14520 0% /dev/shm
/dev/hda1 488006 8239 454569 2% /home
[root@gyhredhat root]#
以下是为收集于网络,个人觉得非常不错
1. 检查所有硬盘分区
[root@web home]# fdisk -l
Disk /dev/hdc: 81.9 GB, 81964302336 bytes
255 heads, 63 sectors/track, 9964 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdc1 * 1 3921 31495401 7 HPFS/NTFS
/dev/hdc2 3922 9964 48540397+ f Win95 Ext’d (LBA)
/dev/hdc5 3922 7840 31479336 7 HPFS/NTFS
/dev/hdc6 7841 9964 17060998+ 7 HPFS/NTFS
Disk /dev/hda: 60.0 GB, 60022480896 bytes
255 heads, 63 sectors/track, 7297 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 7043 56468475 83 Linux
/dev/hda3 7044 7297 2040255 82 Linux swap
2. 检查新硬盘分区
[root@web root]# fdisk /dev/hdc
The number of cylinders for this disk is set to 9964.
There is nothing wrong with that, but this is larger than 1024,
and could 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)
3. 删除老硬盘分区(hdc1,hdc2,hdc5,hdc6)
Command (m for help): d
Partition number (1-6): 6
4. 保存修改信息
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
5. 检查保存情况,直到所有老分区都删除
[root@web root]# fdisk -l /dev/hdc
Disk /dev/hdc: 81.9 GB, 81964302336 bytes
255 heads, 63 sectors/track, 9964 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdc2 3922 9964 48540397+ f Win95 Ext’d (LBA)
/dev/hdc5 3922 7840 31479336 7 HPFS/NTFS
6. 重新创建硬盘分区
[root@web root]# fdisk -l /dev/hdc
Disk /dev/hdc: 81.9 GB, 81964302336 bytes
255 heads, 63 sectors/track, 9964 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): d
No partition is defined yet!
Command (m for help): n
Command action
e extended
p primary partition (1-4)
7. 选择主分区(?)
p
8. 选择硬盘分区号(hdc1中的1)
Partition number (1-4): 1
9. 选择硬盘分区的第一柱面(从第2个开始,从1开始不安全(?))
First cylinder (1-9964, default 1): 2
10. 选择硬盘分区结束柱面
Last cylinder or +size or +sizeM or +sizeK (2-9964, default 9964): 5000
11. 保存修改信息
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
12. 创建hdc2
[root@web root]# fdisk /dev/hdc
The number of cylinders for this disk is set to 9964.
There is nothing wrong with that, but this is larger than 1024,
and could 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): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (1-9964, default 1): 5001
Last cylinder or +size or +sizeM or +sizeK (5001-9964, default 9964):
Using default value 9964
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
13. 检查新硬盘创建信息
[root@web root]# fdisk -l
Disk /dev/hdc: 81.9 GB, 81964302336 bytes
255 heads, 63 sectors/track, 9964 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdc1 2 5000 40154467+ 83 Linux
/dev/hdc2 5001 9964 39873330 83 Linux
Disk /dev/hda: 60.0 GB, 60022480896 bytes
255 heads, 63 sectors/track, 7297 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 7043 56468475 83 Linux
/dev/hda3 7044 7297 2040255 82 Linux swap
14. 建立新硬盘映射目录
[root@web root]# mkdir -pv /disk1
[root@web root]# mkdir -pv /disk2
15. 格式化新硬盘分区
[root@web root]# mkfs.ext3 /dev/hdc1
mke2fs 1.32 (09-Nov-2002)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
5020064 inodes, 10038616 blocks
501930 blocks (5.00%) reserved for the super user
First data block=0
307 block groups
32768 blocks per group, 32768 fragments per group
16352 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@web root]# mkfs.ext3 /dev/hdc2
mke2fs 1.32 (09-Nov-2002)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
4987360 inodes, 9968332 blocks
498416 blocks (5.00%) reserved for the super user
First data block=0
305 block groups
32768 blocks per group, 32768 fragments per group
16352 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
16. 增加新硬盘分区表信息[root@web root]# vi /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
/dev/hda3 swap swap defaults 0 0
/dev/hdc1 /disk1 ext3 defaults 1 1
/dev/hdc2 /disk2 ext3 defaults 1 1
17. 挂上硬盘
[root@web root]# mount -a
18. 检查所有硬盘mount情况
[root@web root]# df -h
/dev/hda2 54G 1.4G 49G 3% /
/dev/hda1 99M 15M 80M 16% /boot
none 1008M 0 1008M 0% /dev/shm
/dev/hdc1 38G 33M 36G 1% /disk1
/dev/hdc2 38G 33M 36G 1% /disk2