Create a bootable flash image

Installing Linux onto a Flash card can be painfully slow. The way to work around this is to install into a VM and write the VM image to the Flash.

Step 1: Create the properly sized Flash image. To do this, just copy the existing data onto your hard disk. Assuming your flash comes to /dev/sdj
dd if=/dev/sdj of=myimage.img

Step 2: Use virt-manager to create a virtual machine. Instead of creating new storage, install into the myimage.img file. Follow the steps just as you would with any virtual machine.

Step 3: Install and configure your virtual machine Use the ext2 file system for "/" because it will be made readonly later and there is no point to having a journaling file system on a read-only medium. Don't allocate a swap file, because it is pointless.

Step 4: Shutdown and poweroff virtual machine.

Step 5: Mount image locally to do file level manipulation
run parted as:
parted myimage.img unit b print
Model: (file)
Disk /vol01/myimage.img: 4017807360B
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
1 1048576B 3782213631B 3781165056B primary ext4 boot
Make a mount directory:
mkdir flash

Mount using loopback and offset:
mount myimage.img flash -o loop,offset=1048576

Step 6: Make root directory read only. Edit /etc/fstab, change "defaults" to "ro" for the mount of "/" and add two ram disks.
tmpfs /tmp tmpfs size=10M,mode=0777 0 0
tmpfs /var/log tmpfs size=10M,mode=0777 0 1

Step 7: Unmount flash directory
umount flash

Step 8: Copy image to flash unit (this will take some time)
dd if=myimage.img of=/dev/sdj

Step 9: try to boot. I'm not sure how much help you can get at this point. It depends on a lot of variables, it should work. "It works for me" is the best that can be said.

Step 10: Maintenance
All maintenance should be done in the virtual machine. A flash can be updated by mounting the VM as above and mounting the flash drive normally. Use cp or rsync to only copy new or modified files from the VM onto the mounted flash drive.