Debian 9.x is out, and various Live images are available which can be easily flashed onto a USB stick to make a nice, portable Debian. The nice thing about a live image is that it can adapt itself to the hardware it boots up on, so it can be truly portable.
Unfortunately, the live image is static; any changes, additions or customizations are lost when the stick is rebooted. Many users would prefer a 'persistent' image, which would be able to retain changes, and in the good old days Debian used to provide images that included that option. The live image would also contain a large writable partition whose contents would be merged with the static live image at boot up time. Relatively easy to do with Linux.
I found some instructions on how to add persistence to a LiveCD image on a nice page at http://cosmolinux.no-ip.org/raconetlinux2/persistence.html, and then I found that I could simplify those instructions even more. So here is my method:
I'm assuming that you're working from within Windows. If not, adapt! And I'm also assuming you know how to make your Windows machine boot from the USB drive.
First you download an ISO image of whatever Debian Live flavor you prefer. I used the version with XFCE and Non-Free included. Remember a 64-bit image will only boot on a 64-bit machine, so the 32-bit images may be more versatile. Also, of course, you will need a USB stick with enough capacity to hold your ISO image of choice, along with space to make a large extra partition. I used a 16Gig stick. Next you will need some software to write the ISO image to the stick. I won't belabor the many choices that are out there: I used Rufus, which made the job really easy because it uses isolinux automaticallty to make the stick bootable, even updating its builtin support automatically. You will also need a Partition manager, which will either be for Windows or for Linux. You'll see why below.
While in Windows, use Rufus to write your image to your USB stick, being sure to leave the file system as FAT32. You'll end up with a fully bootable USB stick with one large FAT32 partition holding the live system. Go ahead and boot it up, just to make sure.
Next you're going to add persistence, and you can do that almost entirely from within Linux or using a combination of Linux and Windows. The first tricky part is to make a modification to GRUB, and since you're Linux is not persistent yet, you will have to boot back into Windows.
Navigate to the directory
/isolinux on your flash drive. Open the text
menu.cfg in your favorite editor which understands unix text files (I used
Geany). This is a long file because it
describes many menu options. Just modify the first option block by finding the
APPEND initrd=/live/initrd.img-4.9.0-3-amd64 boot=live components
and adding the word "persistence" after the word "live." The result should look like
APPEND initrd=/live/initrd.img-4.9.0-3-amd64 boot=live persistence components
Next, either within Windows or in your not-yet-persistent Linux
environment, use your favorite partition manager to shrink the FAT32 partition
down to a size just big enough to hold its current contents, plus a little
padding, maybe an extra half a gig or so. Then in the empty space add an
ext4 partition and label that partition
Now boot back into the USB stick if you're not there already, and mount
the new partition. Change the ownership of that partition to the default
username of the live distro (which is, confusingly, "user".) If the partition
is mounted as
/media/user/persistence (which it probably will be) then use
sudo chown user /media/user/persistence
Finally create a one-line text file called
persistence.conf in the root of the
persistence partition, with the one-line reading
/ union, which will direct the
file system on boot to merge this partition with the root of the live system.
Easy way to do that is
echo /union > persistence.conf
Reboot the USB stick and you will be done. Test it by dropping a new file in your home directory and rebooting again; the new file will still be there!
The USB stick you just made should be able to boot up on many different machines (as long as they match the architecture of the distribution you chose) and find the devices, network hardware, and so on. Accommodating this versatility makes the distro a little clunky, but at least with the persistent version you can make sure that your favorite editors, tools and so on are already there, waiting to be used.
One final note of warning: by default the 'Live' image will set your hardware clock to UTC, so if your're booting a Windows machine (which usually has the system clock set to local time) your clock will be a little off. If you make the 'Live' image persistent, you can make the necessary changes to the Debian system to also keep the system clock on local time.
This is FABbnet!
This document maintained by rgm at fabbnet.net.
Material Copyright © 2017.