天天看點

雲伺服器磁盤擴容後不顯示,騰訊雲伺服器磁盤擴容問題小記

作業系統:CentOS 7.2 ,檔案類型:ext3

磁盤擴容前,一定要先做磁盤快照備份。

1.解除安裝挂載點報錯:

umount /dev/vdb1

umount: /u01: target is busy.

(In some cases useful info about processes that use the device is found by lsof(8) or fuser(1))

使用fuser -k /dev/vdb1 找不到關聯的程序;同時使用lsof |grep /dev/vdb1 也找不到關聯的程序。

解決方法:重新開機伺服器後停止了雲鏡、httpd、nfs等服務後成功解除安裝資料盤

使用:e2fsck -f /dev/vdb1 > aa.txt & 掃描修複磁盤,300G磁盤執行這條指令需要2個小時。

Pass 1: Checking inodes, blocks, and sizes

Pass 2: Checking directory structure

Pass 3: Checking directory connectivity

Pass 4: Checking reference counts

Pass 5: Checking group summary information

/dev/vdb1: 2892836/19660800 files (14.7% non-contiguous), 72828039/78642944 blocks

執行指令:resize2fs /dev/vdb1 #沒有報錯,但磁盤也沒有擴容。

resize2fs 1.42.9 (28-Dec-2013) The filesystem is already 78642944 blocks long. Nothing to do!

執行:fdisk -l /dev/vdb1 #檢視磁盤空間

Disk /dev/vdb1: 322.1 GB, 322121498624 bytes, 629143552 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes

更換另一種方式:

wget -O /tmp/devresize.py https://raw.githubusercontent.com/tencentyun/tencentcloud-cbs-tools/master/devresize/devresize.py ssh -o ServerAliveInterval=60000 [email protected] #避免ssh因長時間沒有輸入而斷開連接配接

nohup python /tmp/devresize.py /dev/vdb > result.txt & #這裡需要使用磁盤/dev/vdb,而不是分區/dev/vdb1。300G磁盤執行這條指令需要3個小時。

a.指令執行時間過長,出現Write failed: Broken pipe ssh連接配接斷開的問題。連接配接斷開後,執行就失敗了。

b.在執行指令的過程中,不能斷開遠端伺服器的連接配接,否則也會執行失敗。如使用指令:python /tmp/devresize.py /dev/vdb > result.txt & 。在斷開window遠端伺服器的連接配接後,xshell視窗中的執行任務,也會自動中斷。

後續改進:把檔案系統格式從ext3切換到ext4後,會縮減磁盤擴容的時間。

作業系統:CentOS 7.2 ,檔案類型:ext3,把格式轉換成ext4

ssh -o ServerAliveInterval=30 [email protected]

fdisk -l /dev/vdb1

service httpd stop

fuser -um -v /dev/vdb1

systemctl stop YDService

systemctl stop nfs

!umo

tune2fs -O extents,uninit_bg,dir_index /dev/vdb1

fsck -pf /dev/vdb1

mount -t ext4 /dev/vdb1 /u01

vim /etc/fstab

/dev/vdb1 /u01 ext4 defaults 0 0

df -T 隻可以檢視已經挂載的分區和檔案系統類型。

fdisk -l 可以顯示出所有挂載和未挂載的分區,但不顯示檔案系統類型。

file -s /dev/vdb1