DragonOS/tools/create_hdd_image.sh
2022-07-22 15:21:30 +08:00

26 lines
491 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

echo "Creating virtual disk image..."
# 创建一至少为16MB磁盘镜像类型选择raw
qemu-img create -f raw disk.img 16M
# 使用fdisk把disk.img的分区表设置为MBR格式(下方的空行请勿删除)
fdisk disk.img << EOF
o
n
w
EOF
LOOP_DEVICE=$(sudo losetup -f --show -P disk.img) \
|| exit 1
echo ${LOOP_DEVICE}p1
sudo mkfs.vfat -F 32 ${LOOP_DEVICE}p1
sudo losetup -d ${LOOP_DEVICE}
echo "Successfully created disk image."
mkdir -p ../bin
mv ./disk.img ../bin/