linux vm 添加硬盘
将虚拟机关闭,加载一块硬盘
fdisk -l 发现新加载的硬盘标号是sdc ,也就是第三块硬盘
fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
BuildinganewDOSdisklabel.Changeswillremaininmemoryonly,
untilyoudecidetowritethem.Afterthat,ofcourse,theprevious
contentwon'tberecoverable.
Thenumberofcylindersforthisdiskissetto2349.
Thereisnothingwrongwiththat,butthisislargerthan1024,
andcouldincertainsetupscauseproblemswith:
1)softwarethatrunsatboottime(e.g.,oldversionsofLILO)
2)bootingandpartitioningsoftwarefromotherOSs
(e.g.,DOSFDISK,OS/2FDISK)
Warning:invalidflag0x0000ofpartitiontable4willbecorrectedbyw(rite)
Command(mforhelp):m
Commandaction
atoggleabootableflag
beditbsddisklabel
ctogglethedoscompatibilityflag
ddeleteapartition
llistknownpartitiontypes
mprintthismenu
naddanewpartition
ocreateanewemptyDOSpartitiontable
pprintthepartitiontable
qquitwithoutsavingchanges
screateanewemptySundisklabel
tchangeapartition'ssystemid
uchangedisplay/entryunits
vverifythepartitiontable
wwritetabletodiskandexit
xextrafunctionality(expertsonly)
Command(mforhelp):n
Commandaction
eextended
pprimarypartition(1-4)
e
Partitionnumber(1-4):1
Firstcylinder(1-2349,default1):
Usingdefaultvalue1
Lastcylinderor+sizeor+sizeMor+sizeK(1-2349,default2349):
Usingdefaultvalue2349
Command(mforhelp):w
Thepartitiontablehasbeenaltered!
Callingioctl()tore-readpartitiontable.
Syncing disks.[root@qa~]#mkfs-text3-c/dev/sdc1
mke2fs1.39(29-May-2006)
/dev/sdc1: Invalid argument passed to ext2 library while setting up superblock这是应为,在创建分区时添加的是扩展分区,扩展分区不能直接format,需要对扩展分区再划分出逻辑分区
主分区,扩展分区,逻辑分区三者有什么不同?什么关系?各用在何处
1.每个硬盘有一个主分区表,其中每项表示一个主分区,定义了硬盘上的一段连续空间,
主分区可以是各种类型的,如fat,linuxext2,fat32,ntfs等等
2.主分区表有一个限制,最多只能有四个.于是就有了扩展分区:
这是一个特殊的主分区,它不能直接使用,而是象一个指针,指向一个扩展分区表.
每个硬盘只能有一个扩展分区.
3.在扩展分区表中定义的分区就叫逻辑分区,它的功能,作用和主分区类似,
但被限制在扩展分区所定义的空间大小范围内.[root@qa ~]# fdisk /dev/sdc
Thenumberofcylindersforthisdiskissetto2349.
Thereisnothingwrongwiththat,butthisislargerthan1024,
andcouldincertainsetupscauseproblemswith:
1)softwarethatrunsatboottime(e.g.,oldversionsofLILO)
2)bootingandpartitioningsoftwarefromotherOSs
(e.g.,DOSFDISK,OS/2FDISK)
Command(mforhelp):m
Commandaction
atoggleabootableflag
beditbsddisklabel
ctogglethedoscompatibilityflag
ddeleteapartition
llistknownpartitiontypes
mprintthismenu
naddanewpartition
ocreateanewemptyDOSpartitiontable
pprintthepartitiontable
qquitwithoutsavingchanges
screateanewemptySundisklabel
tchangeapartition'ssystemid
uchangedisplay/entryunits
vverifythepartitiontable
wwritetabletodiskandexit
xextrafunctionality(expertsonly)
Command(mforhelp):n
Commandaction
llogical(5orover)
pprimarypartition(1-4)
l5
Firstcylinder(1-2349,default1):
Usingdefaultvalue1
Lastcylinderor+sizeor+sizeMor+sizeK(1-2349,default2349):
Usingdefaultvalue2349
Command(mforhelp):w
Thepartitiontablehasbeenaltered!
Callingioctl()tore-readpartitiontable.
Syncing disks.扩展分区的逻辑化完成了。
现在format:
[root@qa ~]# mkfs -t ext3 -c /dev/sdc5
mke2fs1.39(29-May-2006)
Couldnotstat/dev/sdc5---Nosuchfileordirectory
Thedeviceapparentlydoesnotexist;didyouspecifyitcorrectly?
[root@qa~]#mkfs-text3-c/dev/sdc5
mke2fs1.39(29-May-2006)
Filesystemlabel=
OStype:Linux
Blocksize=4096(log=2)
Fragmentsize=4096(log=2)
2359296inodes,4717069blocks
235853blocks(5.00%)reservedforthesuperuser
Firstdatablock=0
Maximumfilesystemblocks=0
144blockgroups
32768blockspergroup,32768fragmentspergroup
16384inodespergroup
Superblockbackupsstoredonblocks:
32768,98304,163840,229376,294912,819200,884736,1605632,2654208,
4096000
Checkingforbadblocks(read-onlytest):done
Writinginodetables:done
Creatingjournal(32768blocks):done
Writingsuperblocksandfilesystemaccountinginformation:done
Thisfilesystemwillbeautomaticallycheckedevery29mountsor
180 days, whichever comes first. Use tune2fs -c or -i to override.挂载
mount /dev/sdc5 /srv
把挂载添加到分区表中,这样系统每次启动的时候就自动挂载这个分区
vi /etc/fstab
添加/dev/sdc5 /srv ext3 defaults 0 0
注意:如果被挂载点目录下有资料,所有的资料都会消失