Bob Linkonij
2009-May-01 15:23 UTC
[Xen-users] How do I resize a Physical Partition in a Dom U that''s "on" a Logical Volume in the Dom 0?
Hey all, I''m trying to figure out how to re-size physical partitions in the Dom U. I''ve read up what I can find on line and finally decided to have Logical Volumes in the Dom 0 and pass them as physical volumes for use in the Dom U. Here''s an example of what I''m doing. To start in the Dom 0 I created the LV''s with lvcreate -n guest_boot -L 100M /dev/VG01 lvcreate -n guest_swap -L 512M /dev/VG01 lvcreate -n guest_root -L 4G /dev/VG01 Then in the Dom U configuration file I added disk=[''phy:/dev/VG01/guest_boot,xvda,w'',''phy:/dev/VG01/guest_swap,xvdb,w'',''phy:/dev/VG01/guest_root,xvdc,w''] Then I set up the Dom U so (hd0) /dev/xvda --------> mounts @ "/boot" (hd1) /dev/xvdb --------> mounts @ "swap" (hd2) /dev/xvdc --------> mounts @ "/" So with this the Dom U gets started OK. In the guest I see df -H Filesystem Size Used Avail Use% Mounted on /dev/xvdc1 4.3G 2.1G 2.0G 51% / udev 543M 78k 543M 1% /dev /dev/xvda1 82M 19M 57M 14% /boot What I want to do now is increase the size of the Dom U''s root (/dev/xvdc) partition. And I want to avoid losing, overwriting, or screwing up somehow my data in the process :-) I know the first step I have to do is increase the size of the right LV, that matches the /dev/xvdc1 "root" partition in the Dom U, in the Dom 0 first. I do that with lvextend -L +4G /dev/VG01 guest_root Can I do that "hot" without shutting down the Dom U first? Or do I need to shut it down THEN do the lvextend? The next step is what''s got me confused. The lvcreate I did first increased the size of "/dev/xvdc", but now I need to grow or extend the "/dev/xvdc1" partition in the Dom U to fill up to the maximum available. Do I do that in the Dom U or in the Dom 0? I think resize2fs needs to be used, since I don''t have a Logical Volume in the Dom U. I just don''t know. I''m sorry if I''m just missing what''s obvious but I''m kind of confused by the whole Logical/Physical differences in the Dom 0 and the Dom U. Any kind of help or advice would be really appreciated a lot! Thanks a bunch. Bob _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Simon Hobson
2009-May-01 16:33 UTC
Re: [Xen-users] How do I resize a Physical Partition in a Dom U that''s "on" a Logical Volume in the Dom 0?
Bob Linkonij wrote:>What I want to do now is increase the size of the Dom U''s root >(/dev/xvdc) partition. And I want to avoid losing, overwriting, or >screwing up somehow my data in the process :-) > >I know the first step I have to do is increase the size of the right >LV, that matches the /dev/xvdc1 "root" partition in the Dom U, in the >Dom 0 first. I do that with > >lvextend -L +4G /dev/VG01 guest_root > >Can I do that "hot" without shutting down the Dom U first? Or do I >need to shut it down THEN do the lvextend?You can do that ''hot''>The next step is what''s got me confused. > >The lvcreate I did first increased the size of "/dev/xvdc", but now I >need to grow or extend the "/dev/xvdc1" partition in the Dom U to fill >up to the maximum available. > >Do I do that in the Dom U or in the Dom 0? I think resize2fs needs to >be used, since I don''t have a Logical Volume in the Dom U. I just >don''t know.I''m not clear here - did you partition /dev/xvdc and create a filesystem on /dev/xvdc1, or did you create a filesystem on /dev/xvdc ? I do the latter. If you create a filesystem on the disk device rather than partitioning it, then you can shutdown the guest, use resize2fs to enlarge the filesystem in it, and startup the guest. If you created a partition, then you will need to deal with that. I think there was a discussion a while back on mounting partitions from a partition. You''ll need to enlarge the partition to fill the disk, and then you can resize the filesystem in it. Other than doing it from within the guest I don''t know how to do that. Once you shutdown and then start up (NOT reboot) the guest, it will see the new logical volume as a bigger disk - I don''t know if there is any way to make this happen ''live''.>I''m sorry if I''m just missing what''s obvious but I''m kind of confused >by the whole Logical/Physical differences in the Dom 0 and the Dom U.You''re not alone ! -- Simon Hobson Visit http://www.magpiesnestpublishing.co.uk/ for books by acclaimed author Gladys Hobson. Novels - poetry - short stories - ideal as Christmas stocking fillers. Some available as e-books. _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Bob Linkonij
2009-May-01 18:12 UTC
Re: [Xen-users] How do I resize a Physical Partition in a Dom U that''s "on" a Logical Volume in the Dom 0?
Hey Simon, On Fri, May 1, 2009 at 9:33 AM, Simon Hobson <linux@thehobsons.co.uk> wrote:>> lvextend -L +4G /dev/VG01 guest_root >> >> Can I do that "hot" without shutting down the Dom U first? Or do I >> need to shut it down THEN do the lvextend? > > You can do that ''hot''Great. That makes things easier & faster.> I''m not clear here - did you partition /dev/xvdc and create a filesystem on > /dev/xvdc1, or did you create a filesystem on /dev/xvdc ?I''m pretty foggy about the xvdc vs xvdc1 name differences but if I understand what you''re asking I did the first type. I''m not even sure how I''d do the latter, or if I should. Any thoughts on that? Anyway I used Suse SLED v10''s auto-installation stuff to do it. The part of the script for the xvdc device was <partitioning config:type="list"><drive> <device>/dev/xvdc</device> <initialize config:type="boolean">false</initialize> <partitions config:type="list"><partition> <create config:type="boolean">false</create> <filesystem config:type="symbol">ext3</filesystem> <format config:type="boolean">true</format> <label>GUESTROOT</label> <mount>/</mount> <partition_id config:type="integer">131</partition_id> <partition_nr config:type="integer">1</partition_nr> <partition_type>primary</partition_type> <size>max</size> </partition></partitions> <type config:type="symbol">CT_DISK</type> <use>all</use> </drive></partitioning>> If you create a filesystem on the disk device rather than partitioning it, > then you can shutdown the guest, use resize2fs to enlarge the filesystem in > it, and startup the guest. > > If you created a partition, then you will need to deal with that. I think > there was a discussion a while back on mounting partitions from a partition. > You''ll need to enlarge the partition to fill the disk, and then you can > resize the filesystem in it. Other than doing it from within the guest I > don''t know how to do that. Once you shutdown and then start up (NOT reboot) > the guest, it will see the new logical volume as a bigger disk - I don''t > know if there is any way to make this happen ''live''.So it sounds like the 1st one is simpler. And can be done live or hot. Maybe I should just redo the whole thing to use the "create a filesystem on /dev/xvdc" way. Any pointers on that one? I''ve tried to follow some of those discussions, and just get lost. It seems like each message answers a question someone''s not asking. Maybe I didn''t find the right list yet, but so far it''s all pretty confusing to me. I found the Xen wiki site. But I couldn''t find any stuff about which way is the right or best approach, or especially how to do it.> You''re not alone !I guess that''s a good thing :-) Thanks a bunch. Bob _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Simon Hobson
2009-May-01 21:43 UTC
Re: [Xen-users] How do I resize a Physical Partition in a Dom U that''s "on" a Logical Volume in the Dom 0?
Bob Linkonij wrote:> > I''m not clear here - did you partition /dev/xvdc and create a filesystem on >> /dev/xvdc1, or did you create a filesystem on /dev/xvdc ? > >I''m pretty foggy about the xvdc vs xvdc1 name differences but if I >understand what you''re asking I did the first type. I''m not even sure >how I''d do the latter, or if I should.What does it say in /etc/fstab ? If it has "/dev/xvdc" then the filesystem has been created in the whole disk, which I think is easiest. If it has "/dev/xvdc1" then the virtual disk has been partitioned and the filesystem created inside the partition. How you would do that is you would simply treat the virtual disk the same way as a real disk and just partition it - from inside the guest.>Anyway I used Suse SLED v10''s auto-installation stuff to do it. The >part of the script for the xvdc device was > ><partitioning config:type="list"><drive> ><device>/dev/xvdc</device> ><initialize config:type="boolean">false</initialize> ><partitions config:type="list"><partition> > <create config:type="boolean">false</create> > <filesystem config:type="symbol">ext3</filesystem> > <format config:type="boolean">true</format> > <label>GUESTROOT</label> > <mount>/</mount> > <partition_id config:type="integer">131</partition_id> > <partition_nr config:type="integer">1</partition_nr> > <partition_type>primary</partition_type> > <size>max</size> ></partition></partitions> ><type config:type="symbol">CT_DISK</type> ><use>all</use> ></drive></partitioning>Double dutch to me, but it does hint at having created a partition.> >> If you create a filesystem on the disk device rather than partitioning it, >> then you can shutdown the guest, use resize2fs to enlarge the filesystem in >> it, and startup the guest. >> >> If you created a partition, then you will need to deal with that. I think >> there was a discussion a while back on mounting partitions from a partition. >> You''ll need to enlarge the partition to fill the disk, and then you can >> resize the filesystem in it. Other than doing it from within the guest I >> don''t know how to do that. Once you shutdown and then start up (NOT reboot) >> the guest, it will see the new logical volume as a bigger disk - I don''t >> know if there is any way to make this happen ''live''. > >So it sounds like the 1st one is simpler. And can be done live or hot.Actually, it can''t be done live - you have to unmount the filesystem and fsck it before you can resize it. You''ll struggle to unmount your root filesystem. If you find that your root partition is /dev/xvdc1 then what I''d suggest is this : shutdown the guest boot up another guest with this LV attached as a disk. This can be an entirely different guest setup, or you could boot your current setup from one of the "live cd" distros such as Knoppix. You''ll now be able to use fdisk to alter the partition - so you''ll do "fdisk /dev/xvdx" (where x is the current drive letter the LV gets mapped to). I can''t remember the commands, but there is one to alter a partition, and you need to change the end of partition 1 (which should be the only one) to be the end of the disk. use resize2fs to expand the filesystem to fill the partition. shutdown the guest, return everything to normal, boot up your guest with the resized disk. It''s a lot easier to not use partitions in the guest. If you are happy doing that, you could consider re-installing without using partitions, but you may find it hard to persuade the installer to accept that. IIRC, in Debian (whose installer I was using only today) there isn''t an option - but there may be a command line method to bypass the disk partitions step. For Xen guests, I usually just clone a basic image that was created initially with debbootstrap - so I never use OS installers in a guest.>Maybe I should just redo the whole thing to use the "create a >filesystem on /dev/xvdc" way. > >Any pointers on that one? I''ve tried to follow some of those >discussions, and just get lost. It seems like each message answers a >question someone''s not asking.That''s often the way. -- Simon Hobson Visit http://www.magpiesnestpublishing.co.uk/ for books by acclaimed author Gladys Hobson. Novels - poetry - short stories - ideal as Christmas stocking fillers. Some available as e-books. _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Fajar A. Nugraha
2009-May-02 00:29 UTC
Re: [Xen-users] How do I resize a Physical Partition in a Dom U that''s "on" a Logical Volume in the Dom 0?
On Sat, May 2, 2009 at 4:43 AM, Simon Hobson <linux@thehobsons.co.uk> wrote:> Bob Linkonij wrote: >> I''m pretty foggy about the xvdc vs xvdc1 name differences but if I >> understand what you''re asking I did the first type. I''m not even sure >> how I''d do the latter, or if I should. > > What does it say in /etc/fstab ? > > If it has "/dev/xvdc" then the filesystem has been created in the whole > disk, which I think is easiest. > > If it has "/dev/xvdc1" then the virtual disk has been partitioned and the > filesystem created inside the partition.fstab alone can be misleading, as you can actually map the disk as xvda1 and not xvda. Other than fstab, you''ll also need domU''s config file (or do "xm list -l domU_name" from dom0) to find out what block devs are on domU. Usually if the installation process is done using automated tools (like virt-install) the block device will be xvda and it''s parititioned inside domU (possibly with LVM as well)>> So it sounds like the 1st one is simpler. And can be done live or hot. > > Actually, it can''t be done live - you have to unmount the filesystem and > fsck it before you can resize it. You''ll struggle to unmount your root > filesystem.fileystem resize can be done on line (at least it''s possible with ext3 on RHEL5). The problem is changing block device size (xvda) and changing partition layout currently requires shutting down then starting up domU. This is true regardless whether or not you use partitions on domU.> > If you find that your root partition is /dev/xvdc1 then what I''d suggest is > this : > shutdown the guest > boot up another guest with this LV attached as a disk. This can be an > entirely different guest setup, or you could boot your current setup from > one of the "live cd" distros such as Knoppix.... or you could also assign the disk to dom0, using "xm block-attach 0 ... "> It''s a lot easier to not use partitions in the guest.Correct.> but you may > find it hard to persuade the installer to accept that.I haven''t found any installer that could do that :) It''s usually a clone-based installation using domU image template. At this point I believe you need to provide these info : - domU''s fstab - output of "fdisk -l" on domU - disk section from domUs config file (usually on /etc/xen), or the vbd section output from "xm list -l domU_name" Regards, Fajar _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users