Ubuntu 15.04 Remastering Custom ISO for Live USB

UPDATE: The script in this blog post is out of date. I created a new github repo for a shell script called remaster.sh which should help you remaster Ubuntu on Ubuntu. Go here to learn more: http://bad-programming.blogspot.com/2015/08/remaster-ubuntu-using-ubuntu-1404-or.html

These steps produce a ‘No-Op’ ISO. It appears to work for me in VirtualBox.

Original source: https://help.ubuntu.com/community/LiveCDCustomization#Install_pre-requisities

Next, I’ll perform some actual customizations.

Step 1:
# Make a parent directory for our Live USB
mkdir ~/livecdtmp
mv ubuntu-*.iso ~/livecdtmp
cd ~/livecdtmp

Step 2:
mkdir mnt
sudo su
# Mount the ISO as a loop filesystem to ~/livecdtmp/mnt
# This will allow us to look at its insides, basically
mount -o loop ubuntu-*.iso mnt
mkdir extract-cd
# Copy all the ISO’s innards except for filesystem.squashfs to extract-cd/
rsync –exclude=/casper/filesystem.squashfs -a mnt/ extract-cd
# Expand the squashed filesystem and put it into ~/livecdtmp/edit so we can update the squashed filesystem with our new values it needs to boot and install properly
unsquashfs mnt/casper/filesystem.squashfs
mv squashfs-root edit

Step 3:
mount -o bind /run edit/run
# This makes our terminal’s “perspective” come from ~/livecdtmp/edit/
chroot edit
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devpts none /dev/pts

export HOME=/root
export LC_ALL=C

Step 4:
# Normally this is where you’d do your customizations.
# I recommend copying from your main system’s /etc/apt/sources.list to your ISO’s sources.list.

Step 5:
# Back out of the chroot
umount /proc || umount -lf /proc
umount /sys
umount /dev/pts
umount /run
# exiting out of the chroot
exit
umount edit/dev

Step 6:
chmod +w extract-cd/casper/filesystem.manifest
chroot edit dpkg-query -W –showformat=’${Package} ${Version}n’ > extract-cd/casper/filesystem.manifest
cp extract-cd/casper/filesystem.manifest extract-cd/casper/filesystem.manifest-desktop
sed -i ‘/ubiquity/d’ extract-cd/casper/filesystem.manifest-desktop
sed -i ‘/casper/d’ extract-cd/casper/filesystem.manifest-desktop
rm extract-cd/casper/filesystem.squashfs
mksquashfs edit extract-cd/casper/filesystem.squashfs
printf $(sudo du -sx –block-size=1 edit | cut -f1) > extract-cd/casper/filesystem.size
nano extract-cd/README.diskdefines
cd extract-cd
rm md5sum.txt
find -type f -print0 | sudo xargs -0 md5sum | grep -v isolinux/boot.cat | sudo tee md5sum.txt
IMAGE_NAME=’Whatever name you want’
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 ../my-custom-ubuntu.iso .
chmod 775 ../my-custom-ubuntu.iso

Leave a Reply

Your email address will not be published. Required fields are marked *