How to Create Live USB with Persistent Storage

Project Description

This project is work in progress (unfinished at the moment). I was asked to create a live USB with persistent storage for Anuko Time Tracker, which is a PHP application.

I already have a custom ISO image that installs CentOS 7 and all required components for the application. I need to figure out how to make a bootable Live USB out of it. The data need to be persistent between sessions, meaning that the database data and files created during application use need to stay after reboots.

Environment


Project Status

This project is currently work in progress, The following things were tried so far, with some conclusions.


Create ISO

This seems like an easy part.

We'll try to use Linux Live Kit from https://www.linux-live.org to create an ISO of a running system. According to their docs "It is a set of shell scripts which allows you to create your own Live Linux from an already installed Linux distribution. The Live system you create will be bootable from CD-ROM or a disk device, for example USB Flash Drive, a camera connected to USB port, and so on. People use Linux Live Kit to boot Linux from iPod as well."

yum install squashfs-tools
yum install mkisofs
yum install zip

Now that we have an ISO file, burn it onto a CD and try to boot from it. It does display a yellow boot selection screen as shown below, but won't boot, because kernel file is missing.

Linux Live Kit ISO Boot Selection

Linux Live Kit ISO Boot Selection



To fix this, I had to make the following modifications on the source OS (copied the kernel file).

# cd /boot
# cp vmlinuz-3.10.0-957.el7.x86_64 vmlinuz

Then, adjusted /tmp/linux-live-master/config file by editing the VMLINUZ string as so:

VMLINUZ=/boot/vmlinuz

Created ISO and burned a disk again. Now it boots and finds the kernel. However, there is another problem: it does not find a data bundle.

Linux Live Kit ISO failing to find data bundle

Linux Live Kit ISO failing to find data bundle



Apparently, as find_data_try string in debug output reports, it looks for data in /memory/data/ directory and it is not there.

In the end, it prints the following error message:

Fatal error occurred - Could not locate linux data
Something went wrong and we can't continue. This should never happen.
Please reboot your computer with Ctrl+Alt+Delete ...

If we examine the image by looking into the zip file that the utility also allows to generate we can see that the 01-core.sb file is there in the root of the directory, but the init script at boot is looking somewhere else for it. How do we make it find the data bundle?

// TODO: fix the init script to find data bundle, if using slax OS (below) fails. Currently investigating slax OS.

Challenges

Initially, I thought I could use Startup Disk Creator from Ubuntu 16.04.

Using it to create a startup USB from Ubuntu 18.04 ISO image works (I tried with a couple of USB sticks), in a sense that I get a bootable USB. The system can boot from it. But there are a couple of problems.

The above means Startup Disk Creator is useless in our situation.


Using Slax OX Instead

My current plan is to repackage everything into a customized Slax OS instead. We can download Slax OS ISO from https://www.slax.org

Let's see how to install Time Tracker application in there, trying SSD install first to speed things up.

Here is what I needed to do to make Slax OS bootable from SSD:

mkfs --type=ext4 /dev/sda

The above seemed to work, and now I can boot from SSD.

Slax OS running off SSD

Slax OS running off SSD



Customizing Slax

Procedure to install Docker and docker-compose on Slax is described at http://www.doitcontractors.com/projects/0033/how_to_install_docker_on_slax.htm