在CetntOS系统中添加一块容量为20G IDE硬盘,划分分区分别为/dev/hdb1和/dev/hdb2
转http://www.online990.com/htm/201027/181.htm
操作如下:
[root@localhost /]# fdisk /dev/hdb
The number of cylinders for this disk is set to 44384.
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): p #列出硬盘分区表信息
Disk /dev/hdb: 21.4 GB, 21474836480 bytes #发现新添加硬盘
15 heads, 63 sectors/track, 44384 cylinders
Units = cylinders of 945 * 512 = 483840 bytes
Device Boot Start End Blocks Id System
Command (m for help): n #为磁盘划分分区
Command action
e extended #扩展分区
p primary partition (1-4) #主分区
p #通常选择分区为主分区,选择p
Partition number (1-4): 1 #输入分区号,这里是第一个分区,选择1
First cylinder (1-44384, default 1): #输入磁盘块数,默认为1
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-44384, default 44384): +10240M
#输入分区大小,默认是将磁盘空间全部分配。
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (21166-44384, default 21166):
Using default value 21166
Last cylinder or +size or +sizeM or +sizeK (21166-44384, default 44384):
Using default value 44384
Command (m for help): p
Disk /dev/hdb: 21.4 GB, 21474836480 bytes
15 heads, 63 sectors/track, 44384 cylinders
Units = cylinders of 945 * 512 = 483840 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 21165 10000431 83 Linux
/dev/hdb2 21166 44384 10970977+ 83 Linux
Command (m for help): w #对磁盘进行写入操作并退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
这样分区就创建好了,我们还要磁盘进行格式化操作。
[root@localhost /]# mkfs -t ext3 -c /dev/hdb1 #将分区1以ext3格式进行格式化。
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1251712 inodes, 2500107 blocks
125005 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2562719744
77 block groups
32768 blocks per group, 32768 fragments per group
16256 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Checking for bad blocks (read-only test): done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost /]# mkfs -t ext3 -c /dev/hdb2 #将分区2以ext3格式进行格式化。
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1373568 inodes, 2742744 blocks
137137 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2810183680
84 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
Checking for bad blocks (read-only test): done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
重新检查磁盘分区,是否被格式化。
root@localhost ~]# fdisk -l
Disk /dev/hda: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 2550 20482843+ 83 Linux
/dev/hda2 2551 2811 2096482+ 82 Linux swap / Solaris
/dev/hda3 2812 13054 82276897+ 83 Linux
Disk /dev/hdb: 21.4 GB, 21474836480 bytes
15 heads, 63 sectors/track, 44384 cylinders
Units = cylinders of 945 * 512 = 483840 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 21165 10000431 83 Linux
/dev/hdb2 21166 44384 10970977+ 83 Linux
接下来就是对磁盘进行挂载
[root@localhost /]# mkdir /www;mkdir data #创建两个目录分别为www和data
[root@localhost /]# mount /dev/hdb1 /www #将hdb1挂到www下
[root@localhost /]# mount /dev/hdb2 /data #将hdb2挂到data下
用df查看分区是否被挂载。
[root@localhost ~]# df -kv
文件系统 1K-块 已用 可用 已用% 挂载点
/dev/hda1 19840892 3488364 15328388 19% /
/dev/hda3 79699248 367392 75218012 1% /home
tmpfs 127772 0 127772 0% /dev/shm
/dev/hdb1 9843276 153192 9190064 2% /www
/dev/hdb2 10798528 157992 10091988 2% /data
修改/etc/fstab,在文件末尾添加分区加载信息,使系统启动时自动挂载分区。
[root@localhost /]# vi /etc/fstab
/dev/hdb1 /www ext3 defaults 1 2
/dev/hdb2 /data ext3 defaults 1 2
保存并退出,然后重启服务器,查看磁盘是否挂载成功。这样我们添加新硬盘的工作就圆满结束。
yytx1225 于 2010-03-02 14:49:55发表:
有点看不懂了 。。。
theset 于 2010-03-01 08:23:02发表:
学习学习
boiae 于 2010-02-28 11:00:06发表:
前几天准备接一块以前的IDE硬盘,拆出来后线竟然不对头,郁闷