Create A Linux Live Cd From Scratch

  

How to Create Your Own Customized Ubuntu Live CD. Our purposes we're going to burn Tails to a bootable DVD because it's an easier process than creating a USB stick from scratch. Linux Respin is the fork of discontinued remastersys. If in case you don’t know what is remastersys, it is a free and open-source program for Debian, Ubuntu-based, Linux Mint or derivative software systems that were used create a customized Live CD/Live USB (a remaster) of Debian and its derivatives.

Contents

  1. Overview
  2. Graphical installer, optional step
  3. Create the Cd Image Directory and Populate it
  4. Make a bootable USB image

This procedure works and can create a bootable Ubuntu LiveCd (along with the automatic hardware detection and configuration) from scratch. You do not need to start from a pre-existing LiveCd.

You may wish to create an Ubuntu Remix and distribute it as a LiveCd. Here is a way to do that without having to start from an existing Ubuntu Desktop Cd.

There are three different areas to think about; the host system, the disk image and the chroot.

The Host System

This refers to the Ubuntu desktop you are running, the one the customised LiveCd is being built on. You will need to install the syslinux, squashfs-tools and genisoimage packages to be able to build the LiveCd Remix using the current system.

The Disk Image

The disk image is a folder that we will burn to Cd. Just create a new folder to be the Disk-Image-Folder. The isolinux bootloader binary (taken from the syslinux package) needs to be copied onto the disk image so it will go into the disk image folder for now. The isolinux configuration file, which will allow the Cd to show a boot-menu at boot time, needs to be copied into there too. You will also copy the kernel from the chroot onto the disk image (folder).

The disk image will be created in the host environment, outside of the chroot.

The ChRoot Environment

This is the system that will eventually run from the disk. It does not need a kernel, nor a boot-loader unless you are planning on installing it back onto a hard disk (using Ubiquity). The Casper package needs to be installed into the chroot. Casper is what allows the Live System to perform hardware autoconfiguration and run from a live environment. Installing the Casper package will update the kernel's initrd to perform these tasks. The kernel that is installed into the chroot will be copied out from the chroot and put into the disk image.

The chroot will end up inside the disk image in the form of a squashed (compressed) file. For right now, it will be just another folder on your host system.

The basic steps are to

  1. Create a chroot and install your packages there.
  2. Compress the chroot system into a file.
  3. Create and configure the disk image which will have the bootloader (isolinux), the kernel, the compressed file-system image and some other stuff.
  4. Burn the Cd and test it out.

From a command-lineinstall debootstrap on the host system. Then make a new folder 'work' and inside that make another directory 'chroot'. Then run debootstrap

Note: The version of Debootstrap for a release of ubuntu does not contain the files to bootstrap the next Ubuntu release. For example, you cannot bootstrap Karmic on an Intrepid system without intalling Karmic's debootstrap package. Find the version of debootstrap you need here and install it using dpkg. The debootstrap package doesn't depend on any other packages and so installing it 'by hand' will not cause any problems on your system.

$VERSION above should be replaced with whatever you have obtained. Likewise, $RELEASE is the version of Ubuntu you intend to build an ISO for. $ARCH is the target processor architecture. For old 32 bit x86 systems use i386. For newer 64-bit x86 systems (also known as x64, x86_64, Intel 64, and AMD64) use amd64 (--arch=amd64).

The code above creates a directory called work, with a chroot directory inside it. The debootstrap command installs a bare Ubuntu system into work/chroot.

If downloading from the main archive is slow, use one of the alternatives from this list of mirrors by adding the URL to the end of the debootstrap command, otherwise the ubuntu.com archive will be used by default.

Note: If you want to build a newer release of Ubuntu which you cannot bootstrap, for example oneiric:

It is important to install custom applications such as MySQL after linux-generic is installed because such applications require kernel modules for post-install configurations.

If you are planning on installing anything using the package desktop-base (xfce4 for instance), you will also need to bind your /dev to the chroot as well (not just devpts). Otherwise, grube-probe will error out and you won't be able to finish the installations. Replace /path/to/chroot/dev with your respective chroot.

Now copy the system files so you can get some internet in the chroot.

Note: If you are bootstrapping a release of Ubuntu other then the release you are currently running you should substitute the 'sudo cp /etc/apt/sources.list chroot/etc/apt/sources.list' command with the following.

