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 顯示<b>硬碟</b>分割情形。
輸入 a 設定<b>硬碟</b>啟動區。
輸入 n 設定新的<b>硬碟</b>分割區。
輸入 e <b>硬碟</b>為[延伸]分割區(extend)。
輸入 p <b>硬碟</b>為[主要]分割區(primary)。
輸入 t 改變<b>硬碟</b>分割區屬性。
輸入 d 删除<b>硬碟</b>分割區屬性。
輸入 q 結束不存入<b>硬碟</b>分割區屬性。
輸入 w 結束并寫入<b>硬碟</b>分割區屬性
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
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
/dev/sdb1 1 487 3911796 83 Linux
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.
輸入mkfs -t ext3 /dev/sdb1
下一步設定卷标
[root@localhost ~]# e2label /dev/sdb1 /test
這裡/test 就是在根下起了個名字,
下一步建立挂載點
[root@localhost ~]# mkdir /test
下一步 設定開機自動挂載
[root@localhost ~]# vi /etc/fstab
<a href="http://yuzeying.blog.51cto.com/attachment/200904/23/644976_1240466518gFId.jpg"></a>
修改這個檔案為
<a href="http://yuzeying.blog.51cto.com/attachment/200904/23/644976_1240466520qVnt.jpg"></a>
LABEL=/test /test ext3 defaults 1 2
也就是加了這麼一句
儲存退出
下一步重新開機
[root@localhost ~]# reboot
<a href="http://yuzeying.blog.51cto.com/attachment/200904/23/644976_1240466523b9d6.jpg"></a>
能進系統說明挂載成功,要是進不了系統,那就是挂載失敗
[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 實驗成功
本文轉自 yuzeying1 51CTO部落格,原文連結:http://blog.51cto.com/yuzeying/152584