From 340f6c6aecd995f1be79788a4a0237e142c099b2 Mon Sep 17 00:00:00 2001
From: natemaia <natemaia10@gmail.com>
Date: Thu, 14 May 2020 00:16:20 -0700
Subject: [PATCH] Initial btrfs support

---
 archlabs-installer | 190 ++++++++++++++++++++++++++++++++++++---------
 1 file changed, 155 insertions(+), 35 deletions(-)

diff --git a/archlabs-installer b/archlabs-installer
index 4156874..5da514a 100755
--- a/archlabs-installer
+++ b/archlabs-installer
@@ -7,7 +7,7 @@
 
 # shellcheck disable=SC2086,SC2046,SC2254
 
-VER=2.1.48
+VER=2.1.49
 
 # default values {
 
@@ -23,6 +23,7 @@ BG=/tmp/bgout                      # output from background process
 ERR=/tmp/errlog                    # stderr log used internally by errshow()
 DBG=/tmp/debuglog                  # debug log file when passed -d
 RUN=/run/archiso/bootmnt/arch/boot # path for live system /boot
+BTRFS=0                            # is btrfs used, 1 = btrfs alone, 2 = btrfs + subvolume(s)
 EXMNTS=""                          # extra partitions that were mounted, used to verify mountpoint and show user
 USER_CMD=""                        # optional command(s) entered by the user to run in the chroot
 VM="$(systemd-detect-virt)"        # system running in a virtual machine
