Difference between revisions of "Custom Live USB"

From Organic Design wiki
(Wrong url format)
m (Wrong url format)
Line 132: Line 132:
 
sudo lb build
 
sudo lb build
 
</source>
 
</source>
 +
 +
See also:
 +
* https://lists.ubuntu.com/archives/ubuntu-devel-discuss/2014-October/015092.html
  
 
== Multi ISO USB ==
 
== Multi ISO USB ==

Revision as of 02:29, 31 January 2022

Custom ISO

It can be useful to customize an image to preinstall packages or pre-configure settings so that when the image gets live booted those packages are already installed and usable.

Ubuntu

CUBIC (Custom UBuntu Iso Creator) is a easy tool for customizing Ubuntu based distribution images such as Mint. The process gives you a virtual shell and you can install packages and configure the OS as you normally would, after doing this CUBIC packages it back up into an ISO. There appears to be many advanced options but for preinstalling applications and pre-saving data it is straight forward.

Debian

Looks like live-build is an option for customizing Debian ISOs but this method looks more difficult that CUBIC.

This tutorial is nice an simple for getting started with.

Basic Instructions

Install with:

sudo apt-get install live-build

Setup and configure with:

mkdir debian;
cd debian;
lb-configure;
# https://manpages.debian.org/stretch/live-build/lb_config.1.en.html

You should clean the old build configuration before building:

sudo lb clean

Then you can build with:

sudo lb build

Customization

Adding Files/Folders

Files and folders placed in config/includes.chroot will be copied into the root directory on install.

Packages

You can add packages to the image by creating the file config/package-lists/my.list.chroot with the list of packages separated by newlines.

Custom Packages

You install .deb packages by placing them into the config/packages.chroot directory.

Hooks

The config/hooks directory is for placing your scripts you would like to run at certain times in the build process. For example to customize something in the live boot you would need to create a folder called live in this directory, then place a shell script that performs some actions in there.

Debugging

Check the chroot/debootstrap/debootstrap.log file for more specific logs.

Cannot check Release signature
W: Cannot check Release signature; keyring file not available /usr/share/keyrings/debian-archive-keyring.gpg

This can easily be fixed by installing the keyring:

sudo apt-get install debian-archive-keyring
Failed getting release file
E: Failed getting release file http://ftp.debian.org/debian/dists/wheezy/Release

This default release mirror was returning a 404 so, just change it:

lb config -m http://ftp.nz.debian.org/debian/
sudo lb clean
sudo lb build

The release Wheezy is outdated, it needed changing to bullseye.

#lb config -d bullseye --parent-distribution bullseye
lb config -d stable --parent-distribution stable
sudo lb clean
sudo lb build
Does not have a Release file

There seems to be some repo issues:


Disabling security fixes it for now.

lb config --security false
sudo lb clean
sudo lb build
Wrong url format
[2022-01-31 14:54:31] lb_chroot_linux-image 
--2022-01-31 14:54:31--  http://ftp.debian.org/debian//dists/stable/Contents-amd64.gz
Resolving ftp.debian.org (ftp.debian.org)... 151.101.166.132, 2a04:4e42:27::644
Connecting to ftp.debian.org (ftp.debian.org)|151.101.166.132|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2022-01-31 14:54:31 ERROR 404: Not Found.

The URL was missing /main in it so it had to be manually edited:

sudo nano /usr/lib/live/build/lb_chroot_linux-image

Search for the content:

${LB_PARENT_MIRROR_CHROOT}/dists/${LB_PARENT_DISTRIBUTION}/Contents-${LB_ARCHITECTURES}.gz

And replace with:

${LB_PARENT_MIRROR_CHROOT}/dists/${LB_PARENT_DISTRIBUTION}/main/Contents-${LB_ARCHITECTURES}.gz

And likewise search for:

${LB_MIRROR_CHROOT}/dists/${LB_DISTRIBUTION}/Contents-${LB_ARCHITECTURES}.gz

And replace with:

${LB_MIRROR_CHROOT}/dists/${LB_DISTRIBUTION}/main/Contents-${LB_ARCHITECTURES}.gz

Then build without cleaning again:

sudo lb build

See also:

Multi ISO USB

Ventoy is a great tool if you would like to have multiple bootable ISOs on a single USB drive. Ventoy is fairly easy to use since it has a few scripts to handle things for you.

Ventoy Usage

  1. Download Ventoy from its releases.
  2. Run the the appropriate (for your architecture) Ventoy GUI program.
  3. Select your USB drive and flash it with the Ventoy software.
  4. Unplug and replug your USB drive.
  5. Copy any ISOs you like onto the drive (probably labeled "Ventoy").
  6. Boot into your usb and select the ISO you would like to boot from the menu.

Persistent Storage

Live images will not normally persist storage which can really limit their use-case, however there seems to be some options for solving this.

Partitioning/File

It seems possible for Ubuntu (and Debian?) distributions to persist storage through partitions or a file. It looks like if you partition your USB that has the ISO formatted on it with partitions labeled casper-rw and home-rw Ubuntu will detect these and use them as persistent storage. Alternatively it appears you can create a loopback file in the root directory that will be used as well, this file must be named casper-rw.

Ventoy

Ventoy has a plugin that allows you to use a persistent storage file for storing your data and this storage can be configured to be used across the images that support it's format.

Plug your Ventoy USB in and open a terminal and cd into your USB directory.


Run:

# Note: this will create the persistent file in whatever directory you run it so ensure you are in the mounted USB.
sudo /PATH/TO/VENTOY/CreatePersistentImg.sh -s <SIZE_IN_MB>


Note: You can do the next part manually if the UI scares you.


After that finishes change to your Ventoy installation directory and run:

# Note this script won't work if you are not in the right directory.
./VentoyPlugson.sh /YOUR/USB/MOUNT # e.g. /dev/sdb

Open your browser and navigate to http://127.0.0.1:24681 and configure the plugin by:

  1. Click Persistence Plugin on the left.
  2. Click Add down the bottom right.
  3. Fill the File Path with the path of your ISO inside the Ventoy USB.
  4. Fill the Dat Path with the path of the generated persistence file inside the Ventoy USB.


Once that is done reboot and choose the ISO from the menu then choose the with persistence option.

Manually Configure Ventoy

Instead of using the VentoyPlugson UI you can manually configure Ventoy to use the persistent storage file.

  1. Create the folder called ventoy in the root of your Ventoy USB if it doesn't already exist.
  2. Edit or create a file in there called ventoy.json.
  3. Modify the file to include the following JSON:
{
    "persistence":[
        {
            "image": "/YOUR_IMAGE_NAME.iso",
            "backend":[
                "/persistence.dat"
            ]
        }
    ]
}

See also