Skip to main content

4️⃣ Mounting an SD Card to VM and Writing a Disk Image

To mount an SD card to a VirtualBox VM, and then write a disk image to it, please follow these general steps.


Step 1: Mount SD Card to Host

Insert the SD card into the SD card reader or USB card reader and connect it to your Windows 11 machine.

Open File Explorer and check which drive letter corresponds to your SD card. For example, it might be something like D: or E:.

Important

Please ensure that the type of the file system that is used by the SD card is NTFS, as the FAT32 file system has a 4GB file size limit which would cause problems when we are writing a large image file into it.

Step 2: Add SD Card as a VirtualBox USB Device

To allow your guest VM to access the SD card, you'll need to connect it as a USB device within VirtualBox.

Please power off the VM if it is running.

usb_setting

In VirtualBox, click on Settings > go to USB section > enable USB Controller > click Add USB Device. Then, select your SD Card (it should appear as a USB device, e.g. "SD Card Reader").

tip

If the USB device is not detected in the VM or there is an error, try switching the USB Controllers (USB 2.0 or USB 3.0) and restart the VM.

Step 3: Check Mount Status of SD Card in VM

To check if the SD Card is recognized, open a terminal in the Linux guest.

Run the following command to list available disks:

lsblk

You should see the SD card listed as something like /dev/sdb or /dev/sdc (depending on your system configuration). Make a note of the device name.

Step 4: Write a Disk Image to the SD Card

Now, you can write a disk image (e.g., .img file) to the SD card.

Go to the directory where your image file is located and use the command below to write it to the SD card.

sudo bmaptool copy your_image.img /dev/sdb
Troubleshooting

You might encounter an error saying that bmaptool is not installed. Please use these commands below to install it.

sudo apt update && sudo apt upgrade -y # update package manager
sudo apt install bmap-tools # installing bmaptool
bmaptool --version # check if it is installed successfully

If there is a device busy error, please unmount /dev/sdb1 and try again.

umount /dev/sdb1

Step 5: Unmount the SD Card

After writing the disk image, the SD card will be unmounted automatically. You can also unmount the SD card by running:

sudo umount /dev/sdb

Then, shutdown the VM and safely remove the SD card from the host.