> I created a Xen VM on top of a LVM volume. The volume was like 530GB
> big. Within the volume sits the VM, with 5 partitions, one of them
> 500GB big (the other 4 file systems comprise the other 30GB). Each
> virtual disk partition exists as /dev/xvda1 - /dev/xvda5. /dev/xvda5 is
> the one with the 500GB file system on it.
>
> I wanted to reduce the size of the filesystem on /dev/xvda5 from 500GB
> to 5GB. So I unmount /dev/xvda5 then run:
>
> # resize2fs /dev/xvda5 5G
>
> Works great. Next, I shut down the VM and reduce the size of my logical
> volume:
>
> # lvreduce -v -L 40G /dev/vg0/xen1
>
> So the volume is still larger than all the filesystems in it, such that
> I don''t lose any data. The command worked successfully. Then I
booted
> the VM and got errors on boot say something about "/dev/xvda: wanted
> 500000000 but was limited to 5000000" or something like that. But the
> VM booted even after the errors and appeared to work OK. So I:
>
> # fdisk -l
>
> Disk /dev/xvda: 32.2 GB, 32212254720 bytes
> 255 heads, 63 sectors/track, 3916 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 1288 10241437+ 83 Linux
> /dev/xvda3 1289 2308 8193150 82 Linux swap /
> Solaris
> /dev/xvda4 2309 67620 524618640 5 Extended
> /dev/xvda5 2309 67620 524618608+ 83 Linux
You resized the filesystem but you didn''t resize the partition the
filesystem
was on. You need to do both if this is going to work successfully. What has
happened is that the partition table was not updated and now it has values in
it that don''t make sense for your newly smaller disk.
> Notice it says that /dev/xvda is 32.2GB (which is correct), but
> /dev/xvda4-5 still think they are 500GB big! A ''df''
shows that the
> filesystem is really only 5GB though, as expected.
That makes sense too: the partition table says that the partition is that big,
so that''s what fdisk shows. ReiserFS, which you explicitly resized
*knows*
that it''s only managing 5GB of space, so it''s not confused by
this - hence df
works OK.
> I tried some parted
> magic but parted can''t do anything (even print the partition
table!), I
> get errors like:
>
> [root@template ~]# parted /dev/xvda
> GNU Parted 1.8.1
> Using /dev/xvda
> Welcome to GNU Parted! Type ''help'' to view a list of
commands.
> (parted) print
> Error: Can''t have a partition outside the disk!
> (parted)
>
> and it won''t let me make changes, etc. Is there something I
missed?
> Wasn''t the OS supposed to recognize the size change in /dev/xvda
on
> boot? Or do I have to manually change the disk label or something? Is
> it just impossible to resize a VM''s file system then change the
volume
> the VM sits on to reflect the change?
You need to resize /dev/xvda5... Assuming the ReiserFS has successfully
resized to fit within 5G of space then you should be able to shrink this
partition down to exactly 5G in size.
You could try and do this doing parted, but if it''s not playing nice
then you
can probably get away with using fdisk. I don''t think that fdisk has
a "resize" option but you can delete the partition (!) and then create
a new
one with the same starting sector, and an ending sector 5G later. This
should leave the filesystem intact, since it already fits into that 5G of
disk. I''d recommend you backup the contents just in case, though, and
fsck
it afterwards!
(side note: really you ought to have anything important backed up before
messing with partition tables - I''m paranoid)
In future, you could investigate using parted to resize the partition *and*
the filesystem on it simultaneously, which could avoid this problem
recurring.
Cheers,
Mark
--
Dave: Just a question. What use is a unicyle with no seat? And no pedals!
Mark: To answer a question with a question: What use is a skateboard?
Dave: Skateboards have wheels.
Mark: My wheel has a wheel!
_______________________________________________
Xen-users mailing list
Xen-users@lists.xensource.com
http://lists.xensource.com/xen-users