HOWTO: Filesystems

In the following howto’s, <image file> should be replaced with a reference to a specific .img file.

How do I mount an image without booting it?

  • mkdir -p /mnt/loop
  • mount -o loop <image file> /mnt/loop/

How do I resize an image file?

First, make sure that the image file is not already mounted and is not already running as a xen guest. The following commands increase an image file to 2.5GB. Backup the image before attempting this.

  • dd if=/dev/zero of=<image file> bs=1M conv=notrunc count=1 seek=2500
  • losetup /dev/loop0 <image file>
  • e2fsck -f /dev/loop0
  • resize2fs /dev/loop0
  • e2fsck -f /dev/loop0
  • losetup -d /dev/loop0

You may then boot or mount the image to confirm the increased size. The e2fsck checks in this howto are not strictly necessary.

How do I move the contents of an img file to a regular partition?

Mount the img file using the above howto. Assuming the destination partition is mounted at /mnt/dest, execute the following:

  • cp -a /mnt/loop/* /mnt/dest/

You will then be able to boot the filesystem using the partition instead of the image file, which should provide better performance. You will need to update the *.xen.cfg file to reference the partition instead of the img file (the disk parameter will need to change, see the Xen Manual). Also, remember to unmount partitions or img files before booting a xen guest from them!

 
howto/filesystem.txt · Last modified: 2005/08/27 22:35 by dfn
 
Questions? Comments? Email admin@jailtime.org