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: Upgrading images

These instructions can be followed if you already have a working image but want to upgrade to a newer version of a distribution. Always back up your image before attempting a major upgrade.

How do I upgrade a Centos 4.1 guest image to 4.2?

  • Back everything up!
  • Start the guest image
  • Edit /etc/yum.conf to point to a valid CentOS 4.2 repository
  • yum upgrade (this will take a while)
  • Post-upgrade tweaks (to avoid various errors during startup and shutdown)
    • The hwclock error can be fixed by replacing /sbin/hwclock with an empty shell script.
    • The tls emulation error can be fixed by moving /lib/tls to /lib/tls.disabled
    • Edit /etc/rc.d/rc.sysinit: remove lines 77-87 (tty spawn) and 213 (raid)
 
howto/start.txt · Last modified: 2005/10/17 21:31
 
Questions? Comments? Email admin@jailtime.org