[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how can I attach a disk to a virtual machine?
From: |
Narcis Garcia |
Subject: |
Re: how can I attach a disk to a virtual machine? |
Date: |
Tue, 13 Apr 2021 14:18:22 +0200 |
On most cases, it's better like a physical block device (/dev/sda)
instead of a single partition.
Narcis Garcia
__________
I'm using this dedicated address because personal addresses aren't
masked enough at this mail public archive. Public archive administrator
should fix this against automated addresses collectors.
El 13/4/21 a les 14:02, ckim@etri.re.kr ha escrit:
> 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
>
>
>