change btrfs subvolume related commands to loops

This commit is contained in:
i-c-u-p 2022-04-24 11:12:19 +00:00 committed by GitHub
parent be323d103c
commit af35f44baa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 10 deletions

View File

@ -72,21 +72,20 @@ echo -ne "
Creating Filesystems Creating Filesystems
------------------------------------------------------------------------- -------------------------------------------------------------------------
" "
subvols=(home var tmp .snapshots)
# @description Creates the btrfs subvolumes. # @description Creates the btrfs subvolumes.
createsubvolumes () { createsubvolumes () {
btrfs subvolume create /mnt/@ for subvol in '' ${subvols[@]}; do # the '' adds the root subvolume to the loop
btrfs subvolume create /mnt/@home btrfs subvolume create /mnt/@$subvol
btrfs subvolume create /mnt/@var done
btrfs subvolume create /mnt/@tmp
btrfs subvolume create /mnt/@.snapshots
} }
# @description Mount all btrfs subvolumes after root has been mounted. # @description Mount all btrfs subvolumes after root has been mounted.
mountallsubvol () { mountallsubvol () {
mount -o ${MOUNT_OPTIONS},subvol=@home ${partition3} /mnt/home for subvol in ${subvols[@]}; do
mount -o ${MOUNT_OPTIONS},subvol=@tmp ${partition3} /mnt/tmp mount -o ${MOUNT_OPTIONS},subvol=@$subvol ${partition3} /mnt/$subvol
mount -o ${MOUNT_OPTIONS},subvol=@var ${partition3} /mnt/var done
mount -o ${MOUNT_OPTIONS},subvol=@.snapshots ${partition3} /mnt/.snapshots
} }
# @description BTRFS subvolulme creation and mounting. # @description BTRFS subvolulme creation and mounting.
@ -98,7 +97,9 @@ subvolumesetup () {
# mount @ subvolume # mount @ subvolume
mount -o ${MOUNT_OPTIONS},subvol=@ ${partition3} /mnt mount -o ${MOUNT_OPTIONS},subvol=@ ${partition3} /mnt
# make directories home, .snapshots, var, tmp # make directories home, .snapshots, var, tmp
mkdir -p /mnt/{home,var,tmp,.snapshots} for subvol in ${subvols[@]}; do
mkdir -p /mnt/$subvol
done
# mount subvolumes # mount subvolumes
mountallsubvol mountallsubvol
} }