概述
云平臺(tái)客戶(hù)的服務(wù)器可能會(huì)隨著業(yè)務(wù)量的不斷增長(zhǎng)造成磁盤(pán)空間不足的情況,比如:共享文件服務(wù)器硬盤(pán)空間不足,在這個(gè)時(shí)候就需要增加磁盤(pán)空間,來(lái)滿(mǎn)足線(xiàn)上的業(yè)務(wù);又或者我們?cè)谑褂胠inux的過(guò)程中, 有時(shí)會(huì)因?yàn)榘惭b系統(tǒng)時(shí)分區(qū)不當(dāng)導(dǎo)致有的分區(qū)空間不足,而有的分區(qū)空間過(guò)剩的情況,都可以是使用fdisk分區(qū)工具來(lái)動(dòng)態(tài)調(diào)整分區(qū)的大小;
步驟
1.備份
就算是無(wú)損的擴(kuò)容,但難免會(huì)出什么意外,備份是必不可少的,一般云平臺(tái)都有備份功能,可直接對(duì)磁盤(pán)做一次全量備份。
2.用fdisk重新分區(qū)
默認(rèn)的分區(qū)如下
root@i-abnawjwo:/# dfFilesystem 1K-blocks Used Available Use% Mounted onudev 497752 4 497748 1% /devtmpfs 101700 440 101260 1% /run/dev/sda1 20509308 1337636 18106816 7% /none 4 0 4 0% /sys/fs/cgroupnone 5120 0 5120 0% /run/locknone 508488 0 508488 0% /run/shmnone 102400 0 102400 0% /run/user/dev/sdc1 10190136 23032 9626432 1% /dataroot@i-abnawjwo:/data# cat hellotest1
卸載當(dāng)前的分區(qū) umount /dev/sdc1
若是卸載不掉,有可能是有進(jìn)程再用,可以用fuser或者lsof查看
fuser -m -v /datafuser -m -v -i -k /datalsof /data
卸載掉后fdisk刪除原來(lái)的分區(qū),重新分區(qū), 注意開(kāi)始的磁柱號(hào)要和原來(lái)的一致(這是保證數(shù)據(jù)不丟失的關(guān)鍵步驟)
root@i-abnawjwo:/# umount /dataroot@i-abnawjwo:/# fdisk /dev/sdcCommand (m for help): dSelected partition 1Command (m for help): nPartition type: p primary (0 primary, 0 extended, 4 free) e extendedSelect (default p):Using default response pPartition number (1-4, default 1):Using default value 1First sector (2048-104857599, default 2048):Using default value 2048Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599):Using default value 104857599Command (m for help): pDisk /dev/sdc: 53.7 GB, 53687091200 bytes64 heads, 32 sectors/track, 51200 cylinders, total 104857600 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x305cddae Device Boot Start End Blocks Id System/dev/sdc1 2048 104857599 52427776 83 LinuxCommand (m for help): wqThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.
重啟系統(tǒng)
3.檢測(cè)分區(qū),擴(kuò)展分區(qū)大小
root@i-abnawjwo:~# e2fsck -f /dev/sdb1e2fsck 1.42.9 (4-Feb-2014)Pass 1: Checking inodes, blocks, and sizesPass 2: Checking directory structurePass 3: Checking directory connectivityPass 4: Checking reference countsPass 5: Checking group summary information/dev/sdb1: 12/655360 files (0.0% non-contiguous), 79664/2621440 blocksroot@i-abnawjwo:~# resize2fs -p /dev/sdb1resize2fs 1.42.9 (4-Feb-2014)Resizing the filesystem on /dev/sdb1 to 13106944 (4k) blocks.The filesystem on /dev/sdb1 is now 13106944 blocks long.
4.重新掛載,查看分區(qū)大小,檢查數(shù)據(jù)
root@i-abnawjwo:~# mount /dev/sdb1 /data/root@i-abnawjwo:/data# cat helloacasdcacsaroot@i-abnawjwo:/data# dfFilesystem 1K-blocks Used Available Use% Mounted onudev 497752 4 497748 1% /devtmpfs 101700 428 101272 1% /run/dev/sda1 20509308 1337768 18106684 7% /none 4 0 4 0% /sys/fs/cgroupnone 5120 0 5120 0% /run/locknone 508488 0 508488 0% /run/shmnone 102400 0 102400 0% /run/user/dev/sdb1 51474044 33100 48803172 1% /data
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持VEVB武林網(wǎng)。
新聞熱點(diǎn)
疑難解答
圖片精選