Linux on USB
Once this was a very detailed post about which distribution to use on a USB stick and how to get that managed. As I just translated it for devl.net, I keep it short.
I have used Slax in order to install it on a USB stick. Just plug it into any (new) computer, and it’ll boot from it (as long as the mainboard is able to do this and as long as it’s activated in the BIOS). Every Linux user will know the benefits of a full OS on a USB stick.
This is a short how-to about installing Slax on a USB stick:
- Plug in the stick and type `dmesg |tail` in order to get to know how the stick is named. Usually it’s sda or the partition sda1, which I’m also using furtheron. (Use your own device name instead of sda)
- Create partition table: `cfdisk /dev/sda`. Format the whole stick as Fat32 (Type 0B). Also give it a “Bootable Flag”. After writing, it should look something like this:
sda1 Boot Primary W95 FAT32 [ ] 1022.92 - Format: `mkdosfs -F 16 /dev/sda1` creates a Fat16 partition, which can be also read by windows.
- Create a directory called “usb” (or whatever) in /mnt and mount /dev/sda to it: `mkdir /mnt/usb && mount /dev/sda1 /mnt/usb`
- Download Slax. It’s not important which version you use. I downloaded Slax Popcorn Edition.
- Open a shell and go to the directory where you have downloaded slax to (`cd /home/you/whereever/downloads`) and create a directory called ‘usbslax’ by typing `mkdir usbslax`.
- Mount the iso to the just created directory: `mount -o loop slax-*.iso usbslax`.
- `cp -r slax/* /mnt/usb` will copy all the data to the USB stick.
- Go to the stick (`cd /mnt/usb`)
- copy isolinux.cfg to syslinux.cfg, as we want to use syslinux: `mv isolinux.cfg syslinux.cfg`
- Copy the kernel and initrd to the root directory of the stick, as it won’t be a live CD: `cp boot/vmlinuz boot/initrd.gz ./`
- Open syslinux.cfg in a any text edit tool (e.g. `vim syslinux.cfg`) change every ‘/boot/vmlinuz’ to ‘vmlinuz’ and ‘/boot/initrd.gz’ to ‘initrd.gz’.
- Unmount: `cd .. && umount /dev/sda1`
- Install Lilo to the stick: `lilo -M /dev/sda` [grub didn't work for me]
- Make it bootable: `syslinux -s /dev/sda1`
- Reboot and enjoy: `sudo reboot`
