Showing posts with label livecd. Show all posts
Showing posts with label livecd. Show all posts

Sunday, March 20, 2016

Making Live CDs with latest updates

Not too long back I bought a new laptop, and as always needed to put my favourite Linux OS on it to keep ahead of the enterprise version.  If you haven't guessed I'm referring to Fedora.  Being about 3 years ahead of what is about to hit RedHat is extremely useful.

However the laptop that I decided to buy, from pcspecialist looked like a Mac Airbook, or whatever they call their slimest one, but with the latest and greatest faster i7 6th Gen processor, etc.  So in short far superior to the Apple, but less than 1/2 the price at £620.

When it arrived, it was excellent - F23 installed, but after a short while it started to hang if it was stressed, so diverted over to Elementary OS, which although pretty, was a little old from a Kernel perspective and lacking some features.

Last weekend I had some time to sit down, since F23 wouldn't run as a Live USB stick from download I decided to build my own spin.  I've been building kickstart systems for a very long time, especially over networks and also on DVDs, however in recent times the process has changed a little since you can't get the entire OS DVD, but have to create a live one.

So using some useful sites around livecd-tools decided to install it and create F23 spin with all of the latest updates taken from rpmfusion.  Here is how it is done on a Fedora system;

1.Install livecd-tools
    1. sudo dnf -y install livecd-tools fedora-kickstarts
      1. The fedora-kickstarts will provide the basis for your files to build the livecd
2. Create a directory to perform the work and store your final ISO image
    1. mkdir -p $HOME/livecds/fc23
      1. I've added fc23 so that I can build different versions
    2. I also created a script called $HOME/livecds/livecd so that I don't have to remember the options;

#!/bin/bash

# URL location
# https://fedoraproject.org/wiki/How_to_create_and_use_a_Live_CD
if (( $# < 3 ))
then
  echo "Syntax: $0 " >&2
  exit 1
fi

pathToKickstartFileks="$1"
tmpcacheLocation="$2"
cdLabel="$3"

livecd-creator --verbose --config="$pathToKickstartFileks" --fslabel="CDLabel" \
--cache="$tmpcacheLocation"

3. The main element to creating a live CD with the latest kernel, etc is to include the repositories of rpmfusion, and to add the necessary packages to the kickstart file.
  1. Copy the example kickstart base file for Fedora 23 so that you can modify it;
    1. cp /usr/share/spin-kickstarts/fedora-live-workstation.ks $HOME/livecds/fc23
  2. Modify the kickstart file, changing the following to make it fit on an 8GB USB
    1. part / --size 8192  --fstype ext4 --grow
      1. The original only allows for a 4GB and doesn't have grow
    2. Under the %packages section you can add your extra Groups or individual packages that you need.  Note if you are adding a group then something like "Development tools" should be written as development-tools
    3. If you don't want a package then precede it with a hyphen (-)
      1. e.g. -shotwell
    4. You will also notice in this file the line;
      1. %include fedora-repo.ks
      2. Create this file with the following for F23, change version based on OS
repo --name=fedora --mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=fedora-23&arch=$basearch
repo --name=fedora-updates --mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=updates-released-f23&arch=$basearch
repo --name=fpmfusionfreerawhide --mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=free-fedora-rawhide&arch=$basearch
repo --name=rpmfusionnonfreerawhide --mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=nonfree-fedora-rawhide&arch=$basearch
repo --name=rpmfusionfree --mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=free-fedora-23&arch=$basearch
repo --name=rpmfusionfreeupdates --mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=free-fedora-updates-released-23&arch=$basearch
repo --name=rpmfusionnonfree --mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=nonfree-fedora-23&arch=$basearch
repo --name=rpmfusionnonfreeupdate --mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=nonfree-fedora-updates-released-23&arch=$basearch
repo --name=google --baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64

You'll note that I've also included Chrome.  Each repo is one complete line.  The key ones are the rpmfusion and the updates so that we get the latest and greatest software installed.

4. To build the ISO image simply run your livecd script from within the F23 directory;
  1. $HOME/livecds/livecd ../fedora-live-base.ks ../cache F23-livecd
    1. This command then connects with the relevant repositories to download the rpms and builds the DVD ISO image
    2. You should watch the early output since it will tell you if you have any mistakes with package names or groups
5. Finally put the image on to you USB stick with;
  1. dd if=F23-livecd.iso of=/dev/sdd
    1. Where /dev/sdd should be changed to your USB drive
    2. If you don't know how to find out then;
      1. df -h
        1. Get a list of all the Filesystems
      2. Insert the USB stick
        1. df -h
        2. Look for the Filesystems that was not their previously
      3. Unmount the USB stick so you can write to it with dd
        1. sudo umount /dev/sdd

Troubleshooting

In most cases you are likely to see the following error if the partition size in the kickstart file is not large enough for the image.  If this is the case you will see;
Error creating Live CD : Unable to install: Could not run transaction.
Unmounting directory /var/tmp/imgcreate-vo3YLW/install_root
Losetup remove /dev/loop1
In the above case you should increase the part --size until the error no longer appears.

If you have an incorrect package you will see something like;
Retrieving http://www.mirrorservice.org/sites/download1.rpmfusion.org/nonfree/fedora/updates/testing/23/x86_64/repodata/d5d34f8bad2e14babefd4ff808715d34cdd5637475759a76c58852f211892340-primary.sqlite.xz ...OK
Skipping missing group 'Web Server'
Edit the fedora-live-base.ks file and modify the name in the %package section.