Hi all, I have XEN with LVM based disk and I want to convert it to images in order to use tapdisk. However since my disk is limited I want to shrink the .img file. I have 10Gb file in LVM but I only use 5GB of them. I can use dd to convert it to image file but the file will remain the same with the original 10Gb. I can use lvresize but I am afraid it will damage the LVM files. Any best practices? Regards, Agya _______________________________________________ Xen-users mailing list Xen-users@lists.xen.org http://lists.xen.org/xen-users
What is installed on lvm You could shrink partitions and drive size with lvm and then use dd to create image. _______________________________________________ Xen-users mailing list Xen-users@lists.xen.org http://lists.xen.org/xen-users
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? regards, Agya On Thu, Apr 4, 2013 at 10:40 PM, jacek burghardt <jaceksburghardt@gmail.com>wrote:> What is installed on lvm You could shrink partitions and drive size with > lvm and then use dd to create image. >_______________________________________________ Xen-users mailing list Xen-users@lists.xen.org http://lists.xen.org/xen-users
On 2013-04-04 23:56:49 agya naila 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?No. You have to shrink the filesystem that''s contained in the LV first. How to do that depends on the filesystem your domU is using on the LV. For recent linux filesystems (ext3/4, btrfs, reiserfs, xfs, ...) there are tools to do that. For Windows (NTFS) I think you have to do it in the domU itself. Another option would be to just make sure the free space is "filled by zeros" (eg. temporarily fill it with "large empty files") and then create a sparse image: dd if=... of=... bs=1M conv=sparse (use "ls -ls" to see the actually used size of the resulting file!) - peter.
On Fri, Apr 5, 2013 at 4:56 AM, agya naila <agya.naila@gmail.com> 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@lists.xen.org http://lists.xen.org/xen-users