For example if you are running precise and you are bootstrapping oneiric the command would be:

You may edit the sources.list in the chroot to add a line from a PPA, if you need. You will need to add the PPA's key to your chroot's package manager. On the PPA's overview page you'll see the PPA's OpenPGP key id. It'll look something like this: 1024/12345678. Copy it, or make a note of, the portion after the slash, e.g: 12345678. This key will be added once we enter the chroot.

Important: Make a backup copy of /sbin/initctl this next step will delete this file. There is a problem with 10.04 upstart package not containing /sbin/initctl.distrib and even after you update upstart the directions for leaving the chroot do not seem to restore this file.

There is a current (for Karmic, Lucid, .., Precise) issue with services running in a chroot: https://bugs.launchpad.net/ubuntu/+source/upstart/+bug/430224.

A workaround is to link /sbin/initctl to /bin/true.

Upgrade packages if you want:

Install packages needed for Live System:

Before Maverick, discover named to discover1. Adjust the preceding lines accordingly.

If you make Lucid Lynx (10.04) base Live system you need install grub2 plymouth-x11 packages:

Jaunty Jackalope (9.04) seems to hang on the configuration of the network interfaces unless network-manager is installed. This is no longer a problem in Karmic 9.10.

Next, you may install more packages as you like, assuming you have the legal rights to redistribute the packages. This is where you build your custom system using packages from the Ubuntu archives.

The customised system can be set-up to allow it to be installed onto machines rather than only ever being a LiveCd. Simply install the Ubiquity packages and an appropriate desktop environment with a window manager. This step is optional and only needed if you want to allow your customised Ubuntu system to be installed on other computers.

For the Gtk front-end

For the Qt front-end

If you installed software, be sure to run

Before exiting the chroot, remove the diversion:

Earlier this guide asked you to make a backup copy of /sbin/initctl. If the following command does not restore this file, then restore from the backup copy you made.

Remove upgraded, old linux-kernels if more than one:

Then just clean up.

If you also bound your /dev to the chroot, you should unbind that.

So far, you have entered the chroot and installed packages, then cleaned up and left.

There are 4 packages that need to be installed on the Host System which provide the tools to make the Cd image. Syslinux contains isolinux which makes the Cd bootable. Squashfs-tools will compress the image. Genisoimage provides mkisofs tool to turn a directory into a CD image. So install syslinux, squashfs-tools, mkisofs and sbm.

This next command makes the image directory and the 3 required subdirectories.

A. You will need a kernel and an initrd that was built with the Casper scripts. Grab them from your chroot. Use the current version. Note that before 9.10, the initrd was in gz not lz format..

B. If you have a problem with vmlinuz and initrd copying - maybe you have more than one from these files - you can using following commands:

You need the isolinux and memtest binaries. (Note: some distros place file isolinux.bin under /usr/lib/syslinux .)

Boot Instructions for the Remix User

To give some boot-time instructions to the user create an isolinux.txt file in image/isolinux, for example:

Splash Screen

A graphic can be displayed at boot time, but it is optional. The example text above requires a special character along with the file name of the splash image (splash.rle). To create that character, do the following use the following command:

and then edit the emptyfile with any text editor. Add the file name just next to the first character and add the text you want to display at boot time beneath it and save the file as 'isolinux.txt'

To create the splash.rle file, create an image 480 pixels wide. Convert it to 15 colours, indexed (perhaps using GIMP) and 'Save As' to change the ending to .bmp which converts the image to a bitmap format. Then install the 'netpbm' package and run

Boot-loader Configuration

Create an isolinux.cfg file in image/isolinux/ to provide configuration settings for the boot-loader. Please read syslinux.doc which should be on the host machine in /usr/share/doc/syslinux to find out about the configuration options available on the current set-up. Here is an example of what could be in the file:

Don't forget to pick the correct extension for your initrd (initrd.gz or initrd.lz). Now the CD should be able to boot, at least it will be after the image is burned

Create manifest:

Compress the chroot

If this Customised Remix is to potentially be installed on some systems then the /boot folder will be needed. To allow the Customised Cd to be an installer Cd, compress the entire chroot folder with this command:

Then write the filesystem.size file, which is needed by the installer:

However, if it is not going to be installed and is 'only' meant as a LiveCD then the /boot folder can be excluded to save space on your iso image. The live system boots from outside the chroot and so the /boot folder is not used.

Create A Linux Live Cd From Scratch

It is important to note that if you are building a Karmic LiveCd on an earlier system, you will need the squashfs-tools package from Karmic or the LiveCD will not boot.

Create diskdefines

example:

Recognition as an Ubuntu Remix

Create an empty file named 'ubuntu' and a hidden '.disk' folder. This is needed to make the USB Creator work with this custom iso image. Without this the image will still boot but the USB creator will not recognize the image as an Ubuntu CD and refuse to use it. Also, create the following files with the pertinent information:

Calculate MD5

This calculates the md5sum of everything in the image folder, except the file named md5sum.txt.

Create iso from the image directory using the command-line

The boot.cat file will be automatically created. You may test your image through virtualbox-ose instead of rebooting your real system if you wish.

The USB-Creator works properly with the iso image that has been created so long as the hidden '.disk' folder and its contents are present. If you prefer to do it 'by hand', you can put your live system onto a USB drive yourself. Follow these six steps to do so. You can use these steps to put an existing LiveCd onto a Usb bootable device.

FAT16 file-system (Windows)

1. Prepare your work area:

2. Create a loop device with a fat16 file-system. Use whatever size you need to fit your image; in this case it's a 200Mb sparse file. A sparse file is a file that is bigger than the actual number of bytes it takes up on the disk.

3. Two options here;

3a Mount the Cd-Rom iso image and your new file-system:

3b Just use the 'image' folder instead of mounting the iso image. This is useful if you don't want to make anything other than a Usb image from scratch (You don't have to make a Cd iso image if you don't need it)

4. Copy the files

5. Change the location of the boot-loader and its configuration file and make it bootable (For fat16 file-system (default))

6. Pack it up

To install onto a usb drive. Insert the drive and identify it's mount-point, for example /dev/sdc. Ensure that the device has a partition table on it and run

Ext2 file-system (proper Linux)

An ext2 file-system is useful in that it can hold larger files and the boot-loader can support relative symlinks. Follow the same steps as above, but substitute the instructions in steps 2 & 5

2. Create an ext2 file-system instead of FAT16, obviously.

Create A Linux Live Cd From Scratch File

5. It needs to be made bootable *before* unmounting.

Partitioning your Usb device

A persistent home can be included within a file instead of a partition. If you want to use a whole partition, do the following.

The Usb image can be installed to any partition on the device. Just make sure that partition is the only one that is marked as bootable. You can partition your Usb storage device to contain the LiveUsb image as well as a storage partition. You can use the storage partition to:

- keep a small amount of recovered files.

- create a persistent home.

- or you can use it as swap space.

To partition your device, see HowtoPartition.

If the storage partition is located after the LiveUsb image partition then Windows won't be able to see it. This is not a problem since you can create the storage partition first and put the live image at the end of the drive. Just make the LiveUsb image partition the only partition flagged as bootable.

When the drive boots the bootable partition will be used and you are good to go. The LiveUsb image's partition won't be seen by Windows.

Troubleshooting

If the device does not boot, you may need to install an MBR onto the device.

and try again. Vb6 pdf viewer.

Persistent Data

Create an ext2, ext3 or ext4 partition named 'casper-rw' as a separate partition and append the word 'persistent' to your 'append' line configuration and all your session data will be stored there. You will be able to keep your changes between boots.

-Update syslinux/isolinux instructions.

With recent versions of syslinux the instructions shown here create a broken menu.

-Graphical boot

http://wiki.debian.org/DebianDesktopMakeSysImageEtch

http://www.sweb.cz/Frantisek.Rysanek/splash/isolinux-splash-HOWTO.html)

If you have any comments or questions, please feel free to add them here.

I wrote some instructions detailing how to create an Ubuntu Live CD from scratch with debian's live-helper scripts: http://david.decotigny.fr/wiki/wakka.php?wiki=LiveHelperUbuntuTested on an x86_64 jaunty host for an i386 jaunty target CD.

-- DavidDecotigny

