I set the disk size of my root
drive too low, and need to expand it. Default install of Ubuntu 16lts server
.
I've searched and the answers/solutions found do not address the issue. (the problems appear identical, but the steps didn't work or the options were not available on my system).
- no How do I resize root partition?
- no https://help.ubuntu.com/community/HowtoPartition/ResizingPartition
- no https://superuser.com/questions/917988/gparted-cannot-resize-extended-or-lvm-partition
- I wasn't able to make any progress with several other answers lvm (
lvchange
manually, as well assystem-config-lvm
) from inside a separate booted ubuntu box.
I'm booting a gparted live-cd (latest/just downloaed), but i also tried this by plugging the disk into a different ubuntu system (another VM). As you can see in the gparted screenshot below, i have
- booted a liveCD (gparted)
- one disk (
sda
) incidentally, it's a VDI in Virtualbox. I have already enlarged the disk (as shown in the 'unallocated space` - of interest is
/dev/sda5
lvm volume which is contained in/dev/sda2
extended
I've tried:
- From the gparted live iso, I can right-click
/dev/sda5
todeactivate
. Also, thelvdisplay
output below is AFTER this deactivate.- however this doesn't remove the Lock (but does think for some time while, and re-scans the disk)
- and resize remains greyed out on
/dev/sda2
- lvdisplay doesn't seem to show a change
- from the command line, run
lvchange -an
,- does seem to change the available status on /dev/sda5
- but closing/re-opening gparted still shows locked
Thank you, I appreciate your help!
mount | grep sd
–> nothing (not shown). From the gparted live-iso i have also dumped fdisk -l
Best Answer
After a lot of consternation :) I discovered my issue was related at least in part to snapshots (as mentioned, this is all in a VM).
.vdi
, didn't do anything with the snapshotsto prove this out, i cloned the VM from virtualbox's snapshot UI, which gives the option to flatten it at the current state.
This appears to work (including no observed data corruption) so I'm back booted in the original svr vm, with the resized disk!
VboxManage.exe modifyhd <vdi> --resize 50000
#~50gb/dev/mm-ubuntu16-svr-vg/root
/dev/MY_VG/root
belowmount | grep 'VG'
thensudo umount <mountpoint>
if it was mountedsudo lvchange -an /dev/MY_VG
# remove the logical volumesudo vgchange -an MY_VG
# remove the volume groupsudo gparted &
# proceed with normal resize/dev/sda2
followed by a resize (grow) on/dev/sda5
lvresize -l +100%FREE /dev/MY_VG/root
e2fsk -f /dev/MY_VG/root
# resize2fs prompted me to run this cleanupresize2fs /dev/MY_VG/root
Done! while still in the other VM, mount and check capacity:
sudo vgchange -ay MY_VG && sudo lvchange -ay /dev/MY_VG
# eg reverse of the removesudo mkdir <mountpoint> && sudo mount /dev/MY_VG/root <mountpoint>
df -h
# YAY shows ~50gb total !And then shutting down, and booting into the original (well, the Cloned & flattened) vm, it boots and has the expected free space / 50gb root drive & filesystem.
hope this helps someone!