Here we have a virtual machine image (
test1.img) that contains an MBR-style partition with an ext2 filesystem on the first partition, and we create a file
/hello on that filesystem. For more explanation see this posting. Very experimental code is in this git repository. Note that we aren’t building or running any of this as root.
$ guestfish Welcome to guestfish, the libguestfs filesystem interactive shell for editing virtual machine filesystems. Type: 'help' for help with commands 'quit' to quit the shell ><fs> help Command Description help display a list of commands or help on a command quit quit guestfish add add a guest image to be examined or modified cdrom add a CD-ROM image to be examined launch launch the subprocess mount mount a guest disk at a position in the filesystem sync sync disks, writes are flushed through to the disk image touch update file timestamps or create a new file Use -h <cmd> / help <cmd> to show detailed help for a command. ><fs> add test1.img ><fs> launch ><fs> mount /dev/sda1 / ><fs> touch /hello ><fs> sync ><fs> exit