@@ -248,6 +249,7 @@ declare -A EDIT_FILES=(
 
 # mkfs command flags for filesystem formatting {
 declare -A FS_CMD_FLAGS=(
+[btrfs]='-f'
 [ext2]='-q'
 [ext3]='-q'
 [ext4]='-q'
@@ -272,6 +274,7 @@ declare -A FS_OPTS=(
 [xfs]='discard filestreams ikeep largeio noalign nobarrier norecovery noquota wsync'
 [nilfs2]='discard nobarrier errors=continue errors=panic order=relaxed order=strict norecovery'
 [f2fs]='discard fastboot flush_merge data_flush inline_xattr inline_data noinline_data inline_dentry no_heap noacl nobarrier norecovery noextent_cache disable_roll_forward disable_ext_identify'
+[btrfs]='autodefrag compress=zlib compress=lzo compress=no compress-force=zlib compress-force=lzo discard noacl noatime nodatasum nospace_cache recovery skip_balance space_cache ssd ssd_spread'
 ) # }
 
 # packages installed for each login option {
@@ -312,6 +315,7 @@ _device="\nSelect a device to use from the list below.\n\nDevices (/dev) are the
 _mount="\nUse [Space] to toggle mount options from below, press [Enter] when done to confirm selection.\n\nNot selecting any and confirming will run an automatic mount."
 _warn="\nIMPORTANT: Choose carefully when editing, formatting, and mounting partitions or your DATA MAY BE LOST.\n\nTo mount a partition without formatting it, select 'skip' when prompted to choose a file system during the mounting stage.\nThis can only be used for partitions that already contain a file system and cannot be the root (/) partition, it needs to be formatted before install.\n"
 _part="\nFull device auto partitioning is available for beginners otherwise cfdisk is recommended.\n\n  - All systems will require a root partition (8G or greater).\n  - UEFI or BIOS using LUKS without LVM require a separate boot partition (100-512M)."
+_btrfs="\nBtrfs can create branching subvolumes.\n\nAn initial subvolume will be created and mounted with additional subvolumes branching from this created after.\nOtherwise you can skip directly to mounting options.\n\nCreate subvolumes?\n"
 _uefi="\nSelect the EFI boot partition (/boot), required for UEFI boot.\n\nIt's usually the first partition on the device, 100-512M, and will be formatted as vfat/fat32 if not already."
 _bios="\nDo you want to use a separate boot partition? (optional)\n\nIt's usually the first partition on the device, 100-512M, and will be formatted as ext3/4 if not already."
 _biosluks="\nSelect the boot partition (/boot), required for LUKS.\n\nIt's usually the first partition on the device, 100-512M, and will be formatted as ext3/4 if not already."
@@ -357,6 +361,7 @@ _errchoice="\nIf you want to fix the issue yourself use Ctrl-z to pause the inst
 _lukserr="\nA minimum of two partitions are required for encryption:\n\n 1. root (/) - standard or LVM.\n 2. boot (/boot) - standard (unless using LVM on BIOS systems).\n"
 _lvmerr="\nThere are no viable partitions available to use for LVM, a minimum of one is required.\n\nIf LVM is already in use, deactivating it will allow the partition(s) to be used again.\n"
 _lvmerrvgname="\nInvalid name entered.\n\nThe volume group name may be alpha-numeric, but may not contain spaces, start with a '/', or already be in use.\n"
+_btrfserrname="\nInvalid name entered.\n\nThe subvolume name may be alpha-numeric, but may not contain spaces, start with a '/', or already be in use.\n"
 _lvmerlvname="\nInvalid name entered.\n\nThe logical volume (LV) name may be alpha-numeric, but may not contain spaces or be preceded with a '/'\n"
 _lvmerrlvsize="\nInvalid value Entered.\n\nMust be a numeric value with 'M' (megabytes) or 'G' (gigabytes) at the end.\n\neg. 400M, 10G, 250G, etc...\n\nThe value may also not be equal to or greater than the remaining size of the volume group.\n"
 
@@ -444,8 +449,8 @@ select_show()
 	msg "Show Configuration" "
 ---------- PARTITION CONFIGURATION ------------
 
-  Root Part:      $ROOT
-  Boot Part:      ${BOOT:-none}
+  Root Part:      $ROOT - ${ROOTFS:-skipped}
+  Boot Part:      ${BOOT:-none} - ${BOOTFS:-none}
   Boot Device:    ${BOOT_D:-none}
   Swap Part/File: ${SWAP:-none}
   Swap Size:      ${SWAP_S:-none}
@@ -1021,13 +1026,14 @@ part_mount()
 {
 	local part="$1"
 	local mntpt="${MNT}$2"
-	shift 2
+	local ignore=''
+	[[ $part == "$ROOT" && $3 ]] && ignore=$3
 	local fs
 	fs="$(lsblk -lno FSTYPE "$part")"
 
 	mkdir -p "$mntpt"
 
-	if [[ $fs && ${FS_OPTS[$fs]} && $part != "$BOOT" && $part != "$AUTO_ROOT" ]] && select_mntopts "$fs"; then
+	if [[ $ignore -ne 2 && $fs && ${FS_OPTS[$fs]} && $part != "$BOOT" && $part != "$AUTO_ROOT" ]] && select_mntopts "$fs"; then
 		mount -o "$MNT_OPTS" "$part" "$mntpt" > /dev/null 2> "$ERR"
 		errshow 0 "mount -o '$MNT_OPTS' '$part' '$mntpt' > /dev/null" || return 1
 	else
@@ -1281,8 +1287,14 @@ select_boot()
 	fi
 
 	case "$SYS" in
-		UEFI) part_format "$BOOT" "vfat" 2 || return 1 ;;
-		BIOS) part_format "$BOOT" "ext4" 2 || return 1 ;;
+		UEFI)
+			BOOTFS='vfat'
+			part_format "$BOOT" "vfat" 2 || return 1
+			;;
+		BIOS)
+			BOOTFS='ext4'
+			part_format "$BOOT" "ext4" 2 || return 1
+			;;
 	esac
 	return 0
 }
@@ -1321,8 +1333,13 @@ select_root()
 		fi
 	fi
 
-	[[ $ROOT ]] && select_filesystem "$ROOT" && part_mount "$ROOT" "" && return 0
-
+	if [[ $ROOT ]]; then
+		select_filesystem "$ROOT" || return 1
+		part_mount "$ROOT" "" $BTRFS || return 1
+		if (( BTRFS == 2 )); then
+			btrfs_subvols "" "$ROOT" || return 1
+		fi
+	fi
 	# should never reach here unless an error occurred
 	ROOT=''
 	return 1
@@ -1393,7 +1410,10 @@ select_extra()
 		dlg part menu 'Mount Extra' "$_expart" 'done' 'finish mounting step' $PARTS || break
 		if [[ $part == 'done' ]]; then
 			break
