[PATCH] Use the LUKS device for swap in fstab (#1196200)

David Lehman dlehman at redhat.com
Mon Mar 2 15:35:31 UTC 2015


On 02/26/2015 07:43 AM, Vratislav Podzimek wrote:
> If we create an encrypted swap we need to use the LUKS device in fstab for such
> swap not the partition/LV.
>
> Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> ---
>   pyanaconda/kickstart.py | 27 +++++++++++++++++++++++----
>   1 file changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
> index 756eb81..3656352 100644
> --- a/pyanaconda/kickstart.py
> +++ b/pyanaconda/kickstart.py
> @@ -933,6 +933,7 @@ class LogVolData(commands.logvol.F21_LogVolData):
>               raise KickstartValueError(formatErrorMsg(self.lineno,
>                       msg=_("The \"%s\" file system type is not supported.") % ty))
>
> +        add_fstab_swap = None
>           # If we were given a pre-existing LV to create a filesystem on, we need
>           # to verify it and its VG exists and then schedule a new format action
>           # to take place there.  Also, we only support a subset of all the
> @@ -956,7 +957,7 @@ class LogVolData(commands.logvol.F21_LogVolData):
>
>               devicetree.registerAction(ActionCreateFormat(device, fmt))
>               if ty == "swap":
> -                storage.addFstabSwap(device)
> +                add_fstab_swap = device
>           else:
>               # If a previous device has claimed this mount point, delete the
>               # old one.
> @@ -1011,7 +1012,7 @@ class LogVolData(commands.logvol.F21_LogVolData):
>
>               storage.createDevice(request)
>               if ty == "swap":
> -                storage.addFstabSwap(request)
> +                add_fstab_swap = request
>
>           if self.encrypted:
>               if self.passphrase and not storage.encryptionPassphrase:
> @@ -1038,8 +1039,16 @@ class LogVolData(commands.logvol.F21_LogVolData):
>                   luksdev = LUKSDevice("luks%d" % storage.nextID,
>                                        fmt=luksformat,
>                                        parents=request)
> +            if ty == "swap":
> +                # swap is on the LUKS device not on the LUKS' parent device,
> +                # override the info here
> +                add_fstab_swap = luksdev
> +
>               storage.createDevice(luksdev)
>
> +        if add_fstab_swap:
> +            storage.addFstabSwap(add_fstab_swap)
> +
>   class Logging(commands.logging.FC6_Logging):
>       def execute(self, *args):
>           if logger.loglevel == DEFAULT_LEVEL:
> @@ -1267,6 +1276,7 @@ class PartitionData(commands.partition.F18_PartData):
>
>           kwargs["primary"] = self.primOnly
>
> +        add_fstab_swap = None
>           # If we were given a pre-existing partition to create a filesystem on,
>           # we need to verify it exists and then schedule a new format action to
>           # take place there.  Also, we only support a subset of all the options
> @@ -1289,7 +1299,7 @@ class PartitionData(commands.partition.F18_PartData):
>
>               devicetree.registerAction(ActionCreateFormat(device, kwargs["fmt"]))
>               if ty == "swap":
> -                storage.addFstabSwap(device)
> +                add_fstab_swap = device
>           # tmpfs mounts are not disks and don't occupy a disk partition,
>           # so handle them here
>           elif self.fstype == "tmpfs":
> @@ -1315,7 +1325,7 @@ class PartitionData(commands.partition.F18_PartData):
>
>               storage.createDevice(request)
>               if ty == "swap":
> -                storage.addFstabSwap(request)
> +                add_fstab_swap = request
>
>           if self.encrypted:
>               if self.passphrase and not storage.encryptionPassphrase:
> @@ -1342,8 +1352,17 @@ class PartitionData(commands.partition.F18_PartData):
>                   luksdev = LUKSDevice("luks%d" % storage.nextID,
>                                        fmt=luksformat,
>                                        parents=request)
> +
> +            if ty == "swap":
> +                # swap is on the LUKS device not on the LUKS' parent device,
> +                # override the info here
> +                add_fstab_swap = luksdev
> +
>               storage.createDevice(luksdev)
>
> +        if add_fstab_swap:
> +            storage.addFstabSwap(add_fstab_swap)
> +
>   class Raid(commands.raid.F20_Raid):
>       def execute(self, storage, ksdata, instClass):
>           for r in self.raidList:
>

ACK.



More information about the anaconda-patches mailing list