From 84f9c3048987f02fda74fe46cd9548ef96d5937a Mon Sep 17 00:00:00 2001 From: bin456789 Date: Tue, 1 Aug 2023 21:39:53 +0800 Subject: [PATCH] =?UTF-8?q?core:=20=E6=94=BE=E7=BD=AE=20ci=20=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=97=B6=EF=BC=8C=E5=87=86=E7=A1=AE=E5=AF=BB=E6=89=BE?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E5=88=86=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/trans.sh b/trans.sh index 60359db..6a87fca 100644 --- a/trans.sh +++ b/trans.sh @@ -414,15 +414,25 @@ mount_pseudo_fs() { download_cloud_init_config() { if ! mount | grep -w 'on /os type'; then - # 找到系统分区,也就是最大的分区 apk add lsblk mkdir -p /os - os_part=$(lsblk /dev/$xda --sort SIZE -o NAME | sed '$d' | tail -1) - mount /dev/$os_part /os + # 按分区容量大到小,依次寻找系统分区 + for part in $(lsblk /dev/$xda --sort SIZE -no NAME | sed '$d' | tac); do + # btrfs挂载的是默认子卷,如果没有默认子卷,挂载的是根目录 + # fedora 云镜像没有默认子卷,且系统在root子卷中 + if mount /dev/$part /os; then + if etc_dir=$({ ls -d /os/etc || ls -d /os/*/etc; } 2>/dev/null); then + break + fi + umount /os + fi + done + fi + + if [ -z "$etc_dir" ]; then + error_and_exit "can't find os partition" fi - # btrfs 系统可能不在根目录,例如 fedora 系统在 root 子卷中 - etc_dir=$(ls -d /os/etc || ls -d /os/*/etc) ci_file=$etc_dir/cloud/cloud.cfg.d/99_nocloud.cfg # shellcheck disable=SC2154