New guestfish -N options in 1.5.9

The guestfish -N option has been around for a while. It’s a convenient way to create new, empty disk images on the fly. In version 1.5.9 I added an assortment of new image types. This post summarizes the existing image types and the new ones.

The disk image is always called test1.img.

“guestfish -N disk” creates a completely empty block device of the given size (100MB if the size is omitted). This option is not particularly useful because it is equivalent to the guestfish sparse command. Note no partitions or filesystems get created.

“guestfish -N part” partitions the disk with a single partition. No filesystem is created.

“guestfish -N fs” is where this starts to get useful. This creates a single partition and formats it with the chosen filesystem (by default, ext2).

If you want to put something on the filesystem as well, you have to mount it, so the full guestfish command becomes something like this, note the -m option:

$ guestfish -N fs:ext2:10G -m /dev/sda1 <<EOF
mkdir /directory
write "hello world" /hello-world
EOF

Now we get to the new options that need libguestfs ≥ 1.5.9.

“guestfish -N lv” creates a disk image containing a nest of: 1 partition, containing 1 physical volume (PV), containing 1 volume group (VG), containing 1 logical volume (LV). No filesystems are created by this command. You can control the name of the VG and LV, which in the example above are just “VG” and “LV” respectively, but could be any names you want.

“guestfish -N lvfs” is an extension of “lv” which formats the logical volume with the filesystem of your choice.

“guestfish -N bootroot” creates something that looks a little bit like a real virtual machine layout. You get a /boot partition at the beginning of the disk, 64MB in the example, and a / (root) partition second which consumes the remaining disk space.

If you actually want to mount this up, the full guestfish session would look like this:

$ guestfish -N bootroot:ext2:ext4:10G:64M

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> mount /dev/vda2 /
><fs> mkdir /boot
><fs> mount /dev/vda1 /boot
><fs> df-h
Filesystem            Size  Used Avail Use% Mounted on
/dev/vda2             9.8G  151M  9.2G   2% /
/dev/vda1              62M  1.3M   58M   3% /boot

Finally “guestfish -N bootrootlv” creates a plain /boot partition, and a / (root) filesystem on a logical volume.

Advertisement

Leave a comment

Filed under Uncategorized

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 )

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.