Hi- Is it safe to use the zerofree utility on an ext4 partition inside an LVM with guestfish? I know zerofree works on ext4, but I am unsure about LVM. The info page uses the syntax "zerofree <device>", so using the info page example, could I (safely) do something like the following? $ guestfish Welcome to guestfish, the libguestfs filesystem interactive shell for editing virtual machine filesystems. Type: 'help' for a list of commands 'man' to read the manual 'quit' to quit the shell ><fs> add disk.img><fs> run><fs> list-filesystems/dev/sda1: ext4 /dev/vg_guest/lv_root: ext4 /dev/vg_guest/lv_swap: swap><fs> zerofree /dev/vg_guest/lv_rootThanks for any light you can shed on this. -Ben -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://listman.redhat.com/archives/libguestfs/attachments/20110901/4bcd653b/attachment.htm>
On Thu, Sep 01, 2011 at 02:55:06PM -0400, Ben Clay wrote:> Is it safe to use the zerofree utility on an ext4 partition inside > an LVM with guestfish? I know zerofree works on ext4, but I am > unsure about LVM. The info page uses the syntax "zerofree > <device>", so using the info page example, could I (safely) do > something like the following?Using it on logical volumes makes no difference, it'll just work the same way as on partitions or whole devices. HOWEVER, I would be cautious about using zerofree at all. It's been checked reasonably carefully against ext2/ext3, but I don't think anyone has looked at whether it does reasonable things on ext4 (particularly w.r.t. filesystems with extents). So it might work, or it might silently corrupt files ... It might be advisable to keep a backup and check your filesystem before and after with 'virt-ls --checksum'. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
On Sun, Sep 04, 2011 at 06:30:58PM -0400, Ben Clay wrote:> I'm trying to run zerofree on the root LVM (/dev/VolGroup/lv_root), but I'm > getting the following error: > > ><fs> zerofree /dev/VolGroup/lv_root > libguestfs: error: zerofree: /dev/VolGroup/lv_root: zerofree: No such file > or directoryIt looks like the zerofree command is missing. What does this say: ><fs> available "zerofree" Do you have /usr/sbin/zerofree installed on the host? What do these commands say: ><fs> debug ll /usr/sbin ><fs> debug ll /dev ><fs> debug ll /dev/VolGroup Which version of libguestfs is this, and where did you obtain it? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
On Tue, Sep 06, 2011 at 01:16:42PM -0400, Ben Clay wrote:> Rich- > > Sorry for the delay, my box went down over the weekend. > > I have zerofree installed to /usr/sbin, but it's from the EPEL 5 repo when > I'm using CentOS 6 x86_64. I was unable to find a zerofree rpm for > CentOS/RHEL 6 x86_64. I manually installed the zerofree 1.0.1 rpm since yum > wouldn't pick it up, and /usr/sbin/zerofree appears to run. > > However, in guestfish, it's missing: > > ><fs> available "zerofree" > libguestfs: error: available: zerofree: group not availableHere is the code: http://git.annexia.org/?p=libguestfs.git;a=blob;f=daemon/zerofree.c;h=f98c69b1785c255fcaa524b5caab136aa3292b17;hb=HEAD#l31 As you can see, it is checking for a zerofree binary somewhere along the $PATH inside the appliance. In the appliance, PATH=/usr/sbin:/usr/bin:/sbin:/bin> ><fs> debug ll /usr/sbin[...]> -rwxr-xr-x 1 root root 52992 Nov 12 2010 vipw > -rwxr-xr-x 1 root root 17392 Jun 25 12:40 zdump > -rwxr-xr-x 1 root root 50256 Jun 25 12:40 zicYup, not there.> Here is my guestfish version: > > ]# guestfish version > major: 1 > minor: 2 > release: 7 > extra: > > Does this version not have zerofree support? I checked the release notes > and do not see it mentioned.By the way, this is a really really old version of libguestfs ... There should be a host file called something similar to /usr/lib*/guestfs/initramfs.epel-5.i686.supermin.hostfiles (it might have a slightly different name). This file should contain a line: ./usr/sbin/zerofree For example: $ grep zerofree /usr/lib/guestfs/initramfs.epel-5.i686.supermin.hostfiles ./usr/sbin/zerofree If that line is there, then /usr/sbin/zerofree on the host filesystem should be copied into the appliance. If it is not there, you could try adding that line. NB the initial dot. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org