Skip to main content

Create a flash drive image

Reference: https://superuser.com/questions/668485/creating-a-fat-file-system-and-save-it-into-a-file-in-gnu-linux

Create a blank file:
dd if=/dev/zero of=test-disk.img bs=1024 count=SIZE
# size = SIZE*bs
Format as FAT32:
mkfs.vfat test-disk.img
Mount:
sudo mkdir /mnt/test-dir
sudo mount -o loop  test-disk.img /mnt/test-dir/
Copy files:
sudo rsync -rv --ignore-existing some_directory/* /mnt/test-disk/
Unmount:
sudo umount /mnt/test-disk
sudo rmdir /mnt/test-disk
Clone to flash drive:
dd if=test-disk.img of=/dev/mmcblk0 bs=4M status=progress