-		elif select_filesystem "$part" && select_mountpoint && part_mount "$part" "$EXMNT"; then
+		elif select_filesystem "$part" && select_mountpoint && part_mount "$part" "$EXMNT" $BTRFS; then
+			if (( BTRFS == 2 )); then
+				btrfs_subvols "$EXMNT" "$part" || return 1
+			fi
 			EXMNTS+="$part: $EXMNT "
 			[[ $EXMNT == '/usr' && $HOOKS != *usr* ]] && HOOKS+=" usr"
 		else
@@ -1436,26 +1456,39 @@ select_filesystem()
 	txt="\nSelect which file system to use\n\npart: $pt\n\nfs default:  ext4"
 
 	if [[ $cur ]]; then
+		txt+="\nCurrent:  $cur"
 		# bail early if the partition was created in part_auto()
 		[[ $part == "$AUTO_ROOT" ]] && return 0
-		[[ $part != "$ROOT" ]] && txt+="\nCurrent:  $cur"
 	fi
 
+	BTRFS=0
 	until [[ $fs ]]; do
-		dlg fs menu "File System" "$txt" $([[ $cur && $part != "$ROOT" ]] && printf "skip -") \
+		dlg fs menu "File System" "$txt" $([[ $cur ]] && printf "skip 'Do not format the current partition'") \
 			ext4 "The evolution of the most used Linux file system, successor to Ext3" \
 			ext3 "Third extended file system, successor to Ext2" \
 			ext2 "Second extended file system, unlike 3/4 it is not journaled and obsolete" \
 			vfat "File allocation table, a legacy file system which is simple and robust" \
+			btrfs "A modern copy on write file system with advanced features, fault tolerance, repair, and easy administration" \
 			ntfs "NT file system, a journaling file system created by Microsoft" \
 			f2fs "Flash-friendly file system, intended for NAND-based flash memory" \
 			jfs "Journaled file system created by IBM and open-sourced in 1999" \
 			xfs "Journaled file system created by Silicon Graphics Inc. (SGI)" \
 			nilfs2 "A log-structured file system implementation for the Linux kernel" \
 			reiserfs "Journaled file system created by a team at Namesys led by Hans Reiser" || return 1
+
 		[[ $fs == 'skip' ]] && return 0
 		yesno "File System" "\nConfirm Format\n\npart: $pt\n\nfs: $fs\n" || fs=''
+
+		if [[ $fs == 'f2fs' ]]; then
+			modprobe f2fs
+		elif [[ $fs == 'btrfs' ]]; then
+			modprobe btrfs
+			BTRFS=1
+			yesno "Btrfs Subvolumes" "$_btrfs" && BTRFS=2
+		fi
 	done
+
+	[[ $part == "$ROOT" ]] && ROOTFS=$fs
 	part_format "$part" "$fs" 0
 }
 
@@ -1491,6 +1524,12 @@ install_main()
 	install_user
 	install_login
 
+	# changing distro name?
+	if [[ $DIST != "ArchLabs" ]]; then
+		sed -i "s/ArchLabs/$DIST/g" "$MNT/etc/lsb-release"
+		sed -i "s/ArchLabs/$DIST/g" "$MNT/etc/os-release"
+	fi
+
 	# allow members of the wheel group to run commands as root
 	sed -i "s/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g" "$MNT/etc/sudoers"
 
@@ -1577,14 +1616,15 @@ install_base()
 		find "$MNT/boot" -name '*-ucode.img' -delete
 	fi
 
-	# changing distro name?
-	[[ $DIST != "ArchLabs" ]] || sed -i "s/ArchLabs/$DIST/g" "$MNT/etc/"{lsb-release,os-release}
-
 	# copy network settings
 	[[ -f /etc/resolv.conf ]] && cp -fv /etc/resolv.conf "$MNT/etc/"
 	[[ -d /etc/netctl/interfaces ]] && cp -rfv /etc/netctl/interfaces "$MNT/etc/netctl/"
 	[[ -d /etc/NetworkManager/system-connections ]] && cp -rvf /etc/NetworkManager/system-connections "$MNT/etc/NetworkManager/"
 
+	# Stop pacman complaining
+	chrun 'mkdir -p /var/lib/pacman/sync'
+	chrun 'touch /var/lib/pacman/sync/{core.db,extra.db,community.db}'
+
 	# allow members of the wheel group to run commands as root
 	sed -i "s/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g" "$MNT/etc/sudoers"
 
