[PATCH] Specify btrfs volumes by UUID in fstab

David Lehman dlehman at redhat.com
Wed Nov 13 16:10:18 UTC 2013


On Tue, 2013-11-12 at 12:36 -0500, Gene Czarcinski wrote:
> 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.

I have made a couple of minor changes to my version of the patch, most
notably setting the fstab spec to "UUID=<volUUID>" instead of just
"<volUUID>". Comments below apply to your patch and are fixed in mine.

I'll push it to master today, but I doubt this will be in f20 since it's
not at all critical.

> 
> 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:

self.format will never evaluate to False, so there's no point in that.

> +            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,

We don't want to pass format.uuid -- only volUUID. The uuid should be
unique and those are really the UUIDs for the individual member block
devices, so it makes no sense to set them in the subvolumes.

>                                  mountopts="subvol=%s" % vol_path)
>                  subvol = BTRFSSubVolumeDevice(vol_path,
>                                                vol_id=vol_id,




More information about the anaconda-patches mailing list