How to mount micro SD card to flash OS image?

I need to flash a Debian image to a micro SD card to use with a Raspberry Pi.

The micro SD Card (MSDC) I will use (16GB) already has Raspberry Pi OS flashed, and when I plug the MSDC into my laptop (dedicated MSD reader port), Qubes OS reports 3 Data (block) devices available.

There is

dom0: mmcblk0 - ()           14.8 GiB
dom0: mmcblk0p1 - (boot)    256.0 MiB
dom0: mmcblk0p2 - (rootfs)    3.3 GiB

When I attach boot and rootfs to a StandaloneVM, the output of sudo fdisk -l shows them mounted as /dev/xvdi and /dev/xvdj (attaching () is mounted as xvdi too).

I don’t know enough about writing OS images nor how Qubes deals with block devices and MSDC to know what exactly I have to attach and/or overwrite to put a new OS image on this MSDC.

I assume that p1 and p2 in the Qubes Devices are partitions. Also, when I attach boot or rootfs to any VM, then the () device is removed. Attaching () to any VM makes boot and rootfs unavailable.

Should I work with the () device and overwrite that, since it seems to represent almost all the MSDC? I don’t want to mess up some partitioning system and make more problems for recognizing the MSDC.

You can just do everything in the sys-usb without attaching the stick to other VMs. In this case everything should work like on regular Linux.

I can’t seem to find the MSDC in sys-usb. Do non-usb devices like micro SD cards appear in sys-usb? Running sudo fdisk -l doesn’t show the MSDC, and there’s no /dev/xvdi or the like.

I might try overwriting the () device and see if that works.

Edit: it seems that attaching () to a VM also attaches the boot and rootfs partitions to that VM, which may be why those partitions disappear from dom0.

Hi @qubes-kernel-5.8,

Yes this is the good way.

mmcblk0 is your disk (micro SD disk), which contains two partitions as you already understood (p1 and p2).
lsblk will list all the disks (and so the attached mmcblk0) and the partitions. This command shows all the block devices, with an understandable tree.

Then you will use the standard flash commands used on all other Gnu/Linux OSes (dd ... if=my.iso of=/dev/mmcblk0 ..., cp my.iso /dev/mmcblk0, cat ..., …).

2 Likes

A mistake above, of course replace /dev/mmcblk0 with the device in the VM (example: /dev/xvdi).

1 Like