Linux的根分区如果已经使用率达到100,导致服务不能正常进行,我们可以这样扩展根目录的大小(注意:下面所有操作需在root用户下完成)。 1。新加一块硬盘(这里使用的是sde),先创建物理卷 注意:扩展的分区必须要是linuxlvm卷,是否是lvm卷是由磁盘第一次分区时候选择的分区格式决定的。 〔rootbigdata105〕fdiskdevsde DevicecontainsneitheravalidDOSpartitiontable,norSun,SGIorOSFdisklabel BuildinganewDOSdisklabelwithdiskidentifier0x6133f941。 Changeswillremaininmemoryonly,untilyoudecidetowritethem。 Afterthat,ofcourse,thepreviouscontentwontberecoverable。 Warning:invalidflag0x0000ofpartitiontable4willbecorrectedbyw(rite) WARNING:Thesizeofthisdiskis3。0TB(3000592982016bytes)。 DOSpartitiontableformatcannotbeusedondrivesforvolumes largerthan(2199023255040bytes)for512bytesectors。Useparted(1)andGUID partitiontableformat(GPT)。 WARNING:DOScompatiblemodeisdeprecated。Itsstronglyrecommendedto switchoffthemode(commandc)andchangedisplayunitsto sectors(commandu)。 Command(mforhelp):n(命令n用于添加新分区) Commandaction eextended pprimarypartition(14) p(选择创建主分区) Partitionnumber(14):1 Firstcylinder(1364801,default1):(回车,默认将所有空间分配给第一个主分区) Usingdefaultvalue1 Lastcylinder,cylindersorsize{K,M,G}(1267349,default267349): Usingdefaultvalue267349 Command(mforhelp):t(修改磁盘格式) Selectedpartition1(指定分区号) Hexcode(typeLtolistcodes):8e(8e代表LVM) Changedsystemtypeofpartition1to8e(LinuxLVM) Command(mforhelp):w(保存所有并退出) Thepartitiontablehasbeenaltered! Callingioctl()torereadpartitiontable。 Syncingdisks。 2。查看当前磁盘情况 〔rootbigdata105〕fdiskl Diskdevsde:3000。6GB,3000592982016bytes 255heads,63sectorstrack,364801cylinders Unitscylindersof160655128225280bytes Sectorsize(logicalphysical):512bytes512bytes IOsize(minimumoptimal):512bytes512bytes Diskidentifier:0x6133f941 DeviceBootStartEndBlocksIdSystem devsde1126734921474808118eLinuxLVM 可以看到devsde1已支持LVM。 3。将新创建的主分区创建为物理卷 〔rootbigdata105〕pvcreatedevsde1 Physicalvolumedevsde1successfullycreated 4。dfh命令查看根目录所属的卷组和逻辑卷 〔rootbigdata105〕dfh FilesystemSizeUsedAvailUseMountedon devmappervgi8350rlvroot542G318G197G62 tmpfs127G254M126G1devshm devsdd1485M40M420M9boot devmappervgi8350rlvhome221G58G152G28home 这里根目录所属的卷组是vgi8350r,逻辑卷是devmappervgi8350rlvroot 5。将刚创建的物理卷devsde1添加到卷组中 〔rootbigdata105〕vgextendvgi8350rdevsde1 FoundduplicatePVi35fwCm5JjA6P77IVdaXDDYQBg50o5hm:usingdevsdd2notdevsdc2 Volumegroupvgi8350rsuccessfullyextended 6。将卷组的200GB扩展给根所在的逻辑卷 〔rootbigdata105〕lvextendL200Gdevmappervgi8350rlvroot Extendinglogicalvolumelvrootto750。00GiB Logicalvolumelvrootsuccessfullyresized 7。激活修改的配置 〔rootbigdata105〕resize2fsdevmappervgi8350rlvroot resize2fs1。41。12(17May2010) Filesystematdevmappervgi8350onlineresizingrequired olddescblocks35,newdescblocks47 Performinganonlineresizeofdevmappervgi8350rlvrootto196608000(4k)blocks。 Thefilesystemondevmappervgi8350rlvrootisnow196608000blockslong。 8。查看扩展后系统情况 〔rootbigdata105〕dfh FilesystemSizeUsedAvailUseMountedon devmappervgi8350rlvroot739G318G383G46 tmpfs127G254M126G1devshm devsdd1485M40M420M9boot devmappervgi8350rlvhome221G58G152G28home 扩展前系统情况 〔rootbigdata105〕dfh FilesystemSizeUsedAvailUseMountedon devmappervgi8350rlvroot542G318G197G62 tmpfs127G254M126G1devshm devsdd1485M40M420M9boot devmappervgi8350rlvhome221G58G152G28home 根目录已经成功扩展200G空间。 9。其他 如果扩展的根目录下装有其它服务,如数据库,则扩展操作完成后需要重启数据库。