From 2408ae18363b1968bea80ee1b3b4e3fa3ff49b45 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Tue, 1 Aug 2023 22:13:45 +0800 Subject: [PATCH] =?UTF-8?q?core:=20=E6=8A=8A=E9=87=8D=E8=A3=85=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=94=BE=E5=88=B0=20btrfs=20=E6=A0=B9=E7=9B=AE?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.sh | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index d19fa5b..67149ca 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -80,12 +80,23 @@ is_os_in_btrfs() { mount | grep -w 'on / type btrfs' } -get_os_subvol_in_btrfs() { - subvol=$(awk '{ if ($2=="/") print $i }' /proc/mounts | grep -o 'subvol=[^ ]*' | cut -d= -f2) - if [ "$subvol" = / ]; then - subvol= +is_os_in_subvol() { + subvol=$(awk '($2=="/") { print $i }' /proc/mounts | grep -o 'subvol=[^ ]*' | cut -d= -f2) + [ "$subvol" != / ] +} + +get_os_part() { + awk '($2=="/") { print $1 }' /proc/mounts +} + +cp_to_btrfs_root() { + files=$* + mount_dir=/tmp/reinstall-btrfs-root + if ! grep -q $mount_dir /proc/mounts; then + mkdir -p $mount_dir + mount "$(get_os_part)" $mount_dir -t btrfs -o subvol=/ fi - echo $subvol + cp -rf $files /tmp/reinstall-btrfs-root } is_host_has_ipv4_and_ipv6() { @@ -924,16 +935,15 @@ 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 <