Cannot modify VM disks

I have a 64-bit Ubuntu 12.04 KVM instance which I built from an image I purchsed from stacklet.com and converted to KVM format with Cloudmin.

When I created the VM, I set the root disk to 40GB and swap to 1GB. It created two disk images: 20GB root and 1GB swap. However, the swap image was not mounted. I was able to mount the swap by adding it (/dev/sdb1, as reported by fdisk) to /etc/fstab. I also chaned LABEL=root to /dev/sda1 for the root device.

I then tried to resize the 20GB image to 40GB, which failed. I noticed the device name was listed as /dev/hda for the root disk and /dev/hdb for swap. I tried to change these to /dev/sda1 and /dev/sdb1 with no success -- it says it worked, but remained set to the initial values.

There's other strangness going on too, e.g. I tried to remove the swap disk and re-add it, and it added as the root disk (i.e. "Mounted on / as Linux EXT4 (new)").

I wonder if this will be fixed by http://www.virtualmin.com/node/24175 or if there's another issue here.

Status: 
Active

Comments

What error did you get when the resize failed?

Right now I'm getting:

Warning - this disk cannot be safely resized. Cloudmin does not know what type of filesystem this disk contains, and so cannot properly resize it. This is most likely because the disk is not mounted on the virtual system.

However, there were different errors on different attempts as I tried various solutions. Sorry, didn't document them.

The real problem, I think, is that Cloudmin thinks this is /dev/hda while on the VM it's /dev/sda.

Could you post the /etc/fstab file from the virtual system?

Ok so I broke the VM (could not ping or log in via SSH) by trying to resize the disk, but I had tried so many things, who knows what the state was at that point.

So I deleted it, and created a fresh machine. I chose 40 GB disk and 1 GB swap, but it created a 20 GB disk and no swap.

I logged in and did the following:

root@athens:~# cat /etc/fstab LABEL=root / ext4 defaults,errors=remount-ro 1 1 /dev/hdb1 swap swap defaults 0 0 root@athens:~# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 20G 1.2G 18G 6% / udev 494M 4.0K 494M 1% /dev tmpfs 200M 216K 199M 1% /run none 5.0M 0 5.0M 0% /run/lock none 498M 0 498M 0% /run/shm root@athens:~# free -m total used free shared buffers cached Mem: 995 70 924 0 8 20 -/+ buffers/cache: 41 954 Swap: 0 0 0 root@athens:~# sudo fdisk -l |grep /dev Disk /dev/sda: 21.5 GB, 21474836480 bytes /dev/sda1 2048 41943039 20970496 83 Linux Disk /dev/sdb: 2147 MB, 2147483648 bytes /dev/sdb1 2048 4194303 2096128 82 Linux swap / Solaris root@athens:~# vi /etc/fstab root@athens:~# cat /etc/fstab /dev/sda1 / ext4 defaults,errors=remount-ro 1 1 /dev/sdb1 none swap sw 0 0 root@athens:~# reboot root@athens:~# free -m total used free shared buffers cached Mem: 995 72 923 0 9 20 -/+ buffers/cache: 42 953 Swap: 2046 0 2046

Then I shutdown, resized the disk and it worked! It still lists /dev/hda, but no matter.

root@athens:~# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 40G 1.4G 37G 4% / udev 494M 4.0K 494M 1% /dev tmpfs 200M 216K 199M 1% /run none 5.0M 0 5.0M 0% /run/lock none 498M 0 498M 0% /run/shm

The thing I know I did differently was correct the swap line in /etc/fstab (in addition to the / line).

The disk being shown as hda in Cloudmin but sda on the VM shouldn't be a problem, as Cloudmin just assumes they are equivalent - the reason hda is used is that it is how the disk appears for most VMs. However, this depends on the kernel version running within the VM.

So it sounds like the problem is fixed now? Most likely the cause was the LABEL= entry in /etc/fstab instead of a device path.

Yes, fixed, thanks. I left it open in case the incorrect swap line was an issue ('swap' -> 'none', 'defaults' -> 'sw'). Would be nice not to have to edit /etc/fstab when creating a VM.

The images we provide have the /etc/fstab file correct by default. However stacklet images do not, and unfortunately cloudmin needs to know which disks correspond to which filesystems to perform a safe resize..

Ah perhaps I can simply correct it, take a snapshot and build from that... Will give that a go, thanks for the help.

Yes, that's the best option.

Creating an image with a correct /etc/fstab works for the root disk, but not for swap. That line still must be edited by hand after building a new machine from this image.

Which specific line did you need to edit?

/dev/hdb1 swap swap defaults 0 0

I had to change /dev/hdb1 to /dev/sdb1

Once you change that and create an image from the VM, is Cloudmin changing it back tp /dev/hdb1 when you create a new VM?

When you create this VM, do you have VirtIO mode enabled for disk? There is an option for it on the creation form..

If yes, I would recommend choosing "No" instead.

No dice. I tried with it set to "No" -- same results. (Before I've always kept it at "Based on image",)

Is there any chance I could get a copy of the VM image you are trying to create systems from?