From 8047078d260a4a7798fa1b412b5518f767deef24 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Wed, 4 Jun 2014 11:03:06 +0000 Subject: Make uuid mandatory when calling create_btrfs_system_layout It's only ever called from the core of the write extensions library, so we can change it to be mandatory in all cases. install_extlinux is left with the uuid being optional and defaulting to /dev/sda, since it is called directly from the rawdisk write extension currently, and upgrades of systems that have an initramfs will be part of a later patch series. --- morphlib/writeexts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'morphlib') diff --git a/morphlib/writeexts.py b/morphlib/writeexts.py index 334dc15c..fb7261f6 100644 --- a/morphlib/writeexts.py +++ b/morphlib/writeexts.py @@ -221,7 +221,7 @@ class WriteExtension(cliapp.Application): os.rmdir(mount_point) def create_btrfs_system_layout(self, temp_root, mountpoint, version_label, - disk_uuid=None): + disk_uuid): '''Separate base OS versions from state using subvolumes. ''' -- cgit v1.2.1 From 6daa22a652a622dfafc967b38cb7d123457bb23c Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Wed, 4 Jun 2014 11:10:43 +0000 Subject: Use UUID in fstab entries if provided This makes systems use the UUID of the disk in the fstab when there is no pre-existing fstab entry for /. This happens whether the system has an initramfs or not, since it should be harmless, and by this point we're in userland, so can know what the UUIDs are. Passing the UUID to `complete_fstab_for_btrfs_layout` is optional, and defaults to the old behaviour of using /dev/sda, since it is called directly by some write extensions for doing upgrades, and upgrading systems that use an initramfs will be part of a later patch. --- morphlib/writeexts.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'morphlib') diff --git a/morphlib/writeexts.py b/morphlib/writeexts.py index fb7261f6..d6f23e0d 100644 --- a/morphlib/writeexts.py +++ b/morphlib/writeexts.py @@ -235,7 +235,8 @@ class WriteExtension(cliapp.Application): self.create_orig(version_root, temp_root) system_dir = os.path.join(version_root, 'orig') - state_dirs = self.complete_fstab_for_btrfs_layout(system_dir) + state_dirs = self.complete_fstab_for_btrfs_layout(system_dir, + disk_uuid) for state_dir in state_dirs: self.create_state_subvolume(system_dir, mountpoint, state_dir) @@ -298,7 +299,7 @@ class WriteExtension(cliapp.Application): filepath = os.path.join(existing_state_dir, filename) cliapp.runcmd(['mv', filepath, subvolume]) - def complete_fstab_for_btrfs_layout(self, system_dir): + def complete_fstab_for_btrfs_layout(self, system_dir, rootfs_uuid=None): '''Fill in /etc/fstab entries for the default Btrfs disk layout. In the future we should move this code out of the write extension and @@ -322,8 +323,9 @@ class WriteExtension(cliapp.Application): if '/' in existing_mounts: root_device = existing_mounts['/'] else: - root_device = '/dev/sda' - fstab.add_line('/dev/sda / btrfs defaults,rw,noatime 0 1') + root_device = ('/dev/sda' if rootfs_uuid is None else + 'UUID=%s' % rootfs_uuid) + fstab.add_line('%s / btrfs defaults,rw,noatime 0 1' % root_device) state_dirs_to_create = set() for state_dir in shared_state_dirs: -- cgit v1.2.1