diff options
author | James Thomas <james.thomas@codethink.co.uk> | 2014-07-30 17:46:58 +0100 |
---|---|---|
committer | James Thomas <james.thomas@codethink.co.uk> | 2014-08-03 12:49:22 +0100 |
commit | 37b7e39aa7c2216c385b87f8c986821ad2cc1d52 (patch) | |
tree | a9b34e8f178cb9ad32a9ee158bd86a45db078223 | |
parent | 21c9683278cb01a4e9425923740124217ce47723 (diff) | |
download | definitions-37b7e39aa7c2216c385b87f8c986821ad2cc1d52.tar.gz |
Support setting a different root device using ROOT_DEVICE
-rw-r--r-- | writeexts.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/writeexts.py b/writeexts.py index 74587bd1..1b8770e2 100644 --- a/writeexts.py +++ b/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: |