core: 使用 get-xda.sh 寻找主硬盘

This commit is contained in:
bin456789
2024-02-02 00:31:21 +08:00
parent 5150feddc6
commit 5d3227fe64
5 changed files with 50 additions and 46 deletions

View File

@@ -1,24 +1,4 @@
#!/bin/bash
get_all_disks() {
lsblk -rn --nodeps -o NAME,TYPE | grep 'disk$' | awk '{print $1}'
}
get_xda() {
# 防止 $main_disk 为空
if [ -z "$main_disk" ]; then
return
fi
for disk in $(get_all_disks); do
# shellcheck disable=SC2154
if fdisk -l "/dev/$disk" | grep -iq "$main_disk"; then
echo "$disk"
break
fi
done
}
sed -i -E '/^\.{3}$/d' /autoinstall.yaml
echo 'storage:' >>/autoinstall.yaml
@@ -28,12 +8,11 @@ cat <<EOF >>/autoinstall.yaml
size: 0
EOF
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)
# shellcheck disable=SC2154
if parted "/dev/$xda" print | grep '^Partition Table' | grep gpt; then
# efi
if [ -e /dev/disk/by-label/efi ]; then