From 584bd8df36dbe32a62a8808a4e849bdf7c0fdbc0 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sun, 23 Jul 2023 11:46:31 +0800 Subject: [PATCH] =?UTF-8?q?core:=20=E6=94=AF=E6=8C=81=E5=8E=9F=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E4=B8=BA=20btrfs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index 7c6d4e1..7967563 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -58,6 +58,18 @@ is_use_cloud_image() { [ -n "$cloud_image" ] && [ "$cloud_image" = 1 ] } +is_os_in_btrfs() { + mount | grep -w / | grep btrfs +} + +get_os_subvol_in_btrfs() { + subvol=$(grep -w / /proc/mounts | grep -o 'subvol=[^ ]*' | cut -d= -f2) + if [ "$subvol" = / ]; then + subvol= + fi + echo $subvol +} + is_host_has_ipv4_and_ipv6() { install_pkg dig # dig会显示cname结果,cname结果以.结尾,grep -v '\.$' 用于去除 cname 结果 @@ -871,15 +883,16 @@ fi # 生成 custom.cfg (linux) 或者 grub.cfg (win) is_in_windows && custom_cfg=/cygdrive/$c/grub.cfg || custom_cfg=$(dirname $grub_cfg)/custom.cfg +is_os_in_btrfs && subvol=$(get_os_subvol_in_btrfs) echo $custom_cfg cat <