|
From: | ckim |
Subject: | how can I attach a disk to a virtual machine? |
Date: | Tue, 13 Apr 2021 21:02:41 +0900 |
Hello, qemu experts, What is the method of attaching disk image to a virtual machine? I want to attach disk image to the virtual machine, and it would be best if I can make it seem like a disk partition /dev/sda1, or like a disk(/dev/sda) with a couple of partitions(/dev/sda1, /dev/sda2,..) I made disk image like this. qemu-img create myimage.img 10G and I ran qemu with this command. qemu-system-aarch64 -M virt -cpu cortex-a72 -kernel ${LINUX_DIR}/arch/arm64/boot/Image -initrd initramfs.cpio.gz --append "root=/dev/ram init=/init nokaslr" -m 2048M -nographic -drive if=none,file=myimage.img,id=disk1 -device virtio-blk-device,drive=disk1 In the initrd image(before cpio’ed and compresed to initramfs.cpio.gz above), I made device files like this. mkdir -p dev sudo mknod dev/console c 5 1 sudo mknod dev/ram b 1 0 and the init script contains below lines. #!/bin/sh echo "### INIT SCRIPT ###" mkdir /proc /sys /tmp mount -t proc none /proc mount -t sysfs none /sys mount -t tmpfs none /tmp echo -e "\nThis boot took $(cut -d' ' -f1 /proc/uptime) seconds\n" exec /bin/sh but after linux boots and in the bash shell, I don’t know how to use the disk1. I checked the disk image document, but it describes all the various types but not how to use it inside linux. How can I use disk1 above? A point to a kind document will also be appreciated. Thank you! Chan Kim |
[Prev in Thread] | Current Thread | [Next in Thread] |