core: nbd 连接和断开后要 sleep 几秒
This commit is contained in:
parent
84f9c30489
commit
f62c5ee1c6
17
trans.sh
17
trans.sh
@ -172,11 +172,16 @@ EOF
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qemu_nbd() {
|
||||||
|
command qemu-nbd "$@"
|
||||||
|
sleep 5
|
||||||
|
}
|
||||||
|
|
||||||
# 可能脚本不是首次运行,先清理之前的残留
|
# 可能脚本不是首次运行,先清理之前的残留
|
||||||
clear_previous() {
|
clear_previous() {
|
||||||
{
|
{
|
||||||
# TODO: fuser and kill
|
# TODO: fuser and kill
|
||||||
qemu-nbd -d /dev/nbd0
|
qemu_nbd -d /dev/nbd0
|
||||||
swapoff -a
|
swapoff -a
|
||||||
# alpine 自带的umount没有-R,除非安装了util-linux
|
# alpine 自带的umount没有-R,除非安装了util-linux
|
||||||
umount -R /iso /wim /installer /os/installer /os /nbd /nbd-boot /nbd-efi
|
umount -R /iso /wim /installer /os/installer /os /nbd /nbd-boot /nbd-efi
|
||||||
@ -501,8 +506,7 @@ install_cloud_image() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
modprobe nbd
|
modprobe nbd
|
||||||
qemu-nbd -c /dev/nbd0 $qcow_file
|
qemu_nbd -c /dev/nbd0 $qcow_file
|
||||||
sleep 5
|
|
||||||
|
|
||||||
os_part=$(lsblk /dev/nbd0p*[0-9] --sort SIZE -no NAME,FSTYPE | grep xfs | tail -1 | cut -d' ' -f1)
|
os_part=$(lsblk /dev/nbd0p*[0-9] --sort SIZE -no NAME,FSTYPE | grep xfs | tail -1 | cut -d' ' -f1)
|
||||||
efi_part=$(lsblk /dev/nbd0p*[0-9] --sort SIZE -no NAME,FSTYPE | grep fat | tail -1 | cut -d' ' -f1)
|
efi_part=$(lsblk /dev/nbd0p*[0-9] --sort SIZE -no NAME,FSTYPE | grep fat | tail -1 | cut -d' ' -f1)
|
||||||
@ -559,8 +563,7 @@ install_cloud_image() {
|
|||||||
|
|
||||||
# 取消挂载 nbd
|
# 取消挂载 nbd
|
||||||
umount /nbd/ /nbd-boot/ /nbd-efi/ || true
|
umount /nbd/ /nbd-boot/ /nbd-efi/ || true
|
||||||
qemu-nbd -d /dev/nbd0
|
qemu_nbd -d /dev/nbd0
|
||||||
sleep 5
|
|
||||||
|
|
||||||
# 创建 swap
|
# 创建 swap
|
||||||
rm -rf /installer/*
|
rm -rf /installer/*
|
||||||
@ -666,7 +669,7 @@ EOF
|
|||||||
# debian ubuntu arch
|
# debian ubuntu arch
|
||||||
if true; then
|
if true; then
|
||||||
modprobe nbd
|
modprobe nbd
|
||||||
qemu-nbd -c /dev/nbd0 $qcow_file
|
qemu_nbd -c /dev/nbd0 $qcow_file
|
||||||
|
|
||||||
# 将前1M dd到内存
|
# 将前1M dd到内存
|
||||||
dd if=/dev/nbd0 of=/first-1M bs=1M count=1
|
dd if=/dev/nbd0 of=/first-1M bs=1M count=1
|
||||||
@ -690,7 +693,7 @@ EOF
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
qemu-nbd -d /dev/nbd0
|
qemu_nbd -d /dev/nbd0
|
||||||
else
|
else
|
||||||
# 将前1M dd到内存,将1M之后 dd到硬盘
|
# 将前1M dd到内存,将1M之后 dd到硬盘
|
||||||
qemu-img dd if=$qcow_file of=/first-1M bs=1M count=1
|
qemu-img dd if=$qcow_file of=/first-1M bs=1M count=1
|
||||||
|
Loading…
Reference in New Issue
Block a user