Skip to content

Instantly share code, notes, and snippets.

@praveenbm5
Created June 25, 2015 17:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save praveenbm5/bea8171ff50e4114ec46 to your computer and use it in GitHub Desktop.
Save praveenbm5/bea8171ff50e4114ec46 to your computer and use it in GitHub Desktop.
Custom Xubuntu 15.04 ISO
#!/bin/bash
##################################
# Note:
# DO NOT EXECUTE THIS SCRIPT.
# THIS IS JUST A GUIDE.
#################################
##################################
# Assumes you are in ~/CustomCD
#
# Place any .deb packages / files
# in ~/CustomCD/offline to be
# copied and made available in
# CHROOT environment
#################################
##########################
# Setup
##########################
mkdir /tmp/livecd
sudo mount -o loop ~/Downloads/OS/xubuntu-15.04-desktop-amd64.iso /tmp/livecd
mkdir -p ~/livecd/cd
rsync --exclude=/casper/filesystem.squashfs -a /tmp/livecd/ ~/livecd/cd
mkdir ~/livecd/squashfs ~/livecd/custom
sudo modprobe squashfs
sudo mount -t squashfs -o loop /tmp/livecd/casper/filesystem.squashfs ~/livecd/squashfs/
sudo cp -a ~/livecd/squashfs/* ~/livecd/custom
##########################
# CHROOT
##########################
sudo cp -r ~/CustomCD/offline/. ~/livecd/custom/root/files/
echo "Copied offline files to /root/files ........."
sudo cp /etc/resolv.conf /etc/hosts ~/livecd/custom/etc/
sudo chroot ~/livecd/custom /bin/bash -l
##########################
# Setup CHROOT
##########################
mount -t proc none /proc/
mount -t sysfs none /sys/
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
ln -s /usr/share/initramfs-tools/scripts
##########################
# Install & Remove
# Packages / Kernel
# from CHROOT
##########################
dpkg -i /root/files/*
apt-get remove linux-image-3*
##########################
# Clean and Exit CHROOT
##########################
rm /var/lib/dbus/machine-id
rm /sbin/initctl
rm /scripts
dpkg-divert --rename --remove /sbin/initctl
rm -r /root/files
apt-get clean
rm -rf /tmp/*
umount /proc/
umount /sys/
exit
##########################
# Copy Kernel to Live CD
##########################
sudo cp ~/livecd/custom/vmlinuz ~/livecd/cd/casper/vmlinuz.efi
sudo gzip -dc ~/livecd/custom/initrd.img | sudo lzma -7 > ~/livecd/custom/initrd.lz
sudo mv ~/livecd/custom/initrd.lz ~/livecd/cd/casper/initrd.lz
##########################
# Create ISO
##########################
chmod +w ~/livecd/cd/casper/filesystem.manifest
sudo chroot ~/livecd/custom dpkg-query -W --showformat='${Package} ${Version}\n' > ~/livecd/cd/casper/filesystem.manifest
sudo cp ~/livecd/cd/casper/filesystem.manifest ~/livecd/cd/casper/filesystem.manifest-desktop
sudo mksquashfs ~/livecd/custom ~/livecd/cd/casper/filesystem.squashfs
sudo rm ~/livecd/cd/md5sum.txt
sudo bash -c 'cd ~/livecd/cd && find . -type f -exec md5sum {} +' > md5sum.txt
sudo mv md5sum.txt ~/livecd/cd/md5sum.txt
cd ~/livecd/cd
sudo mkisofs -r -V "Ubuntu Live" -b isolinux/isolinux.bin -c isolinux/boot.cat -cache-inodes -J -l -no-emul-boot -boot-load-size 4 -boot-info-table -o ~/Downloads/OS/xubuntu-15.04-4.1-MPC-desktop-amd64.iso .
sudo chmod 777 ~/Downloads/OS/xubuntu-15.04-4.1-MPC-desktop-amd64.iso
##########################
# Cleanup
##########################
sudo umount ~/livecd/squashfs/
sudo umount /tmp/livecd
rm -r /tmp/livecd
sudo rm -fr ~/livecd/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment