diff --git a/README.en.md b/README.en.md index d896bdb..17a2d0e 100644 --- a/README.en.md +++ b/README.en.md @@ -163,7 +163,7 @@ bash reinstall.sh centos 9 > When installing Debian / Kali, x86 architectures can monitor the installation progress through VNC in the background, while ARM architectures can use the serial console. > > When installing other systems, can monitor the progress through various methods (SSH, HTTP 80 port, VNC in the background, serial console). ->
Even if errors occur during the installation process, you can still install to Alpine via SSH by running `xda=drive_name /trans.sh alpine` +>
Even if errors occur during the installation process, you can still install to Alpine via SSH by running `/trans.sh alpine`
@@ -217,7 +217,7 @@ bash reinstall.sh dd --img https://example.com/xxx.xz > [!TIP] > Can monitor the progress through various methods (SSH, HTTP 80 port, VNC in the background, serial console). ->
Even if errors occur during the installation process, you can still install to Alpine via SSH by running `xda=drive_name /trans.sh alpine` +>
Even if errors occur during the installation process, you can still install to Alpine via SSH by running `/trans.sh alpine` ### Feature 3: Reboot to Alpine Rescue System (Live OS) diff --git a/README.md b/README.md index 288b1ec..aff2818 100644 --- a/README.md +++ b/README.md @@ -163,7 +163,7 @@ bash reinstall.sh centos 9 > 安装 Debian / Kali 时,x86 可通过后台 VNC 查看安装进度,ARM 可通过串行控制台查看安装进度。 > > 安装其它系统时,可通过多种方式(SSH、HTTP 80 端口、后台 VNC、串行控制台)查看安装进度。 ->
即使安装过程出错,也能通过 SSH 运行 `xda=硬盘名 /trans.sh alpine` 安装到 Alpine。 +>
即使安装过程出错,也能通过 SSH 运行 `/trans.sh alpine` 安装到 Alpine。
@@ -217,7 +217,7 @@ bash reinstall.sh dd --img https://example.com/xxx.xz > [!TIP] > 可通过多种方式(SSH、HTTP 80 端口、后台 VNC、串行控制台)查看安装进度。 ->
即使安装过程出错,也能通过 SSH 运行 `xda=硬盘名 /trans.sh alpine` 安装到 Alpine。 +>
即使安装过程出错,也能通过 SSH 运行 `/trans.sh alpine` 安装到 Alpine。 ### 功能 3: 重启到 Alpine Live OS(救援系统) diff --git a/trans.sh b/trans.sh index 63eb2f0..b2e12fa 100644 --- a/trans.sh +++ b/trans.sh @@ -284,6 +284,14 @@ get_ttys() { } find_xda() { + # 出错后再运行脚本,硬盘可能已经格式化,之前记录的分区表 id 无效 + # 因此找到 xda 后要保存 xda 到 /config/xda + + # 先读取之前保存的 + if xda=$(get_config xda 2>/dev/null) && [ -n "$xda" ]; then + return + fi + # 防止 $main_disk 为空 if [ -z "$main_disk" ]; then error_and_exit "cmdline main_disk is empty." @@ -316,7 +324,9 @@ find_xda() { xda=$(lsblk --nodeps -rno NAME,PTUUID | grep -iw "$main_disk" | awk '{print $1}') fi - if [ -z "$xda" ]; then + if [ -n "$xda" ]; then + set_config xda "$xda" + else error_and_exit "Could not find xda: $main_disk" fi @@ -478,6 +488,10 @@ get_config() { cat "/configs/$1" } +set_config() { + printf '%s' "$2" >"/configs/$1" +} + get_password_linux_sha512() { get_config password-linux-sha512 }