按照阿里雲官網教程對雲服務器進行磁盤擴容,使用fdisk從新分區,最後使用e2fsck和resize2fs來完成文件系統層面的擴容html
在執行「e2fsck -f /dev/vdb1」命令時報錯,若是你的問題和下面的錯誤同樣,能夠接着往下看:node
[root@aliyunsrv ~]# e2fsck -f /dev/vdb1 e2fsck 1.41.12 (17-May-2010) e2fsck: Superblock invalid, trying backup blocks... e2fsck: Bad magic number in super-block while trying to open /dev/vdb1 The superblock could not be read or does not describe a correct ext2 filesystem. If the device is valid and it really contains an ext2 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock: e2fsck -b 8193 <device>
按照提示執行「e2fsck -b 8193 /dev/vdb1」,並無什麼用服務器
根據報錯信息推測是該工具並無找到super-block,也就是分區起始位置有問題ide
由於已經從新建立分區表,因此往前查看了命令記錄發現,分區的起始位置在103處,工具
[root@aliyunsrv ~]# fdisk -l Disk /dev/vda: 53.7 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00078f9c Device Boot Start End Blocks Id System /dev/vda1 * 1 6527 52426752 83 Linux Disk /dev/vdb: 536.9 GB, 536870912000 bytes 2 heads, 10 sectors/track, 52428800 cylinders Units = cylinders of 20 * 512 = 10240 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x63c3e6e0 Device Boot Start End Blocks Id System /dev/vdb1 103 52428800 524286976 83 Linux # 分區起始位置在103,很重要,須要肯定
由此其實能夠推測出阿里雲的磁盤擴容最近可能出問題了,以前分區我寫的一定是1,可是擴容後就變了,這個應該是致使這個問題的緣由測試
提阿里雲工單獲得的結果是用testdisk進行數據恢復,顯然這個不是我要的方法,這個只是分區表損壞,數據並無丟,處理好分區表便可。阿里雲
在網上找到的其餘老鐵的解決思路嘗試能夠解決,如今從新整理下供你們參考spa
須要使用到parted分區工具,如下操做注意數據備份!!!code
# 我在阿里雲控制檯擴展的分區大小爲1024GBorm
parted /dev/vdb
# 在parted交互式分區工具中執行
(parted) rm 1
注意:分區表用parted工具刪除後沒法直接使用fdisk進行分區
# 在parted交互式分區工具中執行
(parted) unit s (parted) rescue 103 1099GB
這裏根據以前的分區起始位置確認是103扇區,因爲parted工具默認啓動、結束位置單位都是用容量單位即kB/MB/GB,因此須要經過unit s命令定義默認使用sectors定義起始扇區。
完整的操做以下:
[root@aliyunsrv ~]# parted /dev/vdb GNU Parted 2.1 Using /dev/vdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) p # 打印分區表 Model: Virtio Block Device (virtblk) Disk /dev/vdb: 1100GB # 分區容量 Sector size (logical/physical): 512B/512B Partition Table: msdos # 分區表類型 Number Start End Size Type File system Flags 1 5120B 1100GB 1099GB primary # 當前的分區表信息,是不可用的 (parted) rm 1 # 刪除1號分區 (parted) unit s # 使用扇區號 (parted) rescue 103 1099GB # 恢復分區表 Information: A ext4 primary partition was found at 2048s -> 1048575999s. Do you want to add it to the partition table? # 找到了ext4格式的分區,起始扇區定位到2048,結束扇區是1048575999(推測的,若有問題歡迎指正) Yes/No/Cancel? y # 是否要建立該分區表,也就是恢復舊的分區表 (parted) p Model: Virtio Block Device (virtblk) Disk /dev/vdb: 2147483648s Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 2048s 1048575999s 1048573952s primary ext4 # 能夠看到這個是正確的磁盤分區表 (parted) q Information: You may need to update /etc/fstab.
這裏須要注意的是parted工具裏END的值,因爲磁盤的扇區數量不容易肯定,可使用容量來替代
[root@aliyunsrv ~]# parted /dev/vdb GNU Parted 2.1 Using /dev/vdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) p Model: Virtio Block Device (virtblk) Disk /dev/vdb: 1100GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 1049kB 537GB 537GB primary ext4 # 從新打開後發現分區表的顯示格式有變化,但並不影響,同時也能夠看出來是之前的分區表(未擴容前) (parted) rm 1 # 刪除舊的分區表 (parted) p Model: Virtio Block Device (virtblk) Disk /dev/vdb: 1100GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags (parted) unit s (parted) mkpart primary ext4 2048 1099GB # 建立新的分區表,注意要使用前文獲取的扇區起始位置2048 (parted) p Model: Virtio Block Device (virtblk) Disk /dev/vdb: 2147483648s Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 2048s 2146484223s 2146482176s primary ext4 # 新的分區表 (parted) q Information: You may need to update /etc/fstab.
此時新的分區表就建立成功了,須要注意:是使用的parted工具建立的分區表!!!
若是想使用fdisk進行分區,能夠在fdisk中使用2048起始扇區進行測試,注意數據備份!!!
[root@aliyunsrv ~]# e2fsck -f /dev/vdb1 e2fsck 1.41.12 (17-May-2010) 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: 237246/32768000 files (75.3% non-contiguous), 112383325/131071744 blocks
能夠正常執行檢查文件系統的操做
[root@aliyunsrv ~]# resize2fs /dev/vdb1 resize2fs 1.41.12 (17-May-2010) Resizing the filesystem on /dev/vdb1 to 268310272 (4k) blocks. The filesystem on /dev/vdb1 is now 268310272 blocks long.
能夠正常執行確認變動文件系統大小的操做,執行完便可掛在使用
最後使用工具檢查分區表狀態,供參考
[root@aliyunsrv ~]# parted /dev/vdb GNU Parted 2.1 Using /dev/vdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) p Model: Virtio Block Device (virtblk) Disk /dev/vdb: 1100GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 1049kB 1099GB 1099GB primary ext4
fdisk工具查看的信息
[root@aliyunsrv ~]# fdisk -l Disk /dev/vda: 53.7 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00078f9c Device Boot Start End Blocks Id System /dev/vda1 * 1 6527 52426752 83 Linux Disk /dev/vdb: 1099.5 GB, 1099511627776 bytes 255 heads, 63 sectors/track, 133674 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000ead8a Device Boot Start End Blocks Id System /dev/vdb1 1 133613 1073241088 83 Linux
附上提供幫助老鐵的文章連接:
https://bbs.aliyun.com/read/272957.html?pos=4
======= 完畢,呵呵呵呵 ========