How do I make a custom Ubuntu ISO for fully offline installations? [duplicate]
Solution 1:
Test this: Customise the Ubuntu Desktop CD Install the needed tools
sudo su
apt-get install squashfs-tools genisoimage
Download an official Desktop CD from http://releases.ubuntu.com/ Copy it into an empty directory
mkdir ~/livecdtmp
mv ubuntu-14.04.1-desktop-i386.iso ~/livecdtmp
cd ~/livecdtmp
Mount the Desktop .iso
sudo su
mkdir mnt
mount -o loop ubuntu-14.04.1-desktop-i386.iso mnt
Extract .iso contents into dir 'extract-cd'
sudo su
mkdir extract-cd
rsync --exclude=/casper/filesystem.squashfs -a mnt/ extract-cd
Extract the Desktop system & the SquashFS filesystem
sudo su
unsquashfs mnt/casper/filesystem.squashfs
mv squashfs-root edit
Prepare and chroot
sudo su
cp /etc/resolv.conf edit/etc/
cp /etc/hosts edit/etc/
mount --bind /dev/ edit/dev
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
Customizations Before installing or upgrading packages you need to run
dbus-uuidgen > /var/lib/dbus/machine-id
dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl
Remove, install & upgrade packages.
If you've modified the kernel, init scripts or added new kernel modules, you need to rebuild the initrd.lz file and substitute it into the casper directory.
sudo su
chroot edit mkinitramfs -o /initrd.gz 3.13.0-25-generic
(replace the kernel version with the one that the CD will boot with - this can be found in edit/lib/modules)
Exit from the chroot jail and move this file to extract-cd/casper:
exit
mv edit/initrd.lz extract-cd/casper/
Remove any temporary files which are no longer needed.
apt-get clean
Or
rm -rf /tmp/* ~/.bash_history
If you installed software, be sure to run
rm /var/lib/dbus/machine-id
&
rm /sbin/initctl
dpkg-divert --rename --remove /sbin/initctl
Unmount special filesystems and exit chroot
umount /proc || umount -lf /proc
umount /sys
umount /dev/pts
exit
sudo su
umount edit/dev
Producing the CD image and compress filesystem
sudo su
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 -comp xz -e edit/boot
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
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 ../ubuntu-14.04.1-desktop-i386-custom.iso .
Burning the image to CD
cdrecord dev=/dev/cdrom ubuntu-14.04.1-desktop-i386-custom.iso