@@ -1730,8 +1770,10 @@ install_bootldr()
 	if [[ $SYS == 'UEFI' ]]; then
 		# remove our old install and generic BOOT/ dir
 		echo "Removing conflicting boot directories"
-		find "$MNT/boot/EFI/" -maxdepth 1 -mindepth 1 -iname "$DIST" -type d -delete -printf "remove %p\n"
-		find "$MNT/boot/EFI/" -maxdepth 1 -mindepth 1 -iname 'BOOT' -type d -delete -printf "remove %p\n"
+		if [[ -d "$MNT/boot/EFI/$DIST" ]]; then
+			find "$MNT/boot/EFI/" -maxdepth 1 -mindepth 1 -iname "$DIST" -type d -delete -printf "remove %p\n"
+			find "$MNT/boot/EFI/" -maxdepth 1 -mindepth 1 -iname 'BOOT' -type d -delete -printf "remove %p\n"
+		fi
 	fi
 
 	if [[ $SWAP ]]; then # attempt to setup swap space for suspend/resume
@@ -1798,9 +1840,11 @@ install_packages()
 		grep -qi 'ntfs' <<< "$blk" && inpkg+=("ntfs-3g")
 		grep -qi 'jfs' <<< "$blk" && inpkg+=("jfsutils")
 		grep -qi 'xfs' <<< "$blk" && inpkg+=("xfsprogs")
-		grep -qi 'btrfs' <<< "$blk" && inpkg+=("btrfs-progs")
 		grep -qi 'reiserfs' <<< "$blk" && inpkg+=("reiserfsprogs")
 		[[ $LVM ]] && inpkg+=("lvm2")
+		if [[ $BTRFS_MNT ]] || grep -qi 'btrfs' <<< "$blk"; then
+			inpkg+=("btrfs-progs")
+		fi
 	fi
 
 	[[ $INSTALL_WMS =~ dwm ]] && inpkg+=("git")
@@ -2162,7 +2206,10 @@ prerun_efistub()
 {
 	BCMDS[efistub]="mount -t efivarfs efivarfs /sys/firmware/efi/efivars > /dev/null 2>&1
 		efibootmgr -v -d $BOOT_D -p $BOOT_NUM -c -L '${DIST} Linux' -l /vmlinuz-${KERNEL} \
-		-u 'root=$ROOT_ID rw $([[ $UCODE ]] && printf 'initrd=\%s.img ' "$UCODE")initrd=\initramfs-${KERNEL}.img'"
+			-u 'root=$ROOT_ID rw $(
+					[[ $BTRFS_MNT ]] && printf '%s ' "$BTRFS_MNT"
+					[[ $UCODE ]] && printf 'initrd=\%s.img ' "$UCODE"
+					)initrd=\initramfs-${KERNEL}.img'"
 }
 
 setup_syslinux()
@@ -2219,13 +2266,13 @@ prerun_syslinux()
 	LABEL $DIST
 	MENU LABEL $DIST Linux
 	LINUX $d/vmlinuz-$KERNEL
-	APPEND root=$ROOT_ID ${LUKS_DEV}${RESUME}rw
+	APPEND root=$ROOT_ID ${LUKS_DEV}${RESUME}rw$([[ $BTRFS_MNT ]] && printf ' %s' "$BTRFS_MNT")
 	INITRD $([[ $UCODE ]] && printf "%s" "$d/$UCODE.img,")$d/initramfs-$KERNEL.img
 
 	LABEL ${DIST}fallback
 	MENU LABEL $DIST Linux Fallback
 	LINUX $d/vmlinuz-$KERNEL
-	APPEND root=$ROOT_ID ${LUKS_DEV}${RESUME}rw
+	APPEND root=$ROOT_ID ${LUKS_DEV}${RESUME}rw$([[ $BTRFS_MNT ]] && printf ' %s' "$BTRFS_MNT")
 	INITRD $([[ $UCODE ]] && printf "%s" "$d/$UCODE.img,")$d/initramfs-$KERNEL-fallback.img
 	EOF
 	return 0
