Accessing Ceph (rbd), sheepdog, etc using libguestfs

Thanks to infernix who contributed this tip on how to use libguestfs to access Ceph (and in theory, sheepdog, gluster, iscsi and more) devices.

If you apply this small patch to libguestfs you can use these distributed filesystems straight away by doing:

$ guestfish
><fs> set-attach-method appliance
><fs> add-drive /dev/null
><fs> config -set drive.hd0.file=rbd:pool/volume
><fs> run

… followed by usual guestfish commands.

This is a temporary hack, until we properly model Ceph (etc) through the libguestfs stable API. Nevertheless it works as follows:

  1. The add-drive /dev/null adds a drive, known to libguestfs.
  2. Implicitly this means that libguestfs adds a -drive option when it runs qemu.
  3. The custom qemu -set drive.hd0.file=... parameter modifies the preceding -drive option added by libguestfs so that the file is changed from /dev/null to whatever you want. In this case, to a Ceph rbd:... path.
About these ads

3 Comments

Filed under Uncategorized

3 responses to “Accessing Ceph (rbd), sheepdog, etc using libguestfs

  1. A very interesting and helpful article. I was able to retrieve file from rbd image using the above method.

    Would you please let know how to do this in a single command line. I am getting the following error

    guestfish add /dev/null : config -set drive.hd0.file=rbd:ssd-clonetest-rule5/fullclone.img : run : list-partitions
    guestfish: invalid option — ‘s’
    Try `guestfish –help’ for more information.

    anything I m doing wrong here.

    I am using CentOS 6.4 2.6.32-358.6.2.el6.x86_64
    qemu:

    qemu-kvm-0.12.1.2-2.415.el6.3ceph.x86_64
    qemu-kvm-tools-0.12.1.2-2.415.el6.3ceph.x86_64

    guestfs:

    libguestfs-tools-c-1.20.11-2.el6.x86_64
    libguestfs-tools-1.20.11-2.el6.x86_64
    libguestfs-1.20.11-2.el6.x86_64
    libguestfs-winsupport-1.0-7.el6.x86_64

    Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s