Skip to content

Commit ad9fc3d

Browse files
ElliotLuriezenobit
authored andcommitted
Add initial support for @ subvolumes for BTRFS partitions
1 parent 9016063 commit ad9fc3d

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

installer.sh.in

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,8 +1155,11 @@ as FAT32, mountpoint /boot/efi and at least with 100MB of size." ${MSGBOXSIZE}
11551155
FILESYSTEMS_DONE=1
11561156
}
11571157

1158+
FSOPTS=defaults,noatime
1159+
BTRFS_OPTS="subvol=@,$FSOPTS,space_cache"
1160+
11581161
create_filesystems() {
1159-
local mnts dev mntpt fstype fspassno mkfs size rv uuid
1162+
local mnts dev mntpt fstype fspassno mkfs size rv uuid fsopts
11601163

11611164
mnts=$(grep -E '^MOUNTPOINT.*' $CONF_FILE)
11621165
set -- ${mnts}
@@ -1266,8 +1269,21 @@ failed to create filesystem $fstype on $dev!\ncheck $LOG for errors." ${MSGBOXSI
12661269
# Mount rootfs the first one.
12671270
[ "$mntpt" != "/" ] && continue
12681271
mkdir -p $TARGETDIR
1269-
echo "Mounting $dev on $mntpt ($fstype)..." >$LOG
1270-
mount -t $fstype $dev $TARGETDIR >$LOG 2>&1
1272+
if [ "$fstype" = "btrfs" ]; then
1273+
# Setup subvolume on BTRFS partitions
1274+
echo "Mounting $dev on $mntpt ($fstype) to create subvolume @..." >$LOG
1275+
mount -t $fstype $dev $TARGETDIR >$LOG 2>&1
1276+
btrfs subvolume create $TARGETDIR/@ >$LOG 2>&1
1277+
umount $TARGETDIR >$LOG 2>&1
1278+
fsopts=$BTRFS_OPTS
1279+
echo "Remounting $dev on $mntpt ($fstype) with options [$fsopts]..." >$LOG
1280+
1281+
else
1282+
# Setup filesystem options on other partition types
1283+
fsopts=$FSOPTS
1284+
echo "Mounting $dev on $mntpt ($fstype) with options [$fsopts]..." >$LOG
1285+
fi
1286+
mount -o $fsopts -t $fstype $dev $TARGETDIR >$LOG 2>&1
12711287
if [ $? -ne 0 ]; then
12721288
DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
12731289
failed to mount $dev on ${mntpt}! check $LOG for errors." ${MSGBOXSIZE}
@@ -1280,7 +1296,7 @@ failed to mount $dev on ${mntpt}! check $LOG for errors." ${MSGBOXSIZE}
12801296
else
12811297
fspassno=1
12821298
fi
1283-
echo "UUID=$uuid $mntpt $fstype defaults 0 $fspassno" >>$TARGET_FSTAB
1299+
echo "UUID=$uuid $mntpt $fstype $fsopts 0 $fspassno" >>$TARGET_FSTAB
12841300
done
12851301

12861302
# mount all filesystems in target rootfs
@@ -1302,15 +1318,15 @@ failed to mount $dev on ${mntpt}! check $LOG for errors." ${MSGBOXSIZE}
13021318
[ "$mntpt" = "/" -o "$fstype" = "swap" ] && continue
13031319
mkdir -p ${TARGETDIR}${mntpt}
13041320
echo "Mounting $dev on $mntpt ($fstype)..." >$LOG
1305-
mount -t $fstype $dev ${TARGETDIR}${mntpt} >$LOG 2>&1
1321+
mount -o $FSOPTS -t $fstype $dev ${TARGETDIR}${mntpt} >$LOG 2>&1
13061322
if [ $? -ne 0 ]; then
13071323
DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
13081324
failed to mount $dev on $mntpt! check $LOG for errors." ${MSGBOXSIZE}
13091325
DIE
13101326
fi
13111327
# Add entry to target fstab
13121328
uuid=$(blkid -o value -s UUID "$dev")
1313-
echo "UUID=$uuid $mntpt $fstype defaults 0 2" >>$TARGET_FSTAB
1329+
echo "UUID=$uuid $mntpt $fstype $FSOPTS 0 2" >>$TARGET_FSTAB
13141330
done
13151331
}
13161332

0 commit comments

Comments
 (0)