First, the caveats:
- I had a working CentOS 6.2 install to work from.
- There’s really nothing new here; it just provides the steps I used and puts a lot of information that’s available out there into one place.
- As per my usual disclaimer, it’s very possible that there are easier, smarter ways to do this. I am not a genius (I don’t even play one on TV).
- I leave it up to you to figure out how to create a LiveDVD ISO for an architecture other than the one you’re currently running. I don’t doubt it’s easy; I just didn’t care to figure it out.
Next, the need:
Recently, we ran into a situation where it would have been really nice to have a customized LiveDVD or even CentOS on USB to get a couple of monitor session capable boxes up and running to look at traffic in a few places where there wasn’t an existing monitor box. No such LiveDVD or USB install was readily available, so I spent the time doing full blown installs of CentOS on a couple of systems that were probably only needed for a week at most. Once that need was out of the way, I started figuring out what one might need to do to to have CentOS ready to go, independent of hardware.
I did manage at one point to get:
- CentOS 6.2 install DVDs onto flash drives (actually fairly easy – formatted the flash drive ext4 and used Unetbootin on Ubuntu to make the flash drive bootable with the 64 bit version; the 32 bit version is small enough to use iso2usb.exe on a Windows box), but they tend to run a bit slow. Easier to move around than DVDs though.
- CentOS 6.2 to install (and run) onto a flash drive. Again, slow – took several hours to run yum update. I suggest killing all but the most essential services off and run init 3 unless you really really need a GUI. Almost wrote a post about this but things started unexpectedly working when they hadn’t before, and I don’t know how that happened.
So the next move: LiveDVD.
Thing is, the packaged LiveDVD available from CentOS was lacking in certain packages we would find useful. Also, we might want to be able to ssh into the LiveDVD and by default root doesn’t have a password … nor does the LiveCD user. So, I had to learn how to roll my own.
First, I needed a couple of packages that weren’t available via the standard yum repos:
It took some doing to find them. There are two methods of getting them installed:
- The hard way, which is to download them from EPEL, use the standard “rpm -ivh” in an attempt to install them, and go through the process of installing the prerequisites through “yum install” …
- The easy way (which I haven’t tried), which according to the CentOS LiveCD Project, is to install the repo and use yum.
Next, it took some time to track down the (or at least a compatible) kickstart file for the stock LiveDVD. It is sufficiently different enough from any install generated kickstart file that you don’t want to write your own without looking. It is my understanding that the CentOS 6.x versions of the kickstart file aren’t available where the previous versions had been. But I got lucky with my Google-Fu and found them.
Once you have the LiveCD or LiveDVD of your choice, you might want to edit the file a bit. Look it over. It’s fairly self-explanatory:
- One of the first things you’ll want to do is include your local repo, if at all possible, in order to use up to date packages to create your LiveDVD. The CentOS LiveCD Project covers this in their explanation of Kickstart files. In my case the example (which they never do provide all in one downloadable file there) did not match what I obtained from other sources. It was close, but a few things were different. But again, the self-explanatory nature of the kickstart file will make it fairly simple to understand what might need to be changed to customize the resulting ISO to your needs.
- You can add package names to the end of the list of packages and package groups, or even remove packages to make your resulting LiveDVD smaller. For us, I had to ensure that “wireshark” was in the list (I think it is) and during my troubleshooting I had to include “system-config-firewall-base” to the list as well. It’s one of the reasons for going with the LiveDVD instead of the LiveCD – it already has quite a bit more to it.
- Depending on your needs, you’ll have to figure out how to set passwords. In my case, it was to use
echo "password" | /usr/bin/passwd user --stdin
Of course this unfortunately means that your passwords are in clear text in the .cfg file. Protect it! Also, I ran into an issue with iptables not letting ssh through (even though I thought I had told it to). So I got frustrated and used a
/bin/mv /etc/sysconfig/iptables /etc/sysconfig/iptables.old
and then a
cat > /etc/sysconfig/iptables << EOFWR <exactly what I wanted> EOFWR
That’s pretty much it as far as I was concerned.
So, the next step is creating the ISO. This is where the LiveCD tools come in. You’ll want to:
prompt# LANG=C livecd-creator --config=your-custom-config.cfg --fslabel=CentOS-Custom-LiveDVD
Which will download the the necessary packages for your ISO and output a file named “CentOS-Custom-LiveDVD.iso”. It may take a while.
Next, instead of wasting a DVD (I wasted two!), I suggest you use a flash drive. I formatted (shouldn’t have needed to, but you know …) it ext2 and then used:
livecd-iso-to-disk --format --reset-mbr CentOS-Custom-LiveDVD.iso /dev/sdb
Assuming /dev/sdb is where your flash drive is mounted. You might have to change that!
Now, boot from your flash drive, verify that the password(s) work and that the system does everything you want it to, and you should be good to go! I’m fairly certain it isn’t upgradable, but it does certainly seem to run faster (even from USB) than a direct USB install of CentOS does.