浏览代码

Install to nvme: place root volume to separate subvolume when btrfs fs used

Igor Velkov 1 周之前
父节点
当前提交
810ea3eefe
共有 1 个文件被更改,包括 11 次插入1 次删除
  1. 11 1
      packages/bsp/common/usr/bin/armbian-install

+ 11 - 1
packages/bsp/common/usr/bin/armbian-install

@@ -96,7 +96,7 @@ mkopts[f2fs]='-f'
 
 
 # @TODO source these options from one source, this is mostly defined in partioning.sh
 # @TODO source these options from one source, this is mostly defined in partioning.sh
 mountopts[ext4]='defaults,noatime,commit=120,errors=remount-ro,x-gvfs-hide	0	1'
 mountopts[ext4]='defaults,noatime,commit=120,errors=remount-ro,x-gvfs-hide	0	1'
-mountopts[btrfs]='defaults,noatime,commit=120,compress=lzo,x-gvfs-hide			0	2'
+mountopts[btrfs]="defaults,commit=120,compress=lzo,x-gvfs-hide,subvol=@	0	2"
 mountopts[f2fs]='defaults,noatime,x-gvfs-hide	0	2'
 mountopts[f2fs]='defaults,noatime,x-gvfs-hide	0	2'
 
 
 # Create boot and root file system #
 # Create boot and root file system #
@@ -120,6 +120,16 @@ create_armbian()
 		[[ -n $2 ]] && ( mount -o compress-force=zlib "$2" "${TempDir}"/rootfs 2> /dev/null || mount "$2" "${TempDir}"/rootfs )
 		[[ -n $2 ]] && ( mount -o compress-force=zlib "$2" "${TempDir}"/rootfs 2> /dev/null || mount "$2" "${TempDir}"/rootfs )
 		[[ -n $1 && $1 != "mtd" ]] && mount "$1" "${TempDir}"/bootfs
 		[[ -n $1 && $1 != "mtd" ]] && mount "$1" "${TempDir}"/bootfs
 	fi
 	fi
+
+	# make separate subvolume for rootfs on btrfs
+	if [[ $eMMCFilesystemChoosen =~ ^(btrfs)$ ]]; then
+		btrfs subvolume create "${TempDir}"/rootfs/@
+		sync
+		btrfs subvolume list ${TempDir}/rootfs/ | grep 'path @$' | cut -d' ' -f2 \
+			| xargs -I{} btrfs subvolume set-default {} ${TempDir}/rootfs/
+		umount "${TempDir}"/rootfs
+		mount -o compress-force=zlib,subvol=@ "$2" "${TempDir}"/rootfs 2> /dev/null
+	fi
 	rm -rf "${TempDir}"/bootfs/* "${TempDir}"/rootfs/*
 	rm -rf "${TempDir}"/bootfs/* "${TempDir}"/rootfs/*
 
 
 	# sata root part
 	# sata root part