Hi all I know for many this is probably an easy answer, but I just can''t figure it out. How do I increase the size of a xen domU that''s installed on a LVM partition?>From what I can gather from Google searches, is that I need to use lvextend,but that doesn''t seem enough. So, what do I need todo to extend a 5GB LVM to say 8GB? I have the following setup: [root@saturn plugins]# lvscan ACTIVE ''/dev/System/root'' [10.00 GB] inherit ACTIVE ''/dev/System/swap'' [4.00 GB] inherit ACTIVE ''/dev/System/pluto'' [50.00 GB] inherit ACTIVE ''/dev/System/home'' [10.00 GB] inherit ACTIVE ''/dev/System/data'' [20.00 GB] inherit ACTIVE ''/dev/System/andrew_vmswap'' [1.00 GB] inherit ACTIVE ''/dev/System/andrew_rootimg'' [5.00 GB] inherit ACTIVE ''/dev/System/keith_vmswap'' [1.00 GB] inherit ACTIVE ''/dev/System/keith_rootimg'' [5.00 GB] inherit ACTIVE ''/dev/System/12_vmswap'' [1.00 GB] inherit ACTIVE ''/dev/System/12_rootimg'' [5.00 GB] inherit ACTIVE Original ''/dev/System/wiseguy_rootimg'' [10.00 GB] inherit ACTIVE ''/dev/System/wiseguy'' [5.00 GB] inherit ACTIVE Snapshot ''/dev/System/oldcpanel'' [32.00 MB] inherit And I would like to increase the size of /dev/System/wiseguy Inside the domU, I get the following: root@server [/scripts]# fdisk -l Disk /dev/xvda: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/xvda1 * 1 13 104391 83 Linux /dev/xvda2 14 652 5132767+ 83 Linux Can someone please tell me what commands I need to run to resize the LVM? -- Kind Regards Rudi Ahlers _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Fajar A. Nugraha
2008-Sep-18 06:53 UTC
Re: [Xen-users] how do I increase a LVM based xen domU?
Rudi Ahlers wrote:> > So, what do I need todo to extend a 5GB LVM to say 8GB? > > ACTIVE ''/dev/System/wiseguy'' [5.00 GB] inherit > > And I would like to increase the size of /dev/System/wiseguy > > Inside the domU, I get the following: > > root@server [/scripts]# fdisk -l > > Disk /dev/xvda: 5368 MB, 5368709120 bytes > 255 heads, 63 sectors/track, 652 cylinders > Units = cylinders of 16065 * 512 = 8225280 bytes > > Device Boot Start End Blocks Id System > /dev/xvda1 * 1 13 104391 83 Linux > /dev/xvda2 14 652 5132767+ 83 Linux > >I''d have to say OUCH. You''re using something that''s hard to manage. Best practices would be : 1) LVM on dom0 -> maps to xvda on domU -> LVM on domU, using xvda as PV (which is what Redhat does by default if you install RHEL5 PV) 2) LVM on dom0 -> maps to (xv/s/h)da1 on domU, and mounted directly without additional partitioning or LVM on domU. If you use (1), you''ll need to add NEW LV on dom0 as new disk on domU, extend the VG on domU using that disk, extend LV on domU, and resize the fs. If you use (2), you simply extend LV on dom0, restart domU, and resize the fs on domU. On your setup, if you extend the LV on dom0 and reboot domU, you''d probably get a bigger disk, but you still need to modify the partition table. Good luck with that. It might be easier to move to (1) or (2) and move the data. Regards, Fajar _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Pasi Kärkkäinen
2008-Sep-18 07:07 UTC
Re: [Xen-users] how do I increase a LVM based xen domU?
On Thu, Sep 18, 2008 at 08:31:28AM +0200, Rudi Ahlers wrote:> Hi all > I know for many this is probably an easy answer, but I just can''t figure it > out. > > How do I increase the size of a xen domU that''s installed on a LVM > partition? > > >From what I can gather from Google searches, is that I need to use lvextend, > but that doesn''t seem enough. > > So, what do I need todo to extend a 5GB LVM to say 8GB? > > I have the following setup: > > [root@saturn plugins]# lvscan > ACTIVE ''/dev/System/root'' [10.00 GB] inherit > ACTIVE ''/dev/System/swap'' [4.00 GB] inherit > ACTIVE ''/dev/System/pluto'' [50.00 GB] inherit > ACTIVE ''/dev/System/home'' [10.00 GB] inherit > ACTIVE ''/dev/System/data'' [20.00 GB] inherit > ACTIVE ''/dev/System/andrew_vmswap'' [1.00 GB] inherit > ACTIVE ''/dev/System/andrew_rootimg'' [5.00 GB] inherit > ACTIVE ''/dev/System/keith_vmswap'' [1.00 GB] inherit > ACTIVE ''/dev/System/keith_rootimg'' [5.00 GB] inherit > ACTIVE ''/dev/System/12_vmswap'' [1.00 GB] inherit > ACTIVE ''/dev/System/12_rootimg'' [5.00 GB] inherit > ACTIVE Original ''/dev/System/wiseguy_rootimg'' [10.00 GB] inherit > ACTIVE ''/dev/System/wiseguy'' [5.00 GB] inherit > ACTIVE Snapshot ''/dev/System/oldcpanel'' [32.00 MB] inherit > > > > And I would like to increase the size of /dev/System/wiseguy > > > > Inside the domU, I get the following: > > > root@server [/scripts]# fdisk -l > > Disk /dev/xvda: 5368 MB, 5368709120 bytes > 255 heads, 63 sectors/track, 652 cylinders > Units = cylinders of 16065 * 512 = 8225280 bytes > > Device Boot Start End Blocks Id System > /dev/xvda1 * 1 13 104391 83 Linux > /dev/xvda2 14 652 5132767+ 83 Linux > > > > > Can someone please tell me what commands I need to run to resize the LVM? >I assume you have those LVM volumes in dom0. - lvextend the volume in dom0. - run "cat /proc/partitions" in domU. Check the size of xvda. - shutdown domU and start it up again (to pick up the new size for xvda from the extended lvm volume) - run "cat /proc/partitions" in domU. Verify xvda is bigger now. - create new partition to xvda, or resize existing partition (you can only grow the last partition easily) - mkfs.ext3 the new partition or resize2fs the existing partition you just grew by editing the xvda partition table. Xen doesn''t support online resizing domU xvdX/vbd devices at the moment. So you need to restart domU to see the new/bigger size for xvdX devices. You could also run LVM in domU aswell.. to be able to resize any partition/volume in domU more easily. In this case the procedure would be: - lvextend the volume in dom0. - run "cat /proc/partitions" in domU. Check the size of xvda. - shutdown domU and start it up again (to pick up the new size for xvda from the extended lvm volume) - run "cat /proc/partitions" in domU. Verify xvda is bigger now. - resize/grow the LVM PV partition by editing partition table. Remember you can only grow last partition easily. - reboot domU to make sure new partition sizes are picked up. - run vgdisplay to check available/free space on your VG. - run pvresize to resize the LVM PV. - run vgdisplay to verify you have more free space in your VG now. - lvextend any domU volume you want to. - run resize2fs for the volume. Another option is to have LVM PV directly on say xvdb, without any partition table.. Then you can skip the partition table editing steps.. just a simple reboot will pick up the new size and you can pvextend immediately after. -- Pasi _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Fajar A. Nugraha
2008-Sep-18 08:20 UTC
Re: [Xen-users] how do I increase a LVM based xen domU?
Rudi Ahlers wrote:> > On Thu, Sep 18, 2008 at 8:53 AM, Fajar A. Nugraha <fajar@fajar.net > <mailto:fajar@fajar.net>> wrote: > > > Best practices would be : > 1) LVM on dom0 -> maps to xvda on domU -> LVM on domU, using xvda > as PV > (which is what Redhat does by default if you install RHEL5 PV) > 2) LVM on dom0 -> maps to (xv/s/h)da1 on domU, and mounted directly > without additional partitioning or LVM on domU. > > It might be easier to move to (1) or (2) > and move the data. >> Ok, so when I create a domU VPS, and I start the installation (in this > case it''s CentOS 5.2), how should I partition it? >If you install it using anaconda (which is what you get if you use virt-manager) the default partitioning scheme is to use LVM on domU. This is (1), which AFAIK is what RH recommends. It will enable easy disk addition (you dan do xm block-attach online without having to restart domU). Personally, I don''t like this approach because it''s harder (although possible) to mount domU''s fs in dom0 (you have two LVM layers to deal with). Layout(2) is somewhat more complicated because it requires either : - you modify an existing install, or - you have a template OS tarball, or - you''re using a distro that can install to a directory from command line (i.e. something like debootstrap for debian/ubuntu) Note that once you have a template tarball, installing (2) is VERY easy.> And is there any way to copy the existing data on this domU to a newly > created one? > >Copying the data is the same as you''d do on a normal linux install : rsync, tar, dd, etc. I just realized that your xvda doesn''t contain a swap partition. Is this intentional? Assuming you want to copy this existing install and modify it to (2), these steps might work. The following assumes : - you''re using PV domU, not HVM - your current domU is called "server" - your dom0 VG is called "System" - you only have a filesystem ("/") on domU On dom0: - create a new LV (10GB or whatever) on dom0 lvcreate -L 10G -n wiseguy2 System - attach the block device as xvdb1 (or whatever partition currently unused on domU) xm block-attach server phy:/dev/System/wiseguy2 xvdb1 w On domU (make sure you doublecheck everything you type): - do "fdisk -l". You should see a new disk /dev/xvdb1 - mkfs.ext3 /dev/xvdb1 - mkdir /mnt/tmp1; mount /dev/xvdb1 /mnt/tmp1 - mkdir /mnt/tmp2; mount --bind / /mnt/tmp2 - cd /mnt/tmp1 - ( cd /mnt/tmp2 && tar cvf - . ) | tar xvf - - cd /mnt/tmp1/boot - ( cd /boot && tar cvf - . ) | tar xvf - - edit /mnt/tmp1/etc/fstab, remove the line for /boot, edit the line for "/" to use "/dev/xvda1" instead of the original "/dev/xvda2" - edit /mnt/tmp1/boot/grub/menu.lst, adjust the boot entry to look something like this default=0 timeout=5 title New-Centos root (hd0,0) kernel /boot/vmlinuz-2.6.18-92.1.10.el5xen ro root=/dev/xvda1 initrd /boot/initrd-2.6.18-92.1.10.el5xen.img At this point you have xvdb1 which contains the original xvda1 (/boot) and xvda2 (/) merged. Next : - shutdown domU (it''s much easier this way) - create a new xen config file with disk line which looks something like this disk = [ ''phy:/dev/System/wiseguy2,xvda1,w'' ] bootloader="/usr/bin/pygrub" Note that it says "xvda1", and not xvda. The xvdb1 that you created earlier will be mounted as xvda1 on the new domU. - start the new domU. It should work. If it boots succesfully, you might want to consider creating a tarball of the fs inside /dev/System/wiseguy2 for future installs. Regards, Fajar _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
On Thu, Sep 18, 2008 at 10:20 AM, Fajar A. Nugraha <fajar@fajar.net> wrote:> Rudi Ahlers wrote: > > > > On Thu, Sep 18, 2008 at 8:53 AM, Fajar A. Nugraha <fajar@fajar.net > > <mailto:fajar@fajar.net>> wrote: > > > > > > Best practices would be : > > 1) LVM on dom0 -> maps to xvda on domU -> LVM on domU, using xvda > > as PV > > (which is what Redhat does by default if you install RHEL5 PV) > > 2) LVM on dom0 -> maps to (xv/s/h)da1 on domU, and mounted directly > > without additional partitioning or LVM on domU. > > > > It might be easier to move to (1) or (2) > > and move the data. > > > > > Ok, so when I create a domU VPS, and I start the installation (in this > > case it''s CentOS 5.2), how should I partition it? > > > > If you install it using anaconda (which is what you get if you use > virt-manager) the default partitioning scheme is to use LVM on domU. > This is (1), which AFAIK is what RH recommends. It will enable easy disk > addition (you dan do xm block-attach online without having to restart > domU). > > Personally, I don''t like this approach because it''s harder (although > possible) to mount domU''s fs in dom0 (you have two LVM layers to deal > with). >With Virt-install I can at least choose all the packages I need to install, and the installation files are on the server already, so I don''t need to waste bandwidth every time I install it. Would it be better to install the VPS with an ext3 partition instead of LVM? In which case it will have 3 partitions (/boot, / & swap) but that shouldn''t be a problem, right? Can an ext3 partition (for the domU) on a LVM (dom0) be resized easily?> > Layout(2) is somewhat more complicated because it requires either : > - you modify an existing install, or > - you have a template OS tarball, or > - you''re using a distro that can install to a directory from command > line (i.e. something like debootstrap for debian/ubuntu) >Installing CentOS / Fedora Core onto CentOS is easiest with virt-install, for me :) I''ve tried the debootstrap option before, but have had no luck getting it to work.> > Note that once you have a template tarball, installing (2) is VERY easy. > > > And is there any way to copy the existing data on this domU to a newly > > created one? > > > > > Copying the data is the same as you''d do on a normal linux install : > rsync, tar, dd, etc. > > I just realized that your xvda doesn''t contain a swap partition. Is this > intentional?Yes, I wanted to add a separate swap partition, but haven''t figured that out yet.> > Assuming you want to copy this existing install and modify it to (2), > these steps might work.> > The following assumes : > - you''re using PV domU, not HVM > - your current domU is called "server" > - your dom0 VG is called "System" > - you only have a filesystem ("/") on domU > > On dom0: > - create a new LV (10GB or whatever) on dom0 > lvcreate -L 10G -n wiseguy2 System > - attach the block device as xvdb1 (or whatever partition currently > unused on domU) > xm block-attach server phy:/dev/System/wiseguy2 xvdb1 w >Do I need to create a configuration file for the wiseguy2 domU manually? And then, for the following steps, for I need to mount /dev/System/wiseguy2 on say /mnt/wiseguy2 - on dom0, or do I need to boot wiseguy2 domU ?> > On domU (make sure you doublecheck everything you type): > - do "fdisk -l". You should see a new disk /dev/xvdb1 > - mkfs.ext3 /dev/xvdb1 > - mkdir /mnt/tmp1; mount /dev/xvdb1 /mnt/tmp1 > - mkdir /mnt/tmp2; mount --bind / /mnt/tmp2 > - cd /mnt/tmp1 > - ( cd /mnt/tmp2 && tar cvf - . ) | tar xvf - > - cd /mnt/tmp1/boot > - ( cd /boot && tar cvf - . ) | tar xvf - > - edit /mnt/tmp1/etc/fstab, remove the line for /boot, edit the line for > "/" to use "/dev/xvda1" instead of the original "/dev/xvda2" > - edit /mnt/tmp1/boot/grub/menu.lst, adjust the boot entry to look > something like this > > default=0 > timeout=5 > title New-Centos > root (hd0,0) > kernel /boot/vmlinuz-2.6.18-92.1.10.el5xen ro root=/dev/xvda1 > initrd /boot/initrd-2.6.18-92.1.10.el5xen.img > > At this point you have xvdb1 which contains the original xvda1 (/boot) > and xvda2 (/) merged. Next : > - shutdown domU (it''s much easier this way) > - create a new xen config file with disk line which looks something like > this > > disk = [ ''phy:/dev/System/wiseguy2,xvda1,w'' ] > bootloader="/usr/bin/pygrub" > > Note that it says "xvda1", and not xvda. The xvdb1 that you created > earlier will be mounted as xvda1 on the new domU. > > - start the new domU. It should work. If it boots succesfully, you might > want to consider creating a tarball of the fs inside > /dev/System/wiseguy2 for future installs. > > Regards, > > Fajar >-- Kind Regards Rudi Ahlers _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Fajar A. Nugraha
2008-Sep-19 01:55 UTC
Re: [Xen-users] how do I increase a LVM based xen domU?
Rudi Ahlers wrote:> > > > If you install it using anaconda (which is what you get if you use > virt-manager) the default partitioning scheme is to use LVM on domU. > This is (1), which AFAIK is what RH recommends. It will enable > easy disk > addition (you dan do xm block-attach online without having to restart > domU). > > > With Virt-install I can at least choose all the packages I need to > install,Correct.> and the installation files are on the server already, so I don''t need > to waste bandwidth every time I install it. >In my case I have a local yum mirror containing all packages I need. So after the template-based installation I can simply do "yum install <any additional package>" without wasting internet BW. If you still want to use virt-install but don''t want to use the default LVM setup on domU, you might be able to use Pasi''s suggestion to resize the disk. If you choose that, it will be a LOT easier if you simply put only one partition on each disk. Meaning you need 2 disks on domU, one for "/" and one for swap.> > Would it be better to install the VPS with an ext3 partition instead > of LVM? In which case it will have 3 partitions (/boot, / & swap) but > that shouldn''t be a problem, right?You only need two. "/boot" doesn''t need to be on separate fs. Here''s an example : memory = "2000" disk = [ ''phy:/dev/VG/domUrootLV,hda1,w'', ''phy:/data/VG/domUswapLV,hda2,w'', ] bootloader="/usr/bin/pygrub" I use hda1/2, but sda1/2 or xvda1/2 should work as well. AFAIK virt-install isn''t able to use LVM dom0 directly as partition on domU though.> Can an ext3 partition (for the domU) on a LVM (dom0) be resized easily?Yes. See this comparison : - LVM dom0 -> disk on domU -> lvm domU -> ext3 on LV : add new disk to domU (online addition possible), extend domU''s VG, extend domU''s LV, resize fs. - LVM dom0 -> disk on domU -> ext3 on partition : resize dom0''s LV, reboot domU, change domU''s partition, run partprobe (or reboot domU again), resize fs. - LVM dom0 -> parition on domU -> ext3 on partition : resize dom0''s LV, reboot domU, resize fs on domU. It can also be mounted on dom0 easly.> > > > On dom0: > - create a new LV (10GB or whatever) on dom0 > lvcreate -L 10G -n wiseguy2 System > - attach the block device as xvdb1 (or whatever partition currently > unused on domU) > xm block-attach server phy:/dev/System/wiseguy2 xvdb1 w > > > > Do I need to create a configuration file for the wiseguy2 domU manually?This step doesn''t require a new config file yet. But yes, ultimately you need to create wiseguy2''s config manually. You can use wiseguy''s config as a starting point. Change wiseguy -> wiseguy2 and xvda -> xvda1.> > > And then, for the following steps, for I need to mount > /dev/System/wiseguy2 on say /mnt/wiseguy2 - on dom0, or do I need to > boot wiseguy2 domU ?No. The steps that I wrote is on a runnning wiseguy domU. Note the "xm block-attach" command previously? It''s used to attach new disk to a running domU. You can do it on dom0, but it''d be harder because it involves kpartx. See http://lists.xensource.com/archives/html/xen-users/2007-07/msg00777.html for example. Regards, Fajar _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
On Thu, Sep 18, 2008 at 9:07 AM, Pasi Kärkkäinen <pasik@iki.fi> wrote:> > > > > Can someone please tell me what commands I need to run to resize the LVM? > > > > I assume you have those LVM volumes in dom0. > > - lvextend the volume in dom0. > - run "cat /proc/partitions" in domU. Check the size of xvda. > - shutdown domU and start it up again (to pick up the new size for xvda > from the extended lvm volume) > - run "cat /proc/partitions" in domU. Verify xvda is bigger now. > - create new partition to xvda, or resize existing partition (you can only > grow the last partition easily)I''ve come this far, and can add a new partition to the domU, but ideally I''d like to have one partition, since we''re installing cPanel (and splitting the data across partitions confuses some people & scripts. )> > - mkfs.ext3 the new partition or resize2fs the existing partition you just > grew by editing the xvda partition table. >If I understand this correctly, this will format the partition, and I will loose all data on it, right?> > Xen doesn''t support online resizing domU xvdX/vbd devices at the moment. > So you need to restart domU to see the new/bigger size for xvdX devices. >That''s fine, I don''t need online resizing, I can shutdown the VPS in order to increase the size of it.> > You could also run LVM in domU aswell.. to be able to resize any > partition/volume in domU more easily. > In this case the procedure would be: > > - lvextend the volume in dom0. > - run "cat /proc/partitions" in domU. Check the size of xvda. > - shutdown domU and start it up again (to pick up the new size for xvda > from the extended lvm volume) > - run "cat /proc/partitions" in domU. Verify xvda is bigger now. > - resize/grow the LVM PV partition by editing partition table. Remember you > can only grow last partition easily. > - reboot domU to make sure new partition sizes are picked up. > - run vgdisplay to check available/free space on your VG. > - run pvresize to resize the LVM PV. > - run vgdisplay to verify you have more free space in your VG now. > - lvextend any domU volume you want to. > - run resize2fs for the volume. > > Another option is to have LVM PV directly on say xvdb, without any > partition table.. > Then you can skip the partition table editing steps.. just a simple reboot > will pick up the new size and you can pvextend immediately after.How would I setup / install CentOS (for example) as a VPS in this manner?> > > -- Pasi >-- Kind Regards Rudi Ahlers _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Pasi Kärkkäinen
2008-Sep-19 08:29 UTC
Re: [Xen-users] how do I increase a LVM based xen domU?
On Fri, Sep 19, 2008 at 09:09:33AM +0200, Rudi Ahlers wrote:> On Thu, Sep 18, 2008 at 9:07 AM, Pasi Kärkkäinen <pasik@iki.fi> wrote: > > > > > > > > > Can someone please tell me what commands I need to run to resize the LVM? > > > > > > > I assume you have those LVM volumes in dom0. > > > > - lvextend the volume in dom0. > > - run "cat /proc/partitions" in domU. Check the size of xvda. > > - shutdown domU and start it up again (to pick up the new size for xvda > > from the extended lvm volume) > > - run "cat /proc/partitions" in domU. Verify xvda is bigger now. > > - create new partition to xvda, or resize existing partition (you can only > > grow the last partition easily) > > > I''ve come this far, and can add a new partition to the domU, but ideally I''d > like to have one partition, since we''re installing cPanel (and splitting the > data across partitions confuses some people & scripts. ) > > > > > > > - mkfs.ext3 the new partition or resize2fs the existing partition you just > > grew by editing the xvda partition table. > > > > If I understand this correctly, this will format the partition, and I will > loose all data on it, right? >mkfs.ext3 will format, yes, and you loose all the data. resize2fs will resize (grow) existing partition, not loosing any data. Backups are good to have anyway. -- Pasi _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users