mirror of
https://github.com/bin456789/reinstall.git
synced 2025-01-18 20:39:14 +08:00
core: 修改主硬盘查找逻辑
排除只读盘,vda 放前面
This commit is contained in:
parent
455c3b33f9
commit
67a2bee31c
19
redhat.cfg
19
redhat.cfg
@ -9,7 +9,7 @@ reboot
|
||||
%include /tmp/include-url-command
|
||||
|
||||
# 分区
|
||||
ignoredisk --only-use="sda|hda|xda|vda|xvda|nvme0n1"
|
||||
%include /tmp/include-disk-only-use
|
||||
%include /tmp/include-bootloader
|
||||
clearpart --all --initlabel
|
||||
reqpart # 如果需要,自动创建 efi 或 biosboot 分区
|
||||
@ -34,6 +34,19 @@ selinux --disabled
|
||||
|
||||
##############################################
|
||||
%pre
|
||||
get_xda() {
|
||||
# 排除只读盘,vda 放前面
|
||||
# 有的机器有sda和vda,vda是主硬盘,另一个盘是只读
|
||||
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
|
||||
}
|
||||
|
||||
distro=$(awk -F: '{ print $3 }' </etc/system-release-cpe)
|
||||
releasever=$(awk -F: '{ print $5 }' </etc/system-release-cpe)
|
||||
|
||||
@ -44,6 +57,10 @@ for var in $(grep -o "\b$prefix\.[^ ]*" /proc/cmdline | xargs); do
|
||||
eval "$(echo $var | sed -E "s/$prefix\.([^=]*)=(.*)/\1='\2'/")"
|
||||
done
|
||||
|
||||
# 只使用主硬盘
|
||||
include=/tmp/include-disk-only-use
|
||||
echo "ignoredisk --only-use=$(get_xda)" >$include
|
||||
|
||||
# 设置 tty
|
||||
include=/tmp/include-bootloader
|
||||
console_cmdline=$(wget $confhome/ttys.sh -O- | sh -s console=)
|
||||
|
17
trans.sh
17
trans.sh
@ -155,6 +155,19 @@ get_ttys() {
|
||||
wget $confhome/ttys.sh -O- | sh -s $prefix
|
||||
}
|
||||
|
||||
get_xda() {
|
||||
# 排除只读盘,vda 放前面
|
||||
# 有的机器有sda和vda,vda是主硬盘,另一个盘是只读
|
||||
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
|
||||
|
@ -1,4 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
get_xda() {
|
||||
# 排除只读盘,vda 放前面
|
||||
# 有的机器有sda和vda,vda是主硬盘,另一个盘是只读
|
||||
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
|
||||
}
|
||||
|
||||
sed -i -E '/^\.{3}$/d' /autoinstall.yaml
|
||||
echo 'storage:' >>/autoinstall.yaml
|
||||
|
||||
@ -8,9 +22,7 @@ cat <<EOF >>/autoinstall.yaml
|
||||
size: 0
|
||||
EOF
|
||||
|
||||
# xda=$(lsblk -dn -o NAME | grep -E 'nvme0n1|.da')
|
||||
# shellcheck disable=SC2010
|
||||
xda=$(ls /dev/ | grep -Ex 'sda|hda|xda|vda|xvda|nvme0n1')
|
||||
xda=$(get_xda)
|
||||
# 是用 size 寻找分区,number 没什么用
|
||||
# https://curtin.readthedocs.io/en/latest/topics/storage.html
|
||||
size_os=$(lsblk -bn -o SIZE /dev/disk/by-label/os)
|
||||
|
Loading…
x
Reference in New Issue
Block a user