Resizing a VM: two questions

microlinux

New Member
Mar 30, 2021
17
1
3
58
Hi,

I'm using the following procedure to resize (e. g. expand) a VM:

Datacenter > sd-155842 > Oracle-Linux-7.9 > Hard disk > Resize disk > Size Increment (GB) : 10

Start the VM and connect to it.

Code:
# yum install cloud-utils-growpart
# lsblk
# growpart -v /dev/sda 3
# resize2fs /dev/sda3

Note : /dev/sda3 is the last partition on the disk and sports an ext4 filesystem.

Q1: is this a trivial procedure that can be used without even giving it a thought or is there some potential risk of data loss?

Q2: Can this procedure be somehow reversed without having to jump through burning loops, e. g. shrink the root partition when there's (too) much space available?

Cheers,

Niki
 
Q1: is this a trivial procedure that can be used without even giving it a thought or is there some potential risk of data loss?
risk ~ 0%
you can do it by hand with fdisk (recereate target partition with same start block address and new end block address without delete FS signature) + run resize2fs.
Also, it can be done fully online (without poweroff VM) with virtio scsi.
After resize FS recommended run fsck (this operation require unmount partition)
 
  • Like
Reactions: microlinux