I’ve been using a compact SSD USB-stick for some years now. My trusty Kingston DataTraveller. A beasty performer considering it’s a glorified USB-stick. It contains a SSD controller with the flash chips so it functions just like a normal SSD. It gives me about 40-50MB/s read/write speeds. Decent for my needs.
Recently I formatted the stick and started afresh. This post gives a quick rundown of what I did to restore its glory.
First of I made a copy of my main install from my internal SSD;
$ mount /dev/sdb1 /mnt/kingston
$ cp -axr / /mnt/kingston
$ cp -axr /home /mnt/kingston
Remember to use -x to only copy from the locale mount and not other mounted filesystems. -a for archive; preserving attributes, recursive and no de-referencing.
Sometimes you get this gnarly error when trying to install GRUB;
Installing for i386-pc platform.
grub-install: warning: Attempting to install GRUB to a disk with multiple partition labels. This is not supported yet..
grub-install: warning: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and their use is discouraged..
grub-install: error: will not proceed with blocklists.
Therefore next clear what could be left of GPT or similar on the USB-stick. Making room for GRUB and insuring grub-install works its wonders.
$ parted /dev/sdb
$ mkpart primary ext4 0MiB 1MiB
$ quit
Then, zero the newly created partition.
$ dd if=/dev/zero of=/dev/sdb2
Then, delete the partition.
$ parted /dev/sdb
$ rm 2
$ quit
grub-install should now be able to do what it does.
$ grub-install target=i386-pc /dev/sdb
$ grub-mkconfig -o /mnt/kingston/boot/grub/grub.cfg
Verify the generated grub.cfg. And voilá. We’re done. You should be able to boot from the USB-stick now. Remember to use the UUID of the sdb1 partition in your /etc/fstab on the USB-stick to avoid problems.