主机自带硬盘超过300GB,目前只划分使用了3个主分区,不到70GB,如下:
[root@db2~]#df-h
FilesystemSizeUsedAvailUse%Mountedon
/dev/sda129G3.7G24G14%/
/dev/sda229G22G5.2G81%/oracle
tmpfs2.0G02.0G0%/dev/shm
[root@db2~]#cat/proc/partitions
majorminor#blocksname
80311427072sda
sda1
8230716280sda2
838193150sda3
816976896sdb
832976896sdc
现在需要给系统添加1个100GB的空间存放数据文件,而又不影响现有系统上业务的运行,
使用fdisk结合partprobe命令不重启系统添加一块新的磁盘分区。操作步骤如下:
第1步,添加新的磁盘分区
[root@db2~]#fdisk/dev/sda
Thenumberofcylindersforthisdiskissetto38770.
Thereisnothingwrongwiththat,butthisislargerthan1024,
andcouldincertainsetupscauseproblemswith:
1)softwarethatrunsatboottime(e.g.,oldversionsofLILO)
2)bootingandpartitioningsoftwarefromotherOSs
(e.g.,DOSFDISK,OS/2FDISK)
Command(mforhelp):p
Disk/dev/sda:318.9GB,318901321728bytes
255heads,63sectors/track,38770cylinders
Units=cylindersof16065*512=8225280bytes
DeviceBootStartEndBlocksIdSystem
/dev/sda1*1382430716248+83Linux
/dev/sda2382576483071628083Linux
/dev/sda376498668819315082Linuxswap/Solaris
Command(mforhelp):n
Commandaction
eextended
pprimarypartition(1-4)
p
Selectedpartition4
Firstcylinder(8669-38770,default8669):
Usingdefaultvalue8669
Lastcylinderor+sizeor+sizeMor+sizeK(8669-38770,default38770):+100G
Command(mforhelp):w
Thepartitiontablehasbeen altered!
Callingioctl()tore-readpartitiontable.
WARNING:Re-readingthepartitiontablefailedwitherror16:
Deviceorresourcebusy.
Thekernelstillusestheoldtable.
Thenewtablewillbeusedatthenextreboot.
Syncingdisks.
[root@db2~]#
第2步,使用工具partprobe让kernel读取分区信息
[root@db2~]#partprobe
使用fdisk工具只是将分区信息写到磁盘,如果需要mkfs磁盘分区则需要重启系统,
而使用partprobe则可以使kernel重新读取分区信息,从而避免重启系统。
第3步,格式化文件系统
[root@db2~]#mkfs.ext3/dev/sda4
mke2fs1.39(29-May-2006)
Filesystemlabel=
OStype:Linux
Blocksize=4096(log=2)
Fragmentsize=4096(log=2)
12222464inodes,24416791blocks
1220839blocks(5.00%)reservedforthesuperuser
Firstdatablock=0
Maximumfilesystemblocks=4294967296
746blockgroups
32768blockspergroup,32768fragmentspergroup
16384inodespergroup
Superblockbackupsstoredonblocks:
32768,98304,163840,229376,294912,819200,884736,1605632,
2654208,4096000,7962624,11239424,20480000,23887872
Writinginodetables:done
Creatingjournal(32768blocks):done
Writingsuperblocksandfilesystemaccountinginformation:
done
Thisfilesystemwillbeautomaticallycheckedevery26mountsor
180days,whichevercomesfirst.Usetune2fs-cor-itooverride.
[root@db2~]#
第4步,mount新的分区/dev/sda4
[root@db2~]#e2label/dev/sda4/data
[root@db2~]#mkdir/data
[root@db2~]#mount/dev/sda4/data
[root@db2~]#df
Filesystem1K-blocksUsedAvailableUse%Mountedon
/dev/sda12975355638108442440690014%/
/dev/sda229753588113046161691316041%/oracle
tmpfs2023936020239360%/dev/shm
/dev/sda496132968192312910573001%/data
[root@db2~]#
总结:使用partprobe可以不用重启系统即可配合fdisk工具创建新的分区。