xref: /DragonOS/tools/create_hdd_image.sh (revision fb6c29d01d4cf92368efec08c01e419c2a941f7d)
1echo "Creating virtual disk image..."
2
3# 创建一至少为32MB磁盘镜像(类型选择raw)
4qemu-img create -f raw disk.img 32M
5
6# 使用fdisk把disk.img的分区表设置为MBR格式(下方的空行请勿删除)
7fdisk disk.img << EOF
8o
9n
10
11
12
13
14w
15EOF
16
17LOOP_DEVICE=$(sudo losetup -f --show -P disk.img) \
18    || exit 1
19echo ${LOOP_DEVICE}p1
20sudo mkfs.vfat -F 32 ${LOOP_DEVICE}p1
21sudo losetup -d ${LOOP_DEVICE}
22
23echo "Successfully created disk image."
24mkdir -p ../bin
25mv ./disk.img ../bin/
26