Skip to content

Commit

Permalink
Add initial support for @ subvolumes for BTRFS partitions
Browse files Browse the repository at this point in the history
  • Loading branch information
ElliotLurie committed Apr 26, 2021
1 parent 25ddad3 commit 8b3af36
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions installer.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -1003,8 +1003,11 @@ as FAT32, mountpoint /boot/efi and at least with 100MB of size." ${MSGBOXSIZE}
FILESYSTEMS_DONE=1
}

FSOPTS=defaults,noatime
BTRFS_OPTS="subvol=@,$FSOPTS,space_cache"

create_filesystems() {
local mnts dev mntpt fstype fspassno mkfs size rv uuid
local mnts dev mntpt fstype fspassno mkfs size rv uuid fsopts

mnts=$(grep -E '^MOUNTPOINT.*' $CONF_FILE)
set -- ${mnts}
Expand Down Expand Up @@ -1058,8 +1061,21 @@ failed to create filesystem $fstype on $dev!\ncheck $LOG for errors." ${MSGBOXSI
# Mount rootfs the first one.
[ "$mntpt" != "/" ] && continue
mkdir -p $TARGETDIR
echo "Mounting $dev on $mntpt ($fstype)..." >$LOG
mount -t $fstype $dev $TARGETDIR >$LOG 2>&1
if [ "$fstype" = "btrfs" ]; then
# Setup subvolume on BTRFS partitions
echo "Mounting $dev on $mntpt ($fstype) to create subvolume @..." >$LOG
mount -t $fstype $dev $TARGETDIR >$LOG 2>&1
btrfs subvolume create $TARGETDIR/@ >$LOG 2>&1
umount $TARGETDIR >$LOG 2>&1
fsopts=$BTRFS_OPTS
echo "Remounting $dev on $mntpt ($fstype) with options [$fsopts]..." >$LOG

else
# Setup filesystem options on other partition types
fsopts=$FSOPTS
echo "Mounting $dev on $mntpt ($fstype) with options [$fsopts]..." >$LOG
fi
mount -o $fsopts -t $fstype $dev $TARGETDIR >$LOG 2>&1
if [ $? -ne 0 ]; then
DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
failed to mount $dev on ${mntpt}! check $LOG for errors." ${MSGBOXSIZE}
Expand All @@ -1072,7 +1088,7 @@ failed to mount $dev on ${mntpt}! check $LOG for errors." ${MSGBOXSIZE}
else
fspassno=1
fi
echo "UUID=$uuid $mntpt $fstype defaults 0 $fspassno" >>$TARGET_FSTAB
echo "UUID=$uuid $mntpt $fstype $fsopts 0 $fspassno" >>$TARGET_FSTAB
done

# mount all filesystems in target rootfs
Expand All @@ -1084,15 +1100,15 @@ failed to mount $dev on ${mntpt}! check $LOG for errors." ${MSGBOXSIZE}
[ "$mntpt" = "/" -o "$fstype" = "swap" ] && continue
mkdir -p ${TARGETDIR}${mntpt}
echo "Mounting $dev on $mntpt ($fstype)..." >$LOG
mount -t $fstype $dev ${TARGETDIR}${mntpt} >$LOG 2>&1
mount -o $FSOPTS -t $fstype $dev ${TARGETDIR}${mntpt} >$LOG 2>&1
if [ $? -ne 0 ]; then
DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
failed to mount $dev on $mntpt! check $LOG for errors." ${MSGBOXSIZE}
DIE
fi
# Add entry to target fstab
uuid=$(blkid -o value -s UUID "$dev")
echo "UUID=$uuid $mntpt $fstype defaults 0 2" >>$TARGET_FSTAB
echo "UUID=$uuid $mntpt $fstype $FSOPTS 0 2" >>$TARGET_FSTAB
done
}

Expand Down

0 comments on commit 8b3af36

Please sign in to comment.