Mandriva Flash is a complete Linux distribution on a bootable USB key, useful for so many things I don’t understand why it’s not a part of everyone’s tool box. It combines the portability of a live CD with the flexibility of a hard drive installation. Here’s how to get the most from your Flash key.
IMAGE BEFORE BEGINNING
Upon first receiving your Flash key, make a backup image of it for disaster recovery. Plug it into a running Linux system and, as root, dd if=/dev/sdb of=flash.img (replacing sdb with your device).
BOOT THE KEY
Reboot the computer from the Flash key. How this is done depends on your hardware:
- Modern motherboards allow the user to select the boot device during the POST by pressing (for example) F12 or F9. See the on-screen messages during the POST or consult your motherboard’s documentation. If available, this option eliminates the need to modify your BIOS or use a boot CD.
- Modern BIOSes offer USB as a boot device option. See your BIOS.
- The Flash key is shipped with a boot/rescue CD. You may boot the computer from the CD, which will continue the boot process using the Flash key. When traveling it is a good idea to bring the boot CD along with the Flash key. I burnt a copy of it to a business card sized CD so it fits in a wallet or passport pouch.
INITIAL CONFIGURATION ON FIRST BOOT
On first boot, you will be asked to provide certain information such as language and passwords for root and user. The final question, partition size, is the most important and the only thing that cannot be easily changed later. A larger partition increases the size of your root partition; a smaller partition increases the space available for use as a normal USB storage device. After much trial and error I found 3000 MB to be adequate for me; adjust for your needs.
Set up PLF repositories.
Install desired software. I keep a list of software I commonly install; to that list I also add (for assisting clients on site, remote host administration, fixing broken Windows boxes) dosfsck, klam, ntfs-3g, and ntfsprogs.
Additionally I install Crossover Office, which lets me edit the Registry of unbootable Windows boxes and bring them back to life. I used Crossover Pro generic installer, same as on my production box, but Standard RPM installer would probably be more appropriate for Flash. Although it installed without error messages, attempting to run it failed with an error message to stdout about a missing Glade module. Installing pygtk2.0-libglade resolved the problem. TODO: Document (perhaps in a new blog entry) how to use Crossover’s RegEdit on a mounted Windows box.
Tweak system as desired. Define sudoers. To fix broken Windows boxes, set up NTFS access and configure KlamAV.
Consider placing a README.txt file in the key root with your name and contact information, and replacing /usr/share/faces/USER.png with your photograph (PNG format, 32×32 pixels) to facilitate recovery if lost.
Once you have your Flash key configured as desired, make another image as described above. Unlike the first one, which can now be discarded, you will probably want to save this image permanently (mine fits nicely on a dual layer DVD) and securely stored with your other backups and recovery images.
If you use your Flash key for regular work, consider adding it to your normal backup or imaging regimen. Dodgy computers in cybercafés and Internet kiosks can corrupt your data or filesystem and even physically destroy USB keys. For this reason this or any USB key should be considered disposable and backed up.
The boot/rescue CD contains a backup script, but I find it less useful and do not use it. It backs up configuration settings and user documents, but not the entire key, so it will not work for bare metal recovery.
BACKGROUND INFORMATION, TIPS, AND TRICKS
The operating system, including all pre-installed applications, are contained in the read-only file distrib.sqfs. All modifications to it (system configuration, non-default installed applications, etc.) are stored in the writable file system.loop. If system.loop is missing, the key is restored to factory defaults and the first boot configuration is triggered to recreate it.
This implies that removing a pre-installed application does not save any space. Rather, by adding an “uninstalled” flag in system.loop, it consumes additional space. Likewise updating the system does not replace software in distrib.sqfs, it bloats system.loop. Thus uninstalling or updating software on the key should be kept to a minimum.
If the symptoms suggest a damaged filesystem, begin by trying dosfsck. Plug the stick into a running Linux box, mount it if necessary, and as root dosfsck -a /dev/sdb1, replacing sdb with your device.
To restore a backup image to the same device or a replacement of the same size, as root dd if=flash.img of=/dev/sdb (replacing flash.img with the name of your backup image and sdb with your device).
During one disaster recovery, the above command appeared to work but the key would not boot. I had to first delete the key’s existing partition and create a new one of the same type (FAT32) and size (7619 MB, leaving an empty unpartitioned space on the key). I did this on a running Mandriva Linux installation, plugging in the key and using the partition manager in the Mandriva Control Center (MCC – Local Disks – Manage Disk Partitions – sdb), although it can be performed using other distributions and tools. Once the partition had been recreated, I restored the backup image as above and all was well.
If you do not have a backup image or it is damaged, you may attempt to restore the key to its factory original state, which will necessitate repeating the “Initial configuration on first boot” section above. There are several ways to do this:
- The easy method: Boot your computer from the boot/rescue CD and follow the on-screen instructions to restore the key to its factory original state. Sometimes this does not work, in which case try one of the manual methods.
- One manual method: Plug your key into a running Linux system. From a terminal, delete the key’s system.loop(e.g rm /media/MDV_FLASH/.loopbacks/system.loop). I have successfully used this method.
- Another manual method: Plug your key into a running Linux system. From a terminal, cd into the .loopbacks directory on the key (e.g cd /media/MDV_FLASH/.loopbacks) and, as root, mkdosfs system.loop. I have not had an opportunity to test this method.
Please respect Mandriva’s right to a fair return on its products and do not use the information presented here to clone multiple copies of a single key. I encourage you to reward this company’s ongoing support of the open source community by purchasing the reasonably priced Mandriva Flash and other products. We in the open source community need to put our money where our mouths are and provide the good guys with the means to pay their bills and continue their good work.
Update 21 May 2010: I stupidly left my Mandriva Flash in my pants pockets and washed them. Despite soaking in soapy water for an hour, agitation, and the high humidity of remaining in the pocket while drying in the sun, the stick continues to work perfectly. Thank you Mandriva for using quality hardware!