mirror of
https://github.com/bin456789/reinstall.git
synced 2025-01-19 04:49:13 +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
|
%include /tmp/include-url-command
|
||||||
|
|
||||||
# 分区
|
# 分区
|
||||||
ignoredisk --only-use="sda|hda|xda|vda|xvda|nvme0n1"
|
%include /tmp/include-disk-only-use
|
||||||
%include /tmp/include-bootloader
|
%include /tmp/include-bootloader
|
||||||
clearpart --all --initlabel
|
clearpart --all --initlabel
|
||||||
reqpart # 如果需要,自动创建 efi 或 biosboot 分区
|
reqpart # 如果需要,自动创建 efi 或 biosboot 分区
|
||||||
@ -34,6 +34,19 @@ selinux --disabled
|
|||||||
|
|
||||||
##############################################
|
##############################################
|
||||||
%pre
|
%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)
|
distro=$(awk -F: '{ print $3 }' </etc/system-release-cpe)
|
||||||
releasever=$(awk -F: '{ print $5 }' </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'/")"
|
eval "$(echo $var | sed -E "s/$prefix\.([^=]*)=(.*)/\1='\2'/")"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# 只使用主硬盘
|
||||||
|
include=/tmp/include-disk-only-use
|
||||||
|
echo "ignoredisk --only-use=$(get_xda)" >$include
|
||||||
|
|
||||||
# 设置 tty
|
# 设置 tty
|
||||||
include=/tmp/include-bootloader
|
include=/tmp/include-bootloader
|
||||||
console_cmdline=$(wget $confhome/ttys.sh -O- | sh -s console=)
|
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
|
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() {
|
setup_tty_and_log() {
|
||||||
cat <<EOF >/reinstall.html
|
cat <<EOF >/reinstall.html
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@ -1619,8 +1632,8 @@ clear_previous
|
|||||||
add_community_repo
|
add_community_repo
|
||||||
|
|
||||||
# 找到主硬盘
|
# 找到主硬盘
|
||||||
# shellcheck disable=SC2010
|
xda=$(get_xda)
|
||||||
xda=$(ls /dev/ | grep -Ex 'sda|hda|xda|vda|xvda|nvme0n1')
|
|
||||||
if [ "$distro" != "alpine" ]; then
|
if [ "$distro" != "alpine" ]; then
|
||||||
setup_nginx_if_enough_ram
|
setup_nginx_if_enough_ram
|
||||||
fi
|
fi
|
||||||
|
@ -1,4 +1,18 @@
|
|||||||
#!/bin/bash
|
#!/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
|
sed -i -E '/^\.{3}$/d' /autoinstall.yaml
|
||||||
echo 'storage:' >>/autoinstall.yaml
|
echo 'storage:' >>/autoinstall.yaml
|
||||||
|
|
||||||
@ -8,9 +22,7 @@ cat <<EOF >>/autoinstall.yaml
|
|||||||
size: 0
|
size: 0
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# xda=$(lsblk -dn -o NAME | grep -E 'nvme0n1|.da')
|
xda=$(get_xda)
|
||||||
# shellcheck disable=SC2010
|
|
||||||
xda=$(ls /dev/ | grep -Ex 'sda|hda|xda|vda|xvda|nvme0n1')
|
|
||||||
# 是用 size 寻找分区,number 没什么用
|
# 是用 size 寻找分区,number 没什么用
|
||||||
# https://curtin.readthedocs.io/en/latest/topics/storage.html
|
# https://curtin.readthedocs.io/en/latest/topics/storage.html
|
||||||
size_os=$(lsblk -bn -o SIZE /dev/disk/by-label/os)
|
size_os=$(lsblk -bn -o SIZE /dev/disk/by-label/os)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user