Ensure to keep directories content if present
This way the script can be called before installation or at the end (preseed/late_command).
This commit is contained in:
parent
0af422207b
commit
74eb9475b0
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# For Debian install
|
# For Debian install in late_command or in a TTY during installation.
|
||||||
# Complete the Btrfs partitionning
|
# Complete the Btrfs partitionning
|
||||||
#
|
#
|
||||||
# Source: https://wiki.101010.fr/doku.php?id=debian:installation_btrfs
|
# Source: https://wiki.101010.fr/doku.php?id=debian:installation_btrfs
|
||||||
|
@ -8,22 +8,20 @@
|
||||||
# Remount the partition with "compress" option
|
# Remount the partition with "compress" option
|
||||||
mount -o remount,defaults,compress=lzo /target
|
mount -o remount,defaults,compress=lzo /target
|
||||||
|
|
||||||
# Create all subvolumes
|
# Manage subvolumes creation
|
||||||
btrfs subvolume create /target/home
|
for DIR in etc home opt root srv tmp usr var; do
|
||||||
btrfs subvolume create /target/opt
|
## Move existent directory to a temp directory
|
||||||
btrfs subvolume create /target/root
|
test -d "/target/${DIR}" && mv -- /target/"${DIR}" /target/"${DIR}".temp
|
||||||
btrfs subvolume create /target/srv
|
## Create subvolume
|
||||||
btrfs subvolume create /target/tmp
|
btrfs subvolume create /target/"${DIR}"
|
||||||
btrfs subvolume create /target/usr
|
## If the directory already existed
|
||||||
btrfs subvolume create /target/var
|
if [ -d "/target/${DIR}.temp" ]; then
|
||||||
|
## Move the content to the new subvolume
|
||||||
# Specific actions for "etc" subvolume
|
mv -- /target/"${DIR}".temp/.* /target/"${DIR}".temp/* /target/"${DIR}"
|
||||||
## In case the installation is based on LUKS/cryptsetup, we need to keep
|
## Remove the temp directory
|
||||||
## the generated cryptsetup's configuration.
|
rmdir -- /target/"${DIR}".temp
|
||||||
mv /target/etc /target/etc.temp
|
fi
|
||||||
btrfs subvolume create /target/etc
|
done
|
||||||
mv /target/etc.temp/* /target/etc
|
|
||||||
rmdir /target/etc.temp
|
|
||||||
|
|
||||||
# Ensure everything is ok
|
# Ensure everything is ok
|
||||||
btrfs subvolume list -p /target
|
btrfs subvolume list -p /target
|
||||||
|
|
Loading…
Reference in New Issue