@@ -2240,9 +2287,9 @@ setup_refind-efi()
 prerun_refind-efi()
 {
 	cat > "$MNT/boot/refind_linux.conf" <<- EOF
-	"$DIST Linux"          "root=$ROOT_ID ${LUKS_DEV}${RESUME}rw add_efi_memmap $([[ $UCODE ]] &&
+	"$DIST Linux"          "root=$ROOT_ID ${LUKS_DEV}${RESUME}rw$([[ $BTRFS_MNT ]] && printf ' %s' "$BTRFS_MNT") add_efi_memmap $([[ $UCODE ]] &&
 						printf "initrd=%s " "/$UCODE.img")initrd=/initramfs-%v.img"
-	"$DIST Linux Fallback" "root=$ROOT_ID ${LUKS_DEV}${RESUME}rw add_efi_memmap $([[ $UCODE ]] &&
+	"$DIST Linux Fallback" "root=$ROOT_ID ${LUKS_DEV}${RESUME}rw$([[ $BTRFS_MNT ]] && printf ' %s' "$BTRFS_MNT") add_efi_memmap $([[ $UCODE ]] &&
 						printf "initrd=%s " "/$UCODE.img")initrd=/initramfs-%v-fallback.img"
 	EOF
 
@@ -2281,14 +2328,14 @@ prerun_systemd-boot()
 	title   $DIST Linux
 	linux   /vmlinuz-${KERNEL}$([[ $UCODE ]] && printf "\ninitrd  %s" "/$UCODE.img")
 	initrd  /initramfs-$KERNEL.img
-	options root=$ROOT_ID ${LUKS_DEV}${RESUME}rw
+	options root=$ROOT_ID ${LUKS_DEV}${RESUME}rw$([[ $BTRFS_MNT ]] && printf ' %s' "$BTRFS_MNT")
 	EOF
 
 	cat > "$MNT/boot/loader/entries/$DIST-fallback.conf" <<- EOF
 	title   $DIST Linux Fallback
 	linux   /vmlinuz-${KERNEL}$([[ $UCODE ]] && printf "\ninitrd  %s" "/$UCODE.img")
 	initrd  /initramfs-$KERNEL-fallback.img
-	options root=$ROOT_ID ${LUKS_DEV}${RESUME}rw
+	options root=$ROOT_ID ${LUKS_DEV}${RESUME}rw$([[ $BTRFS_MNT ]] && printf ' %s' "$BTRFS_MNT")
 	EOF
 
 	mkdir -pv "$MNT/etc/pacman.d/hooks"
@@ -2307,6 +2354,73 @@ prerun_systemd-boot()
 	return 0
 }
 
