core: 修改主硬盘查找逻辑

排除只读盘,vda 放前面
This commit is contained in:
bin456789
2023-10-08 21:46:45 +08:00
parent 455c3b33f9
commit 67a2bee31c
3 changed files with 48 additions and 6 deletions

View File

@ -155,6 +155,19 @@ get_ttys() {
wget $confhome/ttys.sh -O- | sh -s $prefix
}
get_xda() {
# 排除只读盘vda 放前面
# 有的机器有sda和vdavda是主硬盘另一个盘是只读
for _xda in vda xda sda hda xvda nvme0n1; do
if [ -e "/sys/class/block/$_xda/ro" ] &&
[ "$(cat /sys/class/block/$_xda/ro)" = 0 ]; then
echo $_xda
return
fi
done
return 1
}
setup_tty_and_log() {
cat <<EOF >/reinstall.html
<!DOCTYPE html>
@ -1619,8 +1632,8 @@ clear_previous
add_community_repo
# 找到主硬盘
# shellcheck disable=SC2010
xda=$(ls /dev/ | grep -Ex 'sda|hda|xda|vda|xvda|nvme0n1')
xda=$(get_xda)
if [ "$distro" != "alpine" ]; then
setup_nginx_if_enough_ram
fi