linux 下加挂硬盘的具体做法
实验环境 VMware 6.5 +redhat Enterprise linux 5
大致可分这么个步骤
1 :先加挂一块硬盘
2 :创建分区
3 :格式化硬盘
4 :设置卷标
5 :创建挂载点
6 :挂载 (自动,手动)
挂硬盘就不说了,
创建分区
[root@localhost ~]# fdisk /dev/sdb
sda是第一块SCSI硬盘,sdb第二块,以此类推...物理分区使用a、b编号,每个物理硬盘最多有四个主逻辑分区(或扩展分区),所以自动分区中,扩展分区sda2下第一个逻辑分区编号从5开始
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.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help):
这里按m获得帮助
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)
 输入 p 显示硬盘分割情形。
 输入 a 设定硬盘启动区。
 输入 n 设定新的硬盘分割区。
 输入 e 硬盘为[延伸]分割区(extend)。
 输入 p 硬盘为[主要]分割区(primary)。
 输入 t 改变硬盘分割区属性。
 输入 d 删除硬盘分割区属性。
 输入 q 结束不存入硬盘分割区属性。
输入 w 结束并写入硬盘分割区属性
Command (m for help): p
Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
(我挂了个4G的硬盘)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
输入p
p
Partition number (1-4):
分区号 输入1
Partition number (1-4): 1
First cylinder (1-522, default 1):
第几个柱面我们从1开始
First cylinder (1-522, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-522, default 522): +4000M
这里我们按大小输入 即+4000M (注意这个M为大写)
Command (m for help): P
Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 487 3911796 83 Linux
输入p
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]#
输入w保存退出
下一步 格式化
[root@localhost ~]# mkfs -t ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
489600 inodes, 977949 blocks
48897 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1002438656
30 block groups
32768 blocks per group, 32768 fragments per group
16320 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost ~]#
输入mkfs -t ext3 /dev/sdb1
下一步设置卷标
[root@localhost ~]# e2label /dev/sdb1 /test
这里/test 就是在根下起了个名字,
下一步创建挂载点
[root@localhost ~]# mkdir /test
下一步 设置开机自动挂载
[root@localhost ~]# vi /etc/fstab
clip_image002
修改这个文件为
clip_image004
LABEL=/test /test ext3 defaults 1 2
也就是加了这么一句
保存退出
下一步重启
[root@localhost ~]# reboot
clip_image006
能进系统说明挂载成功,要是进不了系统,那就是挂载失败
[root@localhost /]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 6092388 1990056 3787860 35% /
/dev/sda3 988116 17700 919412 2% /home
/dev/sda1 46633 10277 33948 24% /boot
tmpfs 517660 0 517660 0% /dev/shm
/dev/sdb1 3850292 73248 3581456 3% /test
[root@localhost /]#
统计一下分区使用情况,ok 实验成功