3.2 KiB
Creating a LiveCD from an existing ISO
These instructions are condensed and simplified from the guide at https://help.ubuntu.com/community/LiveCDCustomization. Other information, like regional defaults, or changing the kernel used, can be found in that more complete guide.
-
Make sure you have squashfs-tools and genisoimage
sudo apt install squashfs-tools genisoimage
-
Extract the iso contents into a folder
mkdir mnt sudo mount -o loop _iso filename_ mnt mkdir extract-cd sudo rsync --exclude=/casper/filesystem.squashfs -a mnt/ extract-cd
-
Extract the Desktop system
sudo unsquashfs mnt/casper/filesystem.squashfs sudo mv squashfs-root edit
-
Mount the necessary volumes
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
To have network resolution in the chroot use:
sudo mount -o bind /run/ edit/run
-
(Optional) If you want to remove some of the installed software, to shrink the volume:
dpkg-query -W --showformat='${Installed-Size}\t${Package}\n' | sort -nr | less
This will give you a list of installed apps sorted by size. Remember to
purge
any apps you remove. Alternatively, you canrm-rf /tmp/* ~/.bash_history
. -
####Make all of the changes to the installed software and configuration here.
-
Unmount the volumes from within the chroot
umount /proc || umount -lf /proc umount /sys umount /dev/pts
Note that if `umount /proc` fails it will cascade to the bruteforce `umount -lf /proc`
7. Exit the chroot
```
exit
sudo umount edit/dev
```
If you added the network layer:
```
sudo umount edit/run
```
8. Assemble the file system
9. Regenerate the manifest
```
chmod +w extract-cd/casper/filesystem.manifest
sudo su
chroot edit dpkg-query -W --showformat='${Package} ${Version}\n' > extract-cd/casper/filesystem.manifest
exit
sudo cp extract-cd/casper/filesystem.manifest extract-cd/casper/filesystem.manifest-desktop
sudo sed -i '/ubiquity/d' extract-cd/casper/filesystem.manifest-desktop
sudo sed -i '/casper/d' extract-cd/casper/filesystem.manifest-desktop
```
2. Compress the file system
```
sudo rm extract-cd/casper/filesystem.squashfs
sudo mksquashfs edit extract-cd/casper/filesystem.squashfs
```
Alternately, for higher compression, try:
```
sudo mksquashfs edit extract-cd/casper/filesystem.squashfs -b 1048576
```
And for the highest possible compression:
```
sudo mksquashfs edit extract-cd/casper/filesystem.squashfs -comp xz -e edit/boot
```
3. Update the filesystem.size file, which is needed by the installer.
```
sudo su
printf $(du -sx --block-size=1 edit | cut -f1) > extract-cd/casper/filesystem.size
exit
```
2. Set an image name in extract-cd/README.diskdefines
```
sudo nano extract-cd/README.diskdefines
```
1. Create the new md5sum.txt
```
cd extract-cd
sudo rm md5sum.txt
find -type f -print0 | sudo xargs -0 md5sum | grep -v isolinux/boot.cat | sudo tee md5sum.txt
```
2. Creat the new ISO image
```
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 ../_new_iso_disk_image_name.iso .
```