Xen Virtual Server - Resize Disk / Partition?
-
This is more of a Linux question rather than a Xen/Hypervisor question. You can do it by booting to a liveCD and running gparted. Don’t try to modify your drive from your running OS.
-
With the way your partitions are situated, if you want to simply expand xvda1 to take up the new space you allocated, you will have to do so through a live cd or something similar; the extra space is not currently contiguous with xvda1, so something is going to have to move. You could also create a new volume to mount, but that will require modifying the partition table on a running system … not my favorite thing to do. Safest is still to do it with a live cd.
Alternatively, adding the additional storage as a new virtual disk and then mounting that virtual disk under /images would give you the storage separate from your system volume (always a plus in case you don’t realize you don’t have enough room for a capture) and would give you greater operational flexibility, for instance when you need to add storage later or need to migrate to a new VM.
-
@Daniel-Miller said in Xen Virtual Server - Resize Disk / Partition?:
Alternatively, adding the additional storage as a new virtual disk and then mounting that virtual disk under /images would give you the storage separate from your system volume (always a plus in case you don’t realize you don’t have enough room for a capture) and would give you greater operational flexibility, for instance when you need to add storage later or need to migrate to a new VM.
Thumbs up for this! I’d definitely go that route.
Instead of expanding xvda you simply add xvdb to your Xen VM as if you’d add a second hard drive to it. Put one single partition on that disk (e.g. using parted or fdisk on the console) and format, then run the following commands:
mkdir /tempimages/ mount /dev/xvdb /tempimages/ mv /images/* /tempimages/ mv /images/.mntcheck /tempimages/ umount /tempimages/ mount /dev/xvdb /images/ rmdir /tempimages/
Don’t forget to add this second disk to you
/etc/fstab
so it will be mounted on system boot as well! -
@Sebastian-Roth Thank you for the information. My issue is, I already expanded /dev/xvda to 250GB. If I create a new vdisk can I move the 250GB to it? I cannot reduce the size of /dev/xvda.
-
@SBrady Does Xen not let you shrink virtual disks?
Well, if you can’t shrink the disk, you could ways create a new 25GB (or whatever your original disk size was) virtual disk, use some kind of disk cloning solution to copy the original disk data to the new volume, then shuffle things around so the new volume is in the same device position as it was originally, then re-partition and format the 250GB disk. -
@Daniel-Miller Thank you for the information. Is it possible to do this using command line if I have the gparted CD loaded?
-
@SBrady said in Xen Virtual Server - Resize Disk / Partition?:
My issue is, I already expanded /dev/xvda to 250GB. If I create a new vdisk can I move the 250GB to it? I cannot reduce the size of /dev/xvda.
Didn’t you take a snapshot of the VM before expanding xvda???
-
@SBrady If you are using the gparted live cd, you should have access to
dd
. Provided your new small disk is the same size as, or larger than, the original disk and both the new and old disks are attached to said VM, you could do something along the lines ofsudo dd if=/dev/xvda of=/dev/xvdb bs=1M
where xvda is the old disk and xvdb is the new disk. it will error when it reaches the end of the smaller disk with a message indicating there is no more space left on the device. I’m sure there are more graceful means of doing it, but it will get the job done.Note: if you get the disk identifiers backwards, you will wipe the content of the original disk. It is best to confirm the disk identifiers are mapped to the disks you think they are before running
dd
. -
@Sebastian-Roth Sadly I did not use a snapshot before making any changes I was under the impression I could shrink the vdisk if needed but when I tried it told me not possible. This is a fresh install I did awhile ago and only just installed and configured fog. I could do a new one if needed but honestly I would rather not. I was able to get gparted running on it but it’s all command line so more confusing to do. I also like the idea of cloning to a new drive and deleting the original if possible.
-
@Sebastian-Roth @Daniel-Miller
I’m problably going to just build a new server. Which is better for Xen VM, guided or guided with LVM?
-
@SBrady said:
Which is better for Xen VM, guided or guided with LVM?
LVM is great if you know Linux well and can handle that complexity. If you don’t it might make things more prone to errors and I’d suggest installing without LVM.