2017-08-18 20:17:46 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2019-01-23 18:56:57 +01:00
|
|
|
# For Debian install in late_command or in a TTY during installation.
|
2017-08-18 20:17:46 +02:00
|
|
|
# Complete the Btrfs partitionning
|
|
|
|
#
|
|
|
|
# Source: https://wiki.101010.fr/doku.php?id=debian:installation_btrfs
|
|
|
|
|
2019-01-23 19:15:09 +01:00
|
|
|
# Ensure to run the script only with a btrfs root
|
|
|
|
grep " /target btrfs " /etc/mtab || exit 1
|
|
|
|
|
2017-08-18 20:17:46 +02:00
|
|
|
# Remount the partition with "compress" option
|
|
|
|
mount -o remount,defaults,compress=lzo /target
|
|
|
|
|
2019-01-23 18:56:57 +01:00
|
|
|
# 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
|
2019-01-23 19:14:41 +01:00
|
|
|
mv -- /target/"${DIR}".temp/* /target/"${DIR}".temp/.[!.]* /target/"${DIR}".temp/..?* /target/"${DIR}"
|
2019-01-23 18:56:57 +01:00
|
|
|
## Remove the temp directory
|
|
|
|
rmdir -- /target/"${DIR}".temp
|
|
|
|
fi
|
|
|
|
done
|
2017-08-18 20:17:46 +02:00
|
|
|
|
|
|
|
# Ensure everything is ok
|
|
|
|
btrfs subvolume list -p /target
|
|
|
|
|
|
|
|
exit 0
|