Hi, I have a question on this guide. The remix after going through these step does not include Gnome Desktop, right? If so, can someone provide me the package name to the Gnome Desktop?

Thks Alan Chen.

Alan,

The ubuntu-desktop package is based on gnome. If you try to install it with apt-get it will resolve all the dependencies and provide a list. Before installing, it will prompt you and then you can quit. Review the list and you may find the packages you need.

Andrew,

I'd like a live-cd that requires login and does not provide root access without a password of my choosing. Is this possible?

-Patrick

I guess that Casper can do that. Look in the Casper configurations.Perhaps you need to create the user and password while making the chroot, then tell Casper to only use that user? - Andrew

Create A Linux Live Cd From Scratch Download

Andrew et al,

I'm not sure that the instructions added here for the issue with running services in the chroot in Karmic are quite right. I say this because I used them today and it resulted in removing the following files: /sbin/start, /sbin/stop, /sbin/initctl. The commands used for removing the diversion did not restore them, and I had to manually reinstall them using a deb file. - Josh

-Sergey

I have made all as is written in this instruction. After loading from a disk I get to live cd command line. How I can start installation?

How can I set the keyboard language for the console and X? Currently I can make the livecd without problem but the kbd language is always en. Tnx in advance.

Matteo

People interested in a graphical environment read tasksel documentation.

This command show a list of all live CD/DVD tasks (groups of software)

and this other the list of packages in the ubuntu-live task

Carles Barreda

Hi, I'm working on a unnattended install CD using Ubuntu Lucid 10.04, and I found that if you erase /sbin/initctl the automatic install doesn't run. Also the instruction to generate the initctl using dpkg-divert is not working. So be careful..

Alejandro

When I follow this guide using 10.04. After the system boots it seems casper wants to run gdm. However, nowhere in this guide were there instructions for installing gdm and a window manager. Which is exactly what I want. The problem is that casper does not setup any ttys for me. How can I get casper todo this?

-pfifo

How do I install debian-installer is the same as in the alternate-cd, get it to start after instead of the live cd?

Serg

Is it possible to make an HD install from the CD/DVD that has no /pool and /dists folders? I start installation and AptSetup gives me error 127 trying to read the CD pool contents. There's nothing said about that here. As far as I understand this method uses the current (up to date) packages, so we have to grab the cd repo packages from the net repo also if we don't want to break dependencies.

Pry

Pry: If you get an error 127: after install ubiquity open chrooted environment following file:

and uncomment following line: about 136

