Tobias Brunner bio photo

Tobias Brunner

...(a.k.a. tobru) is a Network and Linux Engineer (LPIC-2), working at VSHN AG and blogs about DevOps, Networking, Linux and OpenSource topics on his techblog tobrunet.ch.

Email Twitter XING Github Flattr this

Have you ever wanted to create a customized, redistributable and bootable USB stick of your Debian/Ubuntu Linux server, f.e. as a backup or test system? Or would you like to give your nicely customized Debian/Ubuntu Linux desktop to your friend, without your personal data? Then you should give Remastersys a try. It creates a bootable ISO of your running system (without reboot) which can be copied to a USB stick.

Remastersys knows two main modes for creating a live ISO:

  • backup: Creates a bootable ISO of your whole systen, including the home directories
  • dist: Creates a bootable ISO of your whole systen, NOT including the home directories

Here is how to install and use it:

Install Remastersys on Ubuntu

  1. Add repository key:
    wget -O - http://www.remastersys.com/ubuntu/remastersys.gpg.key | sudo apt-key add -
  2. Add repository to /etc/apt/sources.list.d/remastersys.list:
    deb http://www.remastersys.com/ubuntu precise main
  3. Update Apt and install it:
    apt-get update; apt-get install remastersys
  4. Optionally you can install the GUI:
    apt-get install remastersys-gui

Use Remastersys

Before you can use Remastersys, it needs some configuration. This is found in /etc/remastersys.conf. You should at least check or change the WORKDIR variable, you need a lot of diskspace there and the final ISO image is saved in this directory.

Now simply run Remastersys in the desired mode:

sudo remastersys backup

sudo su
remastersys dist

It takes a lot of time to finish and depends heavily on your disk speed. Note that you need internet access because some packages will be downloaded during the creation of the live image.

After running Remastersys, you will find a .iso image in you WORKDIR. Copy it to a save place and run remastersys cleanup to free up disk space.

Now you can simply try this ISO image in a VirtualBox, burn it to a CD/DVD or copy it to a USB stick. This works very well with the Ubuntu tool “Startup Disk Creator” (usb-creator-gtk or usb-creator-kde), even as read-only stick.

Customizing Remastersys

Remastersys is just a Bash script which makes use of several Linux tools to create a live ISO image: casper, squashfs, preseed, isolinux, ubiquity, mkisofs/genisoimage. Most of them can be customized by editing the files under /etc/remastersys.

I’ve patched the Bash script to have a customized hostname on the iso image and to choose a corresponding custom isolinux config file if available:

--- /usr/bin/remastersys 2013-02-15 15:36:16.465578348 +0100
+++ my-remastersys 2013-02-18 13:46:53.832835624 +0100
@@ -392,6 +392,13 @@
# check and see if they have a custom isolinux already setup. eg. they copied over
# the isolinux folder from their original livecd or made a custom one for their distro
 
+ CUSTOMHOSTNAME=$(echo $CUSTOMISO | gawk -F "." '{print $1}')
+ if [ -f ${CUSTOMISOLINUXCFGPATH}/isolinux.cfg.${CUSTOMHOSTNAME} ]; then
+ ISOLINUXCFGFILE="${CUSTOMISOLINUXCFGPATH}/isolinux.cfg.${CUSTOMHOSTNAME}"
+ else
+ ISOLINUXCFGFILE="/etc/remastersys/isolinux/isolinux.cfg.vesamenu"
+ fi
+
if [ ! -f /etc/remastersys/customisolinux/isolinux.cfg ]; then
log_msg "Creating isolinux setup for the live system"
find /usr -name 'isolinux.bin' -exec cp {} $WORKDIR/ISOTMP/isolinux/ \;
@@ -400,7 +407,7 @@
cp $VESAMENU $WORKDIR/ISOTMP/isolinux/
# setup isolinux for the livecd
VERSION=`lsb_release -r | awk '{print $2}' | awk -F "." '{print $1}'`
- sed -e 's/__LIVECDLABEL__/'"$LIVECDLABEL"'/g' /etc/remastersys/isolinux/isolinux.cfg.vesamenu > \
+ sed -e 's/__LIVECDLABEL__/'"$LIVECDLABEL"'/g' $ISOLINUXCFGFILE > \
$WORKDIR/ISOTMP/isolinux/isolinux.cfg
cp /etc/remastersys/isolinux/splash.png $WORKDIR/ISOTMP/isolinux/splash.png
else
@@ -484,6 +491,7 @@
fi
log_msg "Creating the casper.conf file."
# Added FLAVOUR= as the new casper live boot will make it the first word from the Live CD Name if FLAVOUR is not set
+ if [ $CUSTOMHOSTNAME == "" ]; then $CUSTOMHOSTNAME = $LIVEUSER; fi
cat > /etc/casper.conf <<FOO
# This file should go in /etc/casper.conf
# Supported variables are:
@@ -491,7 +499,7 @@
 
export USERNAME="$LIVEUSER"
export USERFULLNAME="Live session user"
-export HOST="$LIVEUSER"
+export HOST="$CUSTOMHOSTNAME"
export BUILD_SYSTEM="Ubuntu"
export FLAVOUR="$LIVEUSER"
FOO

Install gawk and add the following config variable to /etc/remastersys.conf
CUSTOMISOLINUXCFGPATH="/root/remastersys-config"
You can now place a custom isolinux config files named like this isolinux.cfg.<customhostname> in this directory and it will be chosen when creating the bootable iso image.