From 2e20f9751d98d08f33ae081ef58cf9e539a4462f Mon Sep 17 00:00:00 2001 From: Guido Trotter Date: Thu, 14 Aug 2008 10:24:35 +0000 Subject: [PATCH] Use UUID-based mounts for create and import With this change we mount our root and swap filesystems in /etc/fstab based on their UUID rather than on their device name. This makes the system resistent to device name changes, and makes sure the operating system will find its devices whether they're seen as scsi, ide, virtio, or some other new type/name. This change makes the OS be able to boot under KVM, but also xen+paravirt_ops and other possibly other hypervisors. Reviewed-by: imsnah --- NEWS | 7 +++++++ create.in | 12 +++++++----- import | 17 ++++++++++++++++- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index bb8dd89..ccd4eb8 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,10 @@ +Version 0.6 (unreleased) +----------- + +The instance's fstab is now generated with volumes' UUIDs rather than paths. +This makes it more resilient to changes and use under different +hypervisors/drivers. + Version 0.5 ----------- diff --git a/create.in b/create.in index b168e5c..16c16ad 100755 --- a/create.in +++ b/create.in @@ -71,8 +71,10 @@ if [ -z "$instance" -o -z "$blockdev" -o -z "$swapdev" ]; then exit 1 fi -mkswap $swapdev +swap_uuid=$(mkswap $swapdev | grep 'UUID' | sed -re 's/.*UUID=//') mke2fs -Fjq $blockdev +root_uuid=$(dumpe2fs -h $blockdev | grep '^Filesystem UUID:' \ + | sed -re 's/.*UUID:\s*//') TMPDIR=`mktemp -d` || exit 1 trap "umount $TMPDIR; rmdir $TMPDIR" EXIT @@ -129,10 +131,10 @@ echo $instance > $TMPDIR/etc/mailname cat > $TMPDIR/etc/fstab < -/dev/sda / ext3 defaults 0 1 -/dev/sdb swap swap defaults 0 0 -proc /proc proc defaults 0 0 +# +UUID=$root_uuid / ext3 defaults 0 1 +UUID=$swap_uuid swap swap defaults 0 0 +proc /proc proc defaults 0 0 EOF cat > $TMPDIR/etc/network/interfaces < $TMPDIR/etc/fstab.new + mv $TMPDIR/etc/fstab.new $TMPDIR/etc/fstab +fi + umount $TMPDIR rmdir $TMPDIR trap - EXIT -- 1.7.2.5