This patch is intended to implement the BTRFS equivalent of reformatting a subvolume from a kickstart. That is, a subvolume is destroyed and then (re)created. As currently implemented this is a "hack" which only works for a subvolume with the "/" mountpoint. Once the pykickstart package has been updated to separate --noformat and --useexisting parameters so that they can have different meanings, the simple test for "/" can be removed the the rest of the patch is good.
To invoke this functionality, the user must specify --useexisting on the btrfs command for the "/" mountpoint. If the subvolume does not exist, it does not matter and processing will continue. Again, once pykickstart is updated, this will work for other subvolumes. --- pyanaconda/kickstart.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py index 739f716..7a76f6d 100644 --- a/pyanaconda/kickstart.py +++ b/pyanaconda/kickstart.py @@ -346,7 +346,9 @@ class BTRFSData(commands.btrfs.F17_BTRFSData): if self.mountpoint != "" and self.mountpoint[0] != '/': raise KickstartValueError(formatErrorMsg(self.lineno, msg="The mount point "%s" is not valid." % (self.mountpoint,)))
- if not self.format: # --noformat + # FIXME: The following hack only exists until pykickstart can be updated to separate + # --noformat and --useexisting into separate parameters so they can have different meanings + if not self.format and self.mountpoint != "/": # --noformat if not self.subvol: raise KickstartValueError(formatErrorMsg(self.lineno, msg="Specifying btrfs command for existing volume %s invalid" % self.name))
@@ -370,6 +372,16 @@ class BTRFSData(commands.btrfs.F17_BTRFSData): except KeyError: pass
+ # Handle pre-existing subvol to be deleted + if self.subvol: + device = devicetree.getDeviceByName(self.name) + if device: + if self.preexist: + storage.destroyDevice(device) + log.info("As requested by specified --useexisting, destroying existing BTRFS subvolume %s" % self.name) + else: + raise KickstartValueError(formatErrorMsg(self.lineno, msg="Specified BTRFS subvolume %s already exists, specify --useexisting to recreate" % self.name)) + request = storage.newBTRFS(name=name, subvol=self.subvol, mountpoint=self.mountpoint,
On Mon, 2013-10-14 at 09:33 -0400, Gene Czarcinski wrote:
This patch is intended to implement the BTRFS equivalent of reformatting a subvolume from a kickstart. That is, a subvolume is destroyed and then (re)created. As currently implemented this is a "hack" which only works for a subvolume with the "/" mountpoint. Once the pykickstart package has been updated to separate --noformat and --useexisting parameters so that they can have different meanings, the simple test for "/" can be removed the the rest of the patch is good.
There are no commands in kickstart's partitioning that implicitly remove a device. This isn't acceptable.
anaconda-patches@lists.fedorahosted.org