how to boot QEMU from a cloned USB stick
0
votes
1
answer
791
views
Configuration:
- MacOS arm64 M1 Apple Silicon as host
- Live USB with Ubuntu 20.04 amd64 within a squashfs filesystem as guest
- QEMU emulator on the host OS
I want to strip the OS out the squashfs and boot it on a emulated amd64 virtual machine on my mac.
I managed to extract the Ubuntu OS. I mounted the squashfs an copied the content into an img file I created using dd. I copied the image on the mac but when I try to boot the VM says "No bootable device".
Here are the commands I used, from a supporting Linux virtual machine
mount -t squashfs -o loop /path/to/filesystem.squashfs /sqshfs/mount/point
I created an empty image and made an ext4 fs
dd if=/dev/zeroes of=image.img bs=1M count=15000
mkfs.ext4 image.img
mounted it and copied the files
mount -t auto image.img /img/mount/point
cp -r /sqshfs/mount/point/* /img/mount/point
now on the image I have this folders
total 112
drwxr-xr-x 2 root root 4096 Jan 10 02:37 bin
drwxr-xr-x 3 root root 4096 Jan 10 02:37 boot
drwxr-xr-x 4 root root 4096 Jan 10 02:37 dev
drwxr-xr-x 147 root root 12288 Jan 10 02:37 etc
drwxr-xr-x 3 root root 4096 Jan 10 02:37 home
lrwxrwxrwx 1 root root 33 Jan 10 02:37 initrd.img -> boot/initrd.img-5.4.0-150-generic
lrwxrwxrwx 1 root root 33 Jan 10 02:37 initrd.img.old -> boot/initrd.img-5.4.0-148-generic
drwxr-xr-x 23 root root 4096 Jan 10 02:37 lib
drwxr-xr-x 2 root root 4096 Jan 10 02:37 lib64
drwx------ 2 root root 16384 Jan 10 02:36 lost+found
drwxr-xr-x 2 root root 4096 Jan 10 02:37 media
drwxr-xr-x 2 root root 4096 Jan 10 02:37 mnt
drwxr-xr-x 5 root root 4096 Jan 10 02:37 opt
drwxr-xr-x 2 root root 4096 Jan 10 02:37 proc
drwx------ 3 root root 4096 Jan 10 02:37 root
drwxr-xr-x 2 root root 4096 Jan 10 02:37 run
drwxr-xr-x 2 root root 12288 Jan 10 02:37 sbin
drwxr-xr-x 2 root root 4096 Jan 10 02:37 snap
drwxr-xr-x 2 root root 4096 Jan 10 02:37 srv
drwxr-xr-x 2 root root 4096 Jan 10 02:37 sys
drwxr-xr-t 2 root root 4096 Jan 10 02:37 tmp
drwxr-xr-x 11 root root 4096 Jan 10 02:38 usr
drwxr-xr-x 15 root root 4096 Jan 10 02:38 var
lrwxrwxrwx 1 root root 30 Jan 10 02:38 vmlinuz -> boot/vmlinuz-5.4.0-150-generic
lrwxrwxrwx 1 root root 30 Jan 10 02:38 vmlinuz.old -> boot/vmlinuz-5.4.0-148-generic
converted the img in qcow2
qemu-img convert -f raw -O qcow2 -c image.img image.qcow2
and configured QEMU as follows
qemu-system-x86_64 \
-name TEST \
-cpu qemu64-v1 \
-smp cpus=4,sockets=1,cores=4,threads=1 \
-machine pc-q35-7.2,vmport=off,i8042=off,hpet=off \
-accel tcg,thread=multi,tb-size=1024 \
-m 4096 \
-drive file=/Users/steve/VMs/image.qcow2 \
-boot menu=on
When I try to boot the VM says "No bootable device".
I'm very new abt QEMU and I know this configuration miss something but it should at least try to boot the kernel. GUID?
Asked by Steve-no-Jobs
(33 rep)
Jan 10, 2024, 03:23 AM
Last activity: Jan 10, 2024, 06:48 AM
Last activity: Jan 10, 2024, 06:48 AM