btrfs and kickstart re-installs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In general, kickstart has good support for installing onto btrfs subvolumes.  However, there is one case that has a small problem: re-installing onto an existing subvol rootfs and/or /boot.

To do an install,  anaconda requires that the rootfs and /boot be "freshly formatted."  For regular partitions and LVMlv, this presents no problem, just reformat the partition or LVMlv.  On the other hand, a btrfs subvolume more closely resembles a directory than a partition and how do you re-format a directory? ... well, by deleting it and then re-defining it.  I can easily do this when I do a regular gui install but kickstart is another matter.

I proposed an update to anaconda/pykickstaert to add the "--reclaim" option for the btrfs command.  This was rejected by anaconda developers because it did not fit with anaconda architecture (my words).  An alternative was proposed to use clearpart to delete the subvolume by referring to the subvolume by it unique UUID.  I do not find this useful because I cannot rerun a kickstart install without changing the kickstart file (each run will involve a different UUID).

I do not want to carry my local modification so I came up with an alternative that requires no modification, works, and works if re-run without changing the kickstart file.

Solution:  I use a %pre section to delete the subvolume.  Given a system with /boot on a ext4 partition and an existing btrfs volume supporting root6 and home subvolumes, it would look something like:

###############
clearpart --none
...
part swap  --fstype=swap --noformat --_onpart_=UUID=a3b0c2ad-88c8-4d6d-876c-7c52881ab854

#part /boot --fstype=ext4 --_onpart_=sda4
#part /boot --fstype=ext4 --_onpart_=sda5
part /boot --fstype=ext4 --_onpart_=sda6
#part /boot --fstype=ext4 --_onpart_=sda7

part btrfs.10 --fstype=btrfs --noformat --label=ten --_onpart_=UUID=0f0f82cb-ed27-4468-a18c-64a877b64329
btrfs /                       --subvol --name=root6   ten
btrfs /var                    --subvol --name=var6    ten
btrfs /home                   --subvol --name=home --noformat  ten
...
%pre --log=/tmp/pre-install.log
echo "manage the btrfs subvolumes"
mkdir /mnt/btrfsvol
mount UUID=0f0f82cb-ed27-4468-a18c-64a877b64329 /mnt/btrfsvol
btrfs subvol list /mnt/btrfsvol
btrfs subvol delete /mnt/btrfsvol/root6
btrfs subvol delete /mnt/btrfsvol/var6
btrfs subvol list /mnt/btrfsvol
umount /mnt/btrfsvol
rmdir /mnt/btrfsvol
%end

%post --nochroot --log=/mnt/sysimage/root/post-install.log
cp -v /tmp/pre-install.log /mnt/sysimage/root
%end
#############

The first time this is run, the "btrfs subvol delete" will produce errors.  Thereafter, reruns will delete the subvols so they can be re-installed.

Note:  Besides this mailing list, this might be good information to add to the kickstart documentation.

Gene
_______________________________________________
Kickstart-list mailing list
Kickstart-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/kickstart-list

[Index of Archives]     [Red Hat General]     [CentOS Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux