[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-users] Convert LVM to Images



On Fri, Apr 5, 2013 at 4:56 AM, agya naila <agya.naila@xxxxxxxxx> wrote:
Hi Jacek,

LVM used for my DomU installation, that why I am looking for best practices to ensure the file didn't damage, is it safe using lvresize or lvreduce?


I assume the LVM is in dom0, and domU use it directly as whole disk (i.e. no more partition or LVM in domU side)?

If yes, then short version: it's safe when done properly. But I'd say don't bother, too much effort involved.

Long version:
The "normal" way to shrink your disk is something like this:
- reduce the size of your fs (e.g. resize2fs for ext2/3/4)
- reduce the size of your LVM with lvresize/lvreduce
- copy the data with dd or whatever (this might involve attaching the disk image first to dom0 using "xl block-attach" or similar)
- resize the fs to occupy all space in new disk image
- adjust all necessary settings (e.g. fstab, copy /boot, etc)

If you accidently messed up during lvresize (e.g. make it SMALLER than the actual fs size, or run lvreduce BEFORE resize2fs), then you WILL lose data, so take caution in this.

Another alternative is to use fs-specific clone tool (e.g. clone2fs, ntfsclone). It should only copy blocks in use, so you don't need to worry about resizing the source fs/LV beforehand.

An even easier way is if you use a filesystem that uses compression (e.g. zfs, btrfs) in dom0 for the disk image storage, AND the image you're moving is fairly new (i.e. the unused space contains zeroes). In this case a simple "dd" is enough, as the dom0 fs will compress the disk image, thus you end up with smaller space used anyway.

-- 
Fajar 
_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxx
http://lists.xen.org/xen-users

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.