原数据盘 20G 扩容至 25G,购买后通过 SSH 登陆实例进行操作;

操作步骤完全参考阿里云帮助即可:https://help.aliyun.com/document_detail/25452.html

[root@iZ2ze4knyxhkgpnbo7brn7Z ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        40G   15G   23G  39% /
tmpfs           939M     0  939M   0% /dev/shm
/dev/vdb1        20G   13G  6.7G  65% /home/wwwroot
[root@iZ2ze4knyxhkgpnbo7brn7Z ~]# umount /dev/vdb1
[root@iZ2ze4knyxhkgpnbo7brn7Z ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        40G   15G   23G  39% /
tmpfs           939M     0  939M   0% /dev/shm
[root@iZ2ze4knyxhkgpnbo7brn7Z ~]# fdisk -l

Disk /dev/vda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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: 0x00020f03

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           1        5222    41940992   83  Linux

Disk /dev/vdb: 26.8 GB, 26843545600 bytes
16 heads, 63 sectors/track, 52012 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x78d92770

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1               1       41610    20971408+  83  Linux
[root@iZ2ze4knyxhkgpnbo7brn7Z ~]# fdisk /dev/vdb

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): d
Selected partition 1

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-52012, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-52012, default 52012): 
Using default value 52012

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@iZ2ze4knyxhkgpnbo7brn7Z ~]# 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: 95741/1310720 files (0.8% non-contiguous), 3228283/5242852 blocks
[root@iZ2ze4knyxhkgpnbo7brn7Z ~]# resize2fs /dev/vdb1
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vdb1 to 6553504 (4k) blocks.
The filesystem on /dev/vdb1 is now 6553504 blocks long.

[root@iZ2ze4knyxhkgpnbo7brn7Z ~]# mount /dev/vdb1 /home/wwwroot
[root@iZ2ze4knyxhkgpnbo7brn7Z ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        40G   15G   23G  39% /
tmpfs           939M     0  939M   0% /dev/shm
/dev/vdb1        25G   13G   12G  52% /home/wwwroot

值得注意的点是 fdisk 命令操作时, 是使用 fdisk /dev/vdb 而不是 fdisk /dev/vdb1,这里没仔细看坑了我好长时间,一直扩容失败;

扩容成功。

发表评论

电子邮件地址不会被公开。 必填项已用*标注