From de35a0f256999e107ee524a4647151aab6cbfc87 Mon Sep 17 00:00:00 2001 From: James Thomas Date: Wed, 30 Jul 2014 17:46:58 +0100 Subject: Support setting a different root device using ROOT_DEVICE --- morphlib/writeexts.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/morphlib/writeexts.py b/morphlib/writeexts.py index 74587bd1..1b8770e2 100644 --- a/morphlib/writeexts.py +++ b/morphlib/writeexts.py @@ -334,7 +334,7 @@ class WriteExtension(cliapp.Application): if '/' in existing_mounts: root_device = existing_mounts['/'] else: - root_device = ('/dev/sda' if rootfs_uuid is None else + root_device = (self.get_root_device() if rootfs_uuid is None else 'UUID=%s' % rootfs_uuid) fstab.add_line('%s / btrfs defaults,rw,noatime 0 1' % root_device) @@ -388,6 +388,9 @@ class WriteExtension(cliapp.Application): def get_extra_kernel_args(self): return os.environ.get('KERNEL_ARGS', '') + def get_root_device(self): + return os.environ.get('ROOT_DEVICE', '/dev/sda') + def install_extlinux(self, real_root, disk_uuid=None): '''Install extlinux on the newly created disk image.''' @@ -399,7 +402,7 @@ class WriteExtension(cliapp.Application): 'rootfstype=btrfs ' # required when using initramfs, also boots # faster when specified without initramfs 'rootflags=subvol=systems/default/run ') # boot runtime subvol - kernel_args += 'root=%s ' % ('/dev/sda' if disk_uuid is None + kernel_args += 'root=%s ' % (self.get_root_device() if disk_uuid is None else 'UUID=%s' % disk_uuid) kernel_args += self.get_extra_kernel_args() with open(config, 'w') as f: -- cgit v1.2.1