New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Resize KVM VPS
Hello guys,
I'm trying to resize a KVM VPS but unsure what is the correct procedure. I increased the hard disk from within SolusVMS from 40GB to 45GB and rebooted the VPS however what is the next step in order to expand the partition of the VPS?
Granted there is data on the VPS that I don't want to loose.
Comments
step 1 - back it up,
step 2 - sudo resize2fs /
(if using whole disk vda as a FS, if its partitioned then try parted)
If the disk is resized, then you can increase the partition size with fdisk, followed by increasing the filesystem size with resize2fs.
For online resize, see e.g. https://wiki.lunanode.com/index.php/Frequently_asked_questions#My_disk_space_is_smaller_than_the_plan_disk for the fdisk step; then reboot VM after fdisk step is done, and run resize2fs on the partition
For offline resize, where you boot to ISO and do resize via live CD, it's easier, you can use something like parted; but pretty much the same thing. Offline resize for the partition is also safer (for filesystem, resize2fs is pretty reliable either way).
Warning: if you do fdisk step incorrectly then you could lose data.
Would I do this from within the host node or within the actual VPS?
Better than online resize is booting in either rescue (via VNC) or loading a GRML ISO and do it from there.
Ideally you would do from host node (or use ISO, point is to avoid online resize), but both are possible. If you have a raw disk image, you would register it as block device (see http://dgc.uchicago.edu/20130530/mounting-a-kvm-disk-image-without-kvm/) and then run fdisk on the block device to resize partition. Then you should be able to detect partitions in the block device on host node, and then resize2fs on the partition containing the filesystem.
Note: if you have qcow2 disk image, then you can use qemu-nbd to register it as block device:
And then disconnect it:
Note: also always good idea to copy the disk image to make a backup before you resize. Also obviously if you have LVM partition the steps are going to be different than if you have disk image.
Cool, thanks to both - I managed to resize it fine.
Another way (if you're using straight up libvirt / qemu) would be this
Examine what file systems are on there first.
Expand an image and resize it.
If you are not using LVM:
Do backup before you do anything like this.