Linux添加新硬盤(pán)甲锡、分區(qū)、格式化羽戒、自動(dòng)掛載
在為主機(jī)添加硬盤(pán)前缤沦,首先要了解Linux系統(tǒng)下對(duì)硬盤(pán)和分區(qū)的命名方法。
1)
在Linux下對(duì)SCSI的設(shè)備是以sd命名的易稠,第一個(gè)ide設(shè)備是sda缸废,第二個(gè)是sdb,依此類(lèi)推。一般主板上有兩個(gè)SCSI接口缩多,一共可以安裝四個(gè)SCSI設(shè)備呆奕。主SCSI上的兩個(gè)設(shè)備分別對(duì)應(yīng)sda和sdb,第二個(gè)SCSI口上的兩個(gè)設(shè)備對(duì)應(yīng)sdc和sdd衬吆。一般硬盤(pán)安裝在主SCSI的主接口上,所以是sda或者sdb,光驅(qū)一般安裝在第二個(gè)SCSI的主接口上绳泉,所以是sdc.
(IDE接口設(shè)備是用hd命名的逊抡,第一個(gè)設(shè)備是hda,第二個(gè)是hdb零酪。依此類(lèi)推.)
2)分區(qū)是用設(shè)備名稱(chēng)加數(shù)字命名的冒嫡。例如sda1代表sda這個(gè)硬盤(pán)設(shè)備上的第一個(gè)分區(qū)。
3)每個(gè)硬盤(pán)可以最多有四個(gè)主分區(qū)四苇,一個(gè)擴(kuò)展分區(qū)孝凌,擴(kuò)展分區(qū)可以再分為多個(gè)邏輯分區(qū)。
如下為新加一個(gè)SCSI硬盤(pán)月腋,分區(qū)為擴(kuò)展分區(qū)蟀架,且只包含1個(gè)邏輯分區(qū)sdb1瓣赂,然后格式化為ext3,掛載到/test片拍,增加到/etc/fstab系統(tǒng)啟動(dòng)時(shí)自動(dòng)掛:
1煌集、給硬盤(pán)分區(qū)
fdisk /dev/sda
Command (m for help): n
Command action
e extended
p primary partition (1-4)
輸入:e
Partition number (1-4): 1
First cylinder (1-9729, default 1):回車(chē)
Last cylinder or +size or +sizeM or +sizeK (1-9729, default 9729):回車(chē)
Command (m for help):w(保存退出)
2、格式化硬盤(pán)
fdisk -l
mkfs -t ext3 /dev/sda1
Writing superblocks and filesystem accounting information:直接回車(chē)捌省。
3苫纤、掛載
mount /dev/sda1 /test
4、開(kāi)機(jī)直接掛載
編輯/etc/fstab 文件
添加:/dev/sda1 /test ext3 defaults 1 1
重啟則發(fā)選已經(jīng)掛載上去纲缓。
如下為新加一個(gè)ide硬盤(pán)卷拘,分區(qū)為擴(kuò)展分區(qū),且只包含1個(gè)邏輯分區(qū)hdb1祝高,然后格式化為ext3栗弟,最后掛載到/opt2:
[root]#?fdisk?/dev/hdb
Command?(m?for?help):?m?????(Enter?the?letter?"m"?to?get?list?of?commands)
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)
e
Partition?number?(1-4):?1
First?cylinder?(1-2654,?default?1):
Using?default?value?1
Last?cylinder?or?+size?or?+sizeM?or?+sizeK?(1-2654,?default?2654):
Using?default?value?2654
Command?(m?for?help):?p
Disk?/dev/hdb:?240?heads,?63?sectors,?2654?cylinders
Units?=?cylinders?of?15120?*?512?bytes
Device?Boot????Start???????End????Blocks???Id??System
/dev/hdb1?????????????1??????2654??20064208+???5??Extended
Command?(m?for?help):?w????(Write?and?save?partition?table)
[root]#?mkfs?-t?ext3?/dev/hdb1
mke2fs?1.27?(8-Mar-2002)
Filesystem?label=
OS?type:?Linux
Block?size=4096?(log=2)
Fragment?size=4096?(log=2)
2508352?inodes,?5016052?blocks
250802?blocks?(5.00%)?reserved?for?the?super?user
First?data?block=0
154?block?groups
32768?blocks?per?group,?32768?fragments?per?group
16288?inodes?per?group
Superblock?backups?stored?on?blocks:
32768,?98304,?163840,?229376,?294912,?819200,?884736,?1605632,?2654208,
4096000
Writing?inode?tables:?done
Creating?journal?(8192?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]#?mkdir?/opt2
[root]#?mount?-t?ext3?/dev/hdb1?/opt2