即使在Azure端扩展了OS磁盘的大小,虚拟机中的CentOS端也不会自动扩展该区域。
这是使用fdisk命令删除/dev/sda的主分区1并使用最大容量重新创建它的过程。
[azureuser@TESTVM01 ~]$ sudo fdisk /dev/sda The device presents a logical sector size that is smaller than the physical sector size. Aligning to a physical sector (or optimal I/O) size boundary is recommended, or performance may be impacted. Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p Disk /dev/sda: 1098.4 GB, 1098437885952 bytes, 2145386496 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk label type: dos Disk identifier: 0x000dd16b Device Boot Start End Blocks Id System /dev/sda1 * 2048 62914559 31456256 83 Linux Command (m for help): d Selected partition 1 Partition 1 is deleted Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-2145386495, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-2145386495, default 2145386495): Using default value 2145386495 Partition 1 of type Linux and of size 1023 GiB is set Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.
在CentOS 7中,根分区的格式是xfs,因此xfs_growfs用于区域扩展(在ext 4的情况下调整resize 2 fs命令)。
[azureuser@TESTVM01 ~]$ sudo xfs_growfs /dev/sda1
meta-data=/dev/sda1 isize=256 agcount=4, agsize=1966016 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=7864064, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=3839, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 7864064 to 268173056
成功执行命令后,根分区的区域将扩展为其最大大小。
[azureuser@TESTVM01 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 1023G 1.3G 1022G 1% /
devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 8.3M 2.0G 1% /run
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sdb1 7.8G 36M 7.3G 1% /mnt/resource
tmpfs 395M 0 395M 0% /run/user/1000
评论
还没有任何评论,你来说两句吧!