[PATCH] Specify btrfs volumes by UUID in fstab

Gene Czarcinski gene at czarc.net
Tue Nov 12 17:36:10 UTC 2013


This is David Lehman's patch corrected so it works.

The purpose of this patch is to have the entris of existing
btrfs subvolumes specified with with their parent's (the
BTRFS volume) UUID rather than the path.

This patch should be considered part of the errata for
bz 892747.  Without this patch, there is an entry in fstab
but it is the pathname rather than the UUID of the BTRFS
volume.

This patch was create on blivet 0.23.4-1 and tested by
creating an updated noarch.rpm which was then applied
via an updates img to Fedora-20-Beta.
---
 blivet/devices.py    | 7 +++++++
 blivet/devicetree.py | 2 ++
 2 files changed, 9 insertions(+)

diff --git a/blivet/devices.py b/blivet/devices.py
index d620eaf..54b2ff7 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -4314,6 +4314,13 @@ class BTRFSDevice(StorageDevice):
     def path(self):
         return self.parents[0].path
 
+    @property
+    def fstabSpec(self):
+        if self.format and self.format.volUUID:
+            spec = "UUID=%s" % self.format.volUUID
+        else:
+            spec = super(BTRFSDevice, self).fstabSpec
+        return spec
 
 class BTRFSVolumeDevice(BTRFSDevice):
     _type = "btrfs volume"
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index 0b8dc36..7bd1963 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -1593,6 +1593,8 @@ class DeviceTree(object):
                 if vol_path in [sv.name for sv in btrfs_dev.subvolumes]:
                     continue
                 fmt = getFormat("btrfs", device=btrfs_dev.path, exists=True,
+                                uuid=btrfs_dev.format.uuid,
+                                volUUID=btrfs_dev.format.volUUID,
                                 mountopts="subvol=%s" % vol_path)
                 subvol = BTRFSSubVolumeDevice(vol_path,
                                               vol_id=vol_id,
-- 
1.8.3.1



More information about the anaconda-patches mailing list