+###############################################################################
+# btrfs functions
+
+btrfs_name()
+{
+	local txt="$1"
+	local match="$2"
+
+	SUBVOL=''
+	until [[ $SUBVOL ]]; do
+		dlg SUBVOL input "Btrfs Subvolume Name" "$txt" "" || return 1
+		if [[ -z $SUBVOL ]]; then
+			return 1
+		elif [[ $SUBVOL =~ \ |\' || $match == *"$SUBVOL"* || $SUBVOL == "$MVOL" ]]; then
+			msg "Btrfs Subvolume Name Error" "$_btrfserrname"
+			SUBVOL=''
+		fi
+	done
+	return 0
+}
+
+btrfs_subvols()
+{
+	local mntp="$1"
+	local part="$2"
+	local list=""
+	local n=1
+	local txt="\nEnter a name for the initial subvolume.\n\nOnce mounted other subvolumes created for"
+
+	MVOL=""
+	btrfs_name "$txt ${mntp:-/} will branch from it." "" || return 1
+	MVOL="$SUBVOL"
+	[[ -z $mntp ]] && BTRFS_MNT="rootflags=subvol=$MVOL"
+
+	# create the main subvolume
+	mkdir -p "${MNT}$mntpt" || return 1
+	cd "${MNT}$mntp" || return 1
+	btrfs subvolume create $MVOL 2> "$ERR"
+	errshow 0 "btrfs subvolume create $MVOL" || return 1
+	cd / && umount "$part" 2> "$ERR"
+	errshow 0 "cd / && umount $part" || return 1
+	if select_mntopts 'btrfs' && [[ $MNT_OPTS ]]; then
+		mount -o ${MNT_OPTS},subvol=${MVOL} "$part" "$MNT${mntp}" 2> "$ERR"
+		errshow 0 "mount -o ${MNT_OPTS},subvol=${MVOL} $part $MNT${mntp}" || return 1
+	else
+		mount -o subvol=${MVOL} "$part" "$MNT${mntp}" 2> "$ERR"
+		errshow 0 "mount -o subvol=${MVOL} $part $MNT${mntp}" || return 1
+	fi
+	msg "Mount Complete" "\nSubvolume $MVOL mounted at $MNT${mntp}\n" 1
+
+	# create the subvolume(s)
+	cd ${MNT}$mntp || return 1
+	SUBVOL=''
+	until [[ $SUBVOL == '*' ]]; do
+		local txt="\nEnter a name for the subvolume $n to create within $MVOL."
+		txt+="\n\nThis process will be repeated until an asterisk (*) subvolume name is entered."
+		btrfs_name "$txt\n\nCreated subvolumes: ${list:-none}\n" "$list" || return 1
+		btrfs subvolume create $SUBVOL 2> "$ERR"
+		errshow 0 "btrfs subvolume create $SUBVOL" || return 1
+		(( n++ ))
+		list+="$SUBVOL "
+	done
+
+	msg "Btrfs Setup Complete" "\nBtrfs subvolumes:\n\n$(ls)"
+	cd / || return 1
+}
+
 ###############################################################################
 # lvm functions
 
@@ -2455,6 +2569,9 @@ lvm_del_all()
 			for i in $pv; do pvremove -f "$i" > /dev/null 2>&1; done
 			LVM=''
 		fi
+		for i in $(lvmdiskscan | grep 'LVM physical volume' | grep 'sd[a-z]' | sed 's/\/dev\///' | awk '{print $1}'); do
+			dd if=/dev/zero bs=512 count=512 of=/dev/${i} >/dev/null 2>&1
+		done
 	else
 		msg "Delete LVM" "\nNo available LVM to remove...\n" 2
 		LVM=''
@@ -2516,8 +2633,8 @@ lvm_group_name()
 lvm_volume_name()
 {
 	VNAME=''
-	local txt="$1" default="mainvolume"
-	(( VOL_COUNT > 1 )) && default="extvolume$VOL_COUNT"
+	local txt="$1" default="root"
+	(( VOL_COUNT > 1 )) && default="volume$VOL_COUNT"
 	until [[ $VNAME ]]; do
 		dlg VNAME input "$_lvmnew (LV:$VOL_COUNT)" "\n$txt" "$default"
 		if [[ -z $VNAME ]]; then
@@ -2804,21 +2921,24 @@ live()
 usage()
 {
 	cat <<- EOF
-	usage: $1 [-hdl] [session]
+	usage: $1 [-hdn] [-rb DEVICE] [-l SESSION]
 
 	options:
-		-h, --help      print this message and exit
-		-l, --live      install and setup a live session
-		-d, --debug     enable xtrace and log output to $DBG
-		-t, --tearfree  install and setup drivers for nvidia or tearfree xorg configs for other vendors
-						if you experience boot issues with this option you can remove
-						    /etc/X11/xorg.conf.d/20-*.conf
+		-h		print this message and exit
+		-l		install and setup a live session
+		-d		enable xtrace and log output to $DBG
+		-n		no partitioning, mounting, or formatting (self mount)
+		-r		root partition to use for install, required when using -n
+		-b		boot partition to use for install, required on UEFI systems when using -n
+		-t		install and setup drivers for nvidia or tearfree xorg configs for other vendors
+				if you experience boot issues with this option you can remove /etc/X11/xorg.conf.d/20-*.conf
 
 	sessions:
 		i3-gaps  - A fork of i3wm with more features including gaps
 		openbox  - A lightweight, powerful, and highly configurable stacking wm
 		dwm      - A dynamic WM for X that manages windows in tiled, floating, or monocle layouts
 		awesome  - A customized Awesome WM session created by @elanapan
+		lxqt     - A port of the lightweight desktop environment (LXDE) to Qt
 		bspwm    - A tiling wm that represents windows as the leaves of a binary tree
 		fluxbox  - A lightweight and highly-configurable window manager
 		jwm      - A lightweight window manager for Xorg written in C
@@ -3147,7 +3267,7 @@ if [[ $NOMOUNT ]]; then
 	fi
 	if [[ $BOOT ]]; then
 		part_bootdev
-		SEP_BOOT=true
+		[[ $BOOT != "$ROOT" ]] && SEP_BOOT=true
 	fi
 fi