6

So I got my USB stick with my own running copy of Debian installed and booting ok. Thing is to forget EFI and just use good old LILO to make it bootable -- no fuss, no muss. But USB sticks, so they say, don't like constant writes, and a running copy of Debian is being written too constantly by Firefox and the systemd log and whatever else. So it occurs to me that since a stock install 'live' USB that you create from an .ISO file, so I've learned, never really writes anything -- all seeming writes are to an image in RAM, and evaporate when you log out. So it occurs to me to ask whether or not I can make my own ISO of my own system and have it work as a 'live' USB too. Is the key thing the ISO? or is there some other way? Maybe it has to be EFI?

1
  • 1
    You might enjoy exploring / using Puppy Linux. puppylinux-woof-ce.github.io It can easily be run from a USB stick, with a single write to the stick when you logout (or when you request).
    – PM 2Ring
    Commented yesterday

2 Answers 2

18

Live systems avoid having to write to their underlying storage using a variety of techniques (running entirely from memory, overlaying a RAM-based file system on top of a read-only file system, etc.); that’s what produces the behaviour you’re interested in. How they boot or the extension of the file you downloaded to create them isn’t relevant.

You can create your own live system. Since you’re using Debian, I suggest looking into the set of tools used to create Debian’s own live images, live-build. There’s a detailed manual in the live-manual packages, but you might find it easier to follow posts by users explaining how they used the tools, such as Ian LeCorbeau’s.

It’s also possible to prepare a live image manually; if you get that right this will allow you to create a live image based on your existing setup. See Will Haley’s post on the topic for details.

2
  • Thanks Stephen, I'll dig into this, now that I know where to look. As you and telcoM note, it's not about how it boots -- but that's what I wanted to know. Commented yesterday
  • If the system being booted is based on systemd, then you might be able to take care of creating the tmpfs and overlay just by arranging for systemd.volatile=overlay to be included in the kernel command line. Haven't tested that myself, though. Commented yesterday
12

In short, to answer the question in the title: yes, you can. But you might not want to.

You are combining together several unrelated concepts.

EFI and BIOS (as used by LILO) are boot methods. Either can be used to start both regular OS installations and "live" media - on HDD, USB or CD/DVD/Blu-Ray. Using the native EFI boot method enables some new features like a standard way to configure firmware boot options from within a running OS using efibootmgr, and the option to use Secure Boot. But other than that, once the Linux kernel has started, the bootloader's job is done and the kernel+initramfs will have complete control of what will happen after that.

A proper .ISO file is an image of an ISO9660 filesystem, and is primarily meant to be burned to CD/DVD/Blu-Ray - and so, it was at one point a useful way to distribute OS installation media. Later, Linux distributions started hybridizing their .ISO files so that they can be written to a HDD-like media (like USB sticks) and be bootable that way too. That typically requires embedding a second bootloader that is not used when the image is burned to a CD/DVD/Blu-Ray.

If you want to build your own "live" Linux USB stick, you can do it - but making it a proper ISO image (= using a ISO9660 filesystem and hybridizing it for USB boot) is a lot of unnecessary work if you don't ever plan to burn a copy of it on CD/DVD/Blu-Ray. You could still make a disk image of the USB, but you should not call it an ISO, but just a "disk image" (.IMG or .IMA file, like imaging a HDD/SSD). It could still be written to another USB stick just like a typical Linux ISO image.

Using an ISO file does not make a Linux installation a "live" media; the way its initramfs handles mounting its root filesystem does. If instead of mounting a regular disk-based filesystem, it either sets up a root filesystem to a RAMdisk, or uses an overlayfs to merge a read-only root filesystem image from the media + a writeable set of changes to it on a RAMdisk (or to a free space on the media for persistent live media), it's a "live" media installation.

If you want a Debian-based custom live USB, one easy-ish way to set it up might be to install Debian in a virtual machine for easier development, add live-media helper packages like bilibop-lockfs or overlayroot and configure them as appropriate for live-media-like behavior, make any necessary conversions (like building a squashfs or similar image of the root filesystem), then copy the necessary parts of the entire installation to USB and install a bootloader on it. At that point, the necessary parts (apart from the bootloader) might be just three files:

  • kernel file
  • initramfs file
  • a squashfs or other type of read-only base root filesystem image

But if you like the challenge, you could in theory even set it up Linux from Scratch-style... all without building a custom ISO at any point in the process.

Based on your question, I would assume you are not quite ready to start setting up your own custom live Linux just yet. I would recommend picking apart a live Linux media of your choice: extracting the contents of its initramfs file and then reading its start-up scripts to figure out how it works and what live-media-specific tools it might use. Once you have a more firm idea of what is involved in the process, you could then start your own live Linux project.

1
  • 1
    "You are combining together several unrelated concepts" That's exactly what I was asking -- where does the 'live' functionality originate? Your post is most informative, thanks. Commented yesterday

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .