<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
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.<br>
<br>
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.<br>
<br>
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).<br>
<br>
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.<br>
<br>
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:<br>
<br>
<big><tt>###############</tt><tt><br>
</tt><tt>clearpart --none</tt><tt><br>
</tt><tt>...</tt><tt><br>
</tt><tt>part swap --fstype=swap --noformat
--onpart=UUID=a3b0c2ad-88c8-4d6d-876c-7c52881ab854</tt><tt><br>
</tt><tt><br>
</tt><tt>#part /boot --fstype=ext4 --onpart=sda4</tt><tt><br>
</tt><tt>#part /boot --fstype=ext4 --onpart=sda5</tt><tt><br>
</tt><tt>part /boot --fstype=ext4 --onpart=sda6</tt><tt><br>
</tt><tt>#part /boot --fstype=ext4 --onpart=sda7</tt><tt><br>
</tt><tt><br>
</tt><tt>part btrfs.10 --fstype=btrfs --noformat --label=ten
--onpart=UUID=0f0f82cb-ed27-4468-a18c-64a877b64329</tt><tt><br>
</tt><tt>btrfs / --subvol --name=root6 ten<br>
btrfs /var --subvol --name=var6 ten<br>
</tt><tt></tt><tt>btrfs /home --subvol
--name=home --noformat ten</tt><tt><br>
</tt><tt>...</tt><tt><br>
</tt><tt>%pre --log=/tmp/pre-install.log</tt><tt><br>
</tt><tt>echo "manage the btrfs subvolumes"</tt><tt><br>
</tt><tt>mkdir /mnt/btrfsvol</tt><tt><br>
</tt><tt>mount UUID=0f0f82cb-ed27-4468-a18c-64a877b64329
/mnt/btrfsvol</tt><tt><br>
</tt><tt>btrfs subvol list /mnt/btrfsvol</tt><tt><br>
</tt><tt>btrfs subvol delete /mnt/btrfsvol/root6</tt><tt><br>
</tt><tt>btrfs subvol delete /mnt/btrfsvol/var6</tt><tt><br>
</tt><tt>btrfs subvol list /mnt/btrfsvol</tt><tt><br>
</tt><tt>umount /mnt/btrfsvol</tt><tt><br>
</tt><tt>rmdir /mnt/btrfsvol</tt><tt><br>
</tt><tt>%end</tt><tt><br>
</tt><tt><br>
</tt><tt>%post --nochroot
--log=/mnt/sysimage/root/post-install.log</tt><tt><br>
</tt><tt>cp -v /tmp/pre-install.log /mnt/sysimage/root</tt><tt><br>
</tt><tt>%end</tt><tt><br>
</tt><tt>#############</tt><tt><br>
</tt></big><br>
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.<br>
<br>
Note: Besides this mailing list, this might be good information to
add to the kickstart documentation.<br>
<br>
Gene<br>
</body>
</html>