diff --git a/debian/part.btrfs.sh b/debian/part.btrfs.sh index 16320a5..aa64ed3 100755 --- a/debian/part.btrfs.sh +++ b/debian/part.btrfs.sh @@ -1,6 +1,6 @@ #!/bin/sh -# For Debian install +# For Debian install in late_command or in a TTY during installation. # Complete the Btrfs partitionning # # Source: https://wiki.101010.fr/doku.php?id=debian:installation_btrfs @@ -8,22 +8,20 @@ # Remount the partition with "compress" option mount -o remount,defaults,compress=lzo /target -# Create all subvolumes -btrfs subvolume create /target/home -btrfs subvolume create /target/opt -btrfs subvolume create /target/root -btrfs subvolume create /target/srv -btrfs subvolume create /target/tmp -btrfs subvolume create /target/usr -btrfs subvolume create /target/var - -# Specific actions for "etc" subvolume -## In case the installation is based on LUKS/cryptsetup, we need to keep -## the generated cryptsetup's configuration. -mv /target/etc /target/etc.temp -btrfs subvolume create /target/etc -mv /target/etc.temp/* /target/etc -rmdir /target/etc.temp +# Manage subvolumes creation +for DIR in etc home opt root srv tmp usr var; do + ## Move existent directory to a temp directory + test -d "/target/${DIR}" && mv -- /target/"${DIR}" /target/"${DIR}".temp + ## Create subvolume + btrfs subvolume create /target/"${DIR}" + ## If the directory already existed + if [ -d "/target/${DIR}.temp" ]; then + ## Move the content to the new subvolume + mv -- /target/"${DIR}".temp/.* /target/"${DIR}".temp/* /target/"${DIR}" + ## Remove the temp directory + rmdir -- /target/"${DIR}".temp + fi +done # Ensure everything is ok btrfs subvolume list -p /target