(put an # sign):

save and test it. If you have an generated LiveCd you can do it in booted Ubuntu Live environment too. Sevoir

Yet another question. Is it possible to get the package names to be excluded from the HD install (the difference between filesystem.manifest and filesystem.manifest-desktop files) ? It doesn't seem to be a good idea trying to figure out what to exclude for the next release.

Pry

Successfully completed this great guide! Thanks to everyone who contributed. Now I'm curious, after having followed this, tested out Reconstructor (meh, not worth $5 in my opinion), and other variants.. at what point in this guide could one make some sort of a backup, to start a new build, without having to download the base packages and such? I am assuming after the debootstrap runs? Could I just back up the chroot folder and in the future continue from there with the backup? I'm going to try this, but I want to be certain that there aren't any 'gotchas' with this method.

Derjyn

One possible answer might be another guide in this series

  • https://help.ubuntu.com/community/LiveCDCustomization

So, the Cd itself can be considered a back-up stage to be developed from!

Hello,

I just created a bootable/live usb drive with ubuntu 11.04 on it. the problem is that the drive is 16 gigs, but the program I used to create the live usb only allowed me to allocate 4 gigs of extra space (that is space above the space needed for Ubuntu). So I would like to make the extra space much larger perhaps even allow it to fill the whole drive. Is it possible to resize this? and if so how?

Thanks, Daniel Kimbro.

Interesting.. I've gone through this procedure a couple of times now. It's awesome! What I don't get though is, something else is happening. If you make changes in /etc/init, those changes won't show up when you boot into the live environment.

I was even more surprised when I found that /home/ubuntu doesn't exist. Assuming this is something Casper does (given that it also takes care of persistent data which gets mounted as /home), where does it store this information?

Regards, Nevyn Hira.

Create Linux Live Cd From Scratch

It looks like the sbm package existed in natty but has since been eliminated. Does anyone know if a separate package needs to be installed in precise or oneiric? I will forge ahead and report back either way on my results.

Thanks, erixoltan

This howto is excellent! I am, however, having a problem getting my wireless networking credentials onto the custom image. I've tried to do this simply by copying over /etc/NetworkManager/system-connections/* but this is causing problems. When I boot to the image, it says the installer encountered an 'unrecoverable error' and then goes to a desktop session without any problem.

The specific error is in /usr/lib/ubiquity/bin/ubiquity:

Any help would be appreciated. Thanks!

Mark

Hi Mark, I think it's a permissions error. /etc/NetworkManager/system-connections need to be owned by root (chown root:root /etc/NetworkManager/system-connections/*) AND only readable and writable by the owner (chmod 600 /etc/NetworkManager/system-connections/*). - Regards, Nevyn.

This howto is great. For those wanting to match the iso release with their local release but cant remember what it is you can run the following one liner to put it in the RELEASE variable

Also please note the change from discover1 to discover in the 'remove' line.

- Regards, MrPurple

I cannot umount chroot/dev after the chroot process. It says that it is busy. It worked when I used the -l flag with umount. Is there something I am missing to do it the way it is outlined here?

Jesse

Jul 12, 2015 This will be done by building a new system using debootstrap. This is usefull if you want to build a clean live CD, or if you want to build a minimal rescue cd. (Consult Appendix.1 for more details about building a CD from scratch). The live CD is usually created with a filesystem called squashfs. How to create a custom Ubuntu live from scratch. This procedure shows how to create a bootable and installable Ubuntu Live (along with the automatic hardware detection and configuration) from scratch. Prerequisites (GNU/Linux Debian/Ubuntu) Install applications we need to build the environment. Dec 07, 2019 3. Linux Live Kit. It’s a set of shell scripts to create your own Live Linux from the current Linux installation. I’m going to show you the process to make a Live Linux using Linux Live kit. First, you must install the dependencies of Linux Live kit: Squashfs; Squashfs is a.

Linux, it’s a word that makes many a non-geek’s eyes glaze over almost immediately. However, desktop Linux offerings are now pretty much on par with the big names such as Windows and MacOS.

The image you can download from the Ubuntu website already is a live-CD waiting to be burned, you can burn it by following the instructions which can also be found on the download page: Burning a CD in Windows; Burning a CD in Mac OSX; Burning a CD in Ubuntu; The resulting CD will be your live-CD. Jul 13, 2017 If, however, we are more interested in creating a Linux installation USB than a Linux Live USB and don't care about multiboot, UNetbootin or Rufus are better choices. How to create a Linux installation CD / DVD. Many older systems won't support boot from USB. Because of this cycle, it's essential that the CD boot and shut down as quickly as possible. The problem is that with the next generation of cards, I have to update the CD to a 2.6 kernel. It's easy enough to acquire a pre-existing live CD - but those all are designed for showing off Linux on the desktop - which means they take forever to boot.

Thanks to decades of community work and support from organizations like Canonical, you can download something like Ubuntu Linux today and do almost all the things you can with Windows. All without needing a degree in computer science. Modern desktop Linux distros look good, work well and are suitable for average users.

However, they have one huge differencecompared to commercial operating systems – Open Source licensing.

How To Create A Linux Live Cd

This means we have full access to all theinner workings of Linux. You don’t have to pay to use it and you can customizeit in just about any way you like. That’s great for power users who like totinker with the nut and bolts, but what if you just want to preserve your owntweaked custom Linux installation?

You can actually create a fresh install of Linux, set it up just the way you want it and then turn it into a live, bootable installation. This is super-useful for a few reasons. First of all, it means you won’t have any downtime if you have to reinstall your operating system.

All your settings and software will already be waiting right from the start. It also makes it very easy to create custom installations for distribution. Let’s say you have to install Linux on a whole computer lab full of PCs and then install educational packages. Using a custom distribution tool means you only have to do that customization once and then simply install as usual.

One of the easiest tools out there is calledLinux Live Kit and we’re going to look at exactly how you can change anexisting Linux installation back into a custom distro.

Setting Up The Machine

In order to use the Linux Live Kit, you needan installation of Linux to customize. While you can go ahead and do it withyour main installation, it’s not the most practical approach if you want tocreate customized distributions for something other than your main computer.

So what we’ll be doing is installing UbuntuLinux to a VirtualBox virtual machine. That gives us a clean, controlledinstallation environment. It also means you can make custom Linux distros froma Windows machine if you like. Finally, it’s a good way to test the distroyou’ve just created, to make sure it works properly.

We are going to use the following components:

  • Windows 10
  • VirtualBox
  • Ubuntu 18 LTS

Remember, the process works exactly the sameif you use the Linux Live Kit on a Linux installation that running as normal ona computer, rather than in a virtual machine.

Installing Linux

The first thing to do is install Linux.Obviously if you want to use an existing installation, you can skip this step.

Installing Linux the usual way simply requiresthat you boot from the DVD or USB installation media. Because we’re usingVirtualBox, we just have to create a new virtual machine and then point ittowards the Ubuntu disc image we downloaded. Here are the steps you need tofollow.

Does djay pro play apple lossless files. When I drop the song, it just doesn't appear in VDJ. I tried the fix which was to go into iTunes Settings and clicking the box which allowed other programs to use downloaded songs. And I found that other people were having a similar issue that their VDJ wasn't seeing playlists from Apple Music/Itunes. This allowed me to see my playlist folders in VDJ, but when I click on the folder in VDJ, there is no song in there to choose from.'

Taking Care of Dependencies

Since Linux Live Kit is just a clevercollection of scripts, it needs certain other software packages to be presenton your Linux machine. In many cases they will already be a default part of theversion of Linux you have chosen, but you’ll have to verify this either way.

You need to make sure that aufs is supported by the kernel used by your chosen Linux distribution. You can check which kernel versions supports aufs here. If your chosen kernel does not support aufs, you’ll need to look at an alternative solution to Linux Live Kit.

Now we need to make sure that Squashfs isinstalled on the system. This is the compression technology used by Linux LiveKit. To install it, here’s what to do.

First, open the Terminal. In Ubuntu you can do this by clicking the “Show Application” button at the bottom left of the screen.This will bring up a search bar. Search for “Terminal” and click it when it comes up.

Now, in the terminal, type the following:

sudoapt-get update && sudo apt-get install squashfs-tools

If all goes well the package will beinstalled. If you run into trouble, you’ll have to refer to your version of theOS documentation. Troubleshooting repository and installation issues areoutside our scope for this tutorial.

Trimming the Fat

Since your live distro iw going to have allthe same content as your installed one, you should remove any files you don’tneed from your installation. You don’t have to do this and storage is cheapthese days if you’re using a flash drive. If you don’t know what’s safe to remove,skip this part for now.

Customizing

Now you can go ahead and make the changes youwant for your live distro. Install applications, tweak settings and so on. Onceyou are done with that, we can move on to the Live Kit itself.

Download Linux Live Kit

Create A Linux Live Cd From Scratch Free

Now it’s time to download the scripts we need.You can find it on GitHub. Pay special attention to the tips inthe README here. Some of them may be relevant to your needs or situation. Forexample, there are specific instructions if you want to make a bootable liveCD.

Savethe downloaded files to /tmp. In the download you’llfind a folder named “/DOC/. This is filled with additional readme informationto help you in case you hit a snag.

Generating Your Live OS

Now that the script files are where theyshould be, we want to actually run the script. To do this, we’ll have to switchfrom being a regular user to being a Super User. In Ubuntu, open the terminal and type the following:

cd /tmp

This switches you to the TMP folder where weunpacked the Live Kit files.

The last thing we need to do is run the script, so type:

sudo ./build

Now just wait until the script is done!

Create A Linux Live Cd From Scratches

Running Your Live Distro

So how do you get your live distro? The scriptgenerates two version in the /TMP folder. There’s an ISO image that you canburn to a disc or load up in a virtual machine to test. Most people are howevergoing to care about the bootable USB files. These are also in the /TMP folder.

Copy them to your flash drive, remember tounzip them in the process. Once they are on there, use the Terminal andnavigate to the /boot directory. Then run the “bootinst.sh” script to make thatflash drive bootable.

Create A Linux Live Cd From Scratch Online

If all goes well, you’ll now have your ownlive OS!