How to Customize an Ubuntu Installation Disc – The Right Way (14.04 Compatible!)

This disappeared off this blog earlier this month, so I thought I’d repost it here. I take no credit for any of this.


If you’re like me, you’ve wanted to customize an Ubuntu install DVD for a long time – but all the tools/directions for doing it are out of date and/or broken. Look no further!

I have successfully customized an ISO of Xubuntu 14.04 for my project Builduntu but this guide should work for just about any flavor of Ubuntu, maybe even other Linux distributions. If you aren’t sure, give it a try! Mint and Debian are very similar and may work with minimal changes to the commands (ie, replace apt-get with whatever package manager the particular distro uses). It helps if the distro you want to customize is the same as what you are running currently, but is not necessary.

 

Let’s get to it.

First download the ISO you’d like to start customizing from Ubuntu’s release server here. Remember where you save it, because you’re going to have to move it in a minute.

From here on out, it’s bash command line. Don’t worry, it’s the easiest way of doing this (for now). You don’t need to be a Linux guru, just pay close attention to the directions and it will work fine.

Make sure the prerequisite software is installed for unpacking and repacking the image. Open a terminal and run:

sudo apt-get install squashfs-tools genisoimage

Create a fresh folder to begin work. For the purposes of this guide, everything will be done from the starting point of the user’s home directory (indicated in Linux by a tilde “~”). Approximately 10 gigabytes total of free hard drive space is required for decompressing the ISO filesystem and repackaging it at the end.

mkdir ~/custom-img

Move the base ISO downloaded in the first step to the working directory. From here on out, replace “ubuntu.iso” with the name of the image downloaded from the Ubuntu Release server ex. trusty-desktop-amd64.iso

mv /path/to/saved/ubuntu.iso ~/custom-img
cd ~/custom-img

Next, extract the contents of disc image.

mkdir mnt
sudo mount -o loop ubuntu.iso mnt
mkdir extract
sudo rsync --exclude=/casper/filesystem.squashfs -a mnt/ extract

Here’s where things start to get interesting. Extract the filesystem with the following commands:

sudo unsquashfs mnt/casper/filesystem.squashfs
sudo mv squashfs-root edit

You’re going to need network access from within the chroot environment to download and install updated/new packages. Essentially what’s happening is you are going to “log in” to a command line instance of the Ubuntu installation, separate from the host system. Perhaps a confusing concept to wrap your head around at first, but it makes sense when you think about it. Copy resolv.conf from your system into the freshly unpacked fs.

sudo cp /etc/resolv.conf edit/etc/

Mount a few important working directories:

sudo mount --bind /dev/ edit/dev
sudo chroot edit
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devpts none /dev/pts

Now you are actually logged in to the installation instance as root. Neat. Before making changes, a few commands will make sure that everything goes smoothly while modifying packages.

export HOME=/root
export LC_ALL=C
dbus-uuidgen > /var/lib/dbus/machine-id
dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl

OK, now you can start playing around. This guide is only going to cover adding and removing software, but it’s possible to customize just about anything. Things like custom backgrounds and settings are already documented elsewhere, but be careful! Many of the directions are outdated and the commands may need slight alterations to work correctly. I had to piece this guide together from a few different sources with a whole lot of dead reckoning.

Start by removing the packages you don’t want. Be sure to use the “purge” command so that the system will automatically uninstall and delete the package, which optimizes the space required for the ISO. When you execute purge, read the list of programs to be removed before you select “Y” and make absolutely sure you haven’t accidentally flagged a core system package via association.You will recognize this because the list will contain significantly more packages than those you selected.

apt-get purge package1 package2 package3

I personally remove games, scanning utilities (I don’t have a scanner) and default text editors like abiword and mousepad (geany is the best). Stay away from core components unless you know what you are doing.

Since I am customizing a 64-bit Ubuntu image, I need multiarch (i386) support for some of the programming libraries. The following command is not necessary for everyone, but I recommend it anyway.

dpkg --add-architecture i386

Update the software repositories and upgrade the remaining packages on the system.

apt-get update && apt-get upgrade

Add packages to the system the usual way:

apt-get install package1 package2 package3

You are almost there! Time to clean up:

