在linux下加载一块硬盘总体分为几个步骤:
(1)fdisk 对硬盘就行分区
fdisk -l 查看硬盘分区信息
(2)用mkfs.ext3对硬盘进行格式化
(3)用mount讲该分区挂接到执行目录
Disk /dev/sdb: 1073 MB,1073741824 bytes --可以看到有一块空闲的硬盘还未分区
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
fdisk /dev/sdb 对硬盘进行分区
Command (m for help):m --列出fdisk工具的参数
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 --输入“n”增加一个分区
Command action --选择是建立主分区还是扩展分区
e extended
p primary partition (1-4)
p --输入“p”建立主分区
Partition number (1-4): 1 --输入分区号
First cylinder (1-130, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-130, default 130): 130
Command (m for help):w --写入分区表并退出
The partition table has been altered!
[root@redhad ~]# mkfs.ext3/dev/sdb1 --将新建立的分区进行格式化
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
130560 inodes, 261048 blocks
13052 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
16320 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Writing inode tables:done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will beautomatically checked every 26 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@redhad ~]# mkdir/newdisk --建立一个新的挂接目录
[root@redhad ~]# mount /dev/sdb1 /newdisk --将sdb1挂接到/newdisk下
[root@redhad ~]# df -lh --查看目前硬盘空闲,新建硬盘已经成功挂接
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 28G 2.4G 24G 9% /
none 506M 0 506M 0% /dev/shm
/dev/sdb1 1004M 18M 936M 2% /newdisk
到此为止,我们的新硬盘已经加载成功了,但是这里有一个问题,一旦我们重新启动系统,还需要用mount命令重新挂接才能访问新硬盘,如果我需要挂接的工作在系统启动过程中完成,那么我需要用vi配置/etc/fstab文件,将/dev/sdb1 /newdisk ext3 defaults 1 1 添加到/etc/fstab的最后,然后重新启动系统即可。