apt-get autoremove && apt-get autoclean
rm -rf /tmp/* ~/.bash_history
rm /var/lib/dbus/machine-id
rm /sbin/initctl
dpkg-divert --rename --remove /sbin/initctl

Unmount the directories from the beginning of this guide:

umount /proc || umount -lf /proc
umount /sys
umount /dev/pts
exit
sudo umount edit/dev

You have now “logged out” of the installation environment and are “back” on the host system. These final steps will actually produce the ISO. Other guides stop working at this point, but have no fear! The following commands have been tested and verified.

Generate a new file manifest:

sudo chmod +w extract/casper/filesystem.manifest

sudo chroot edit dpkg-query -W --showformat='${Package} ${Version}\n' > extract-cd/casper/filesystem.manifest
(Note: You may need to be logged in as root to run the above command. I kept getting a permission denied error with only using the sudo).

sudo cp extract/casper/filesystem.manifest extract/casper/filesystem.manifest-desktop

sudo sed -i '/ubiquity/d' extract/casper/filesystem.manifest-desktop

sudo sed -i '/casper/d' extract/casper/filesystem.manifest-desktop

Compress the filesystem:

sudo mksquashfs edit extract/casper/filesystem.squashfs -b 1048576

Update filesystem size (needed by the installer):

printf $(sudo du -sx --block-size=1 edit | cut -f1) | sudo tee extract/casper/filesystem.size

Delete the old md5sum:

cd extract
sudo rm md5sum.txt

…and generate a fresh one: (single command, copy and paste in one piece)

find -type f -print0 | sudo xargs -0 md5sum | grep -v isolinux/boot.cat | sudo tee md5sum.txt

And finally, create the ISO. This is a single long command, be sure to copy and paste it in one piece and don’t forget the period at the end, it’s important:

sudo mkisofs -D -r -V "$IMAGE_NAME" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../name-of-your-custom-image.iso .

It takes a few minutes, but when that is done you will have a burnable/distributable ISO in your working directory (~/custom-img)

Have fun and good luck! Let me know how customizing works out for you!

OS X 10.9.4 Update

I know this is a couple weeks late, but for those wondering, the OS X 10.9.4 update is safe on a 2006/2007 Mac Pro that’s hacked to run Mavericks. There’s no need to replace the modified boot.efi file if you’re going from 10.9.3 to 10.9.4. But, if you are using a combo updater (i.e. from 10.9.2 to 10.9.4), you will need to replace the boot.efi file.

I will write a script soon that will allow you to boot up on the Recovery Partition and run a script from Terminal to automatically replace the bootloader files. Stay tuned…

An Ancient Relic

20140322-172738.jpg

This little guy came into work the other day. This machine is probably one of the coolest that Apple has ever made! Brand new they costed $7500!! And even today, this collector’s item is selling for anywhere between the $1000-$2000+ ballpark. It’s amazing that something so old can still keep it’s value. Here’s an excerpt from the description over at everymac.com:

The unique Apple 20th Anniversary Macintosh, based on an internal design similar to the Gazelle architecture, features a 250 MHz PowerPC 603e processor, 32 MB of RAM, a 2.0 GB hard drive, a vertically oriented 4X CD-ROM drive, an ATI 3D RAGE II graphics processor with 2 MB of SGRAM, S-video input, TV/FM Radio capability, and a custom Bose speaker system all packed in a custom, one-of-a-kind case.

The 20th Anniversary Mac shipped with a unique keyboard with an integrated trackpad and Italian leather palm rest as well as a large external Bose subwoofer.

I won’t lie, when I first saw this machine I geeked out pretty bad. This is the first one that I had ever seen in person! A couple coworkers and I decided to test out the Bose speakers. After all, Bose is one of the best right? We downloaded iTunes 2.0.4 from macintoshgarden.org and popped in a CD and played some tunes! I was quite impressed with the sound quality coming from the 17 year old speakers!

This particular machine had been maxed out all the way with the processor upgraded to a 500MHz G3 and RAM maxed out at 128MB! All in all, this machine is cool enough to make anyone’s head turn.

UPDATE:

I received the new processors and put them in about a week ago. They work great! Temps are a lot more normal. There is still a slight difference in temps between the two processors but that is expected.

I’m positive the temps will go down with time. I read this article from someone who upgraded to the exact same processors as me. He states that his temps went down after a couple months. Apparently thermal paste needs to be “broken in”. It makes sense but I’d never heard of it before.

New Temps

Also, I upgraded the firmware from the 2006 (MacPro1,1) to the 2007 (MacPro2,1) using a utility found on netkas.org. This allows the “About This Mac” box to show “2x 2.66 GHz Quad-Core Intel Xeon” instead of showing “2x 2.66GHz Unknown” for the processor specs. **EDIT:** You can download the utility from here.

Xeon X5355 About This Mac

I took the liberty to encode a Blu-Ray movie to H.264. It worked fantastic! Temps were in the 80°C. It was a lot better than the last time I tried with the old processors! (Last time temps shot up to 100°C and the fans were going at full blast. It sounded like a jet taking off!!). I was very pleased with the encoding speed. On my previous Quad-Core Hackintosh, 1080p would encode at about 6 fps. This was encoding at about 24 fps!! That is amazing in comparison to my Quad-Core i7 Retina MacBook Pro that gets about 27 to 28 fps!

All in all, this 2006 (now converted to 2007) Mac Pro was well worth it in terms of performance and price.

Unmatching CPUs

So it turns out, the processors I bought weren’t correctly matched. One would consistently run about 10 C hotter than the other one. Luckily, the guy I bought them from on eBay was able to exchange them for me. (Don’t worry, I gave him good feedback!).

I should be able to put the new processors in this weekend sometime. Stay tuned for an update!

Upgrading the CPUs in an Original Mac Pro

Recently, I had an original Mac Pro fall into my hands. It’s the Quad-Core 3Ghz model. It’s not a bad machine for being free! The interesting thing is that this old Mac Pro geekbenched higher than my Hackintosh that I made a few years ago. So I figured it was time to scrap the hackintosh and go with the real Mac!

The only caveat is that the original Mac Pro doesn’t “officially” support OS X Mavericks. However, with the help of some people over on forums of MacRumors.com I was able to get it installed. I needed to upgrade the graphics card though since Mavericks doesn’t support the GeForce 7300GT that came with the original Mac Pro. Luckily I had an old PC GeForce 8800GTS that works just fine in the Mac Pro (as long as you’re running Lion or higher!).

Specs Detailed Specs

One problem with this free Mac Pro was that it was missing the memory card cage and rear fan. I purchased one of those off eBay for $20. For the mean time I had to hold the memory riser cards up by using so electrical tape (see picture below). I wanted to get some extra performance out of this Mac Pro to put it in a closer category with my 2.6Ghz i7 Retina MacBook Pro so, naturally, upgrading the processors seemed like a great idea! Apple released an 8-core version of the original Mac Pro and dubbed it the MacPro2,1 (as opposed to the MacPro1,1). This official 8-core version used two 3Ghz Quad-Core Intel Xeon X5365’s.

Looking on eBay, the only X5365’s were close to $200! Most were being advertised as an upgrade kit for the original Mac Pro. I decided to look at some similar processors and settled on the Xeon X5355. This processor is literally the exact same as the X5365 but runs at the lower clock speed of 2.66Ghz. I found a matched pair on eBay for $60! So I purchased them, along with some Arctic Silver 5 thermal paste and 16GB of DDR2 RAM for $25 at the local computer shop. The upgrade process went smoothly!!

Here’s the upgrade process in pictures:

IMG_1494
Memory risers held up by electrical tape.
IMG_1499
The two massive heatsinks!
IMG_1500
Heatsinks removed
IMG_1501
Removing the original Xeon 5160’s
IMG_1502
New CPUs installed!
IMG_1504
Cleaned off the old thermal paste on the heatsinks
IMG_1505
Arctic Silver 5 applied
IMG_1507
Memory Cage installed!
IMG_1508
Final product! (Sorry the picture is a little blurry on this one!)

Results:

The new geekbench score blew the old one out of the water! All in all, even though this Mac Pro is close 8 years old now, it still is a very fast machine!! I’m excited to try and rip some of my blu-ray movies for the Apple TV!

UPDATE: CPU1 is running about 15 – 20 C higher than CPU2… I might need to reapply thermal paste to one of the processors. It could also be that I didn’t tighten down the heatsink enough. I will fix it and let y’all know the results!