1. Install the next packages (if not installed)
sudo apt-get install squashfs-tools genisoimage
2. Make a folder livecdtmp
mkdir ~/livecdtmp
3. Go to the folder
cd ~/livecdtmp
4. Make folders extract-cd and mnt
mkdir extract-cd mnt
5. Mount linuxmint-13-mate-dvd-32bit.iso (Download first of course)
sudo mount -o loop ~/linuxmint-13-mate-dvd-32bit.iso mnt
6. Move the image to the folder extract-cd
sudo rsync --exclude=/casper/filesystem.squashfs -a mnt/ extract-cd
7. Extract squashfs and move extracted to folder edit
sudo unsquashfs mnt/casper/filesystem.squashfs
sudo mv squashfs-root edit
8. Copy resolv.conf and mount /dev to the chroot-system. If there is no resolv.conf, make it first
nm-tool # Tells the DNS
sudo nano /etc/resolv.conf
nameserver here_your_primary_DNS
nameserver here_your_secondary_DNS
sudo cp /etc/resolv.conf edit/etc/
sudo mount --bind /dev/ edit/dev
9. Chroot to the system
sudo chroot edit
10. Mount and export things
mount -t proc none /proc && mount -t sysfs none /sys && mount -t devpts none /dev/pts
export HOME=/root && export LC_ALL=C
11. Update package cache
apt-get update
12. Query installed packages by size
dpkg-query -W --showformat='${Installed-Size}\t${Package}\n' | sort -nr | less
q gets you out from query
13. Edit the system (install/remove packages, etc.). When removing packages, use purge so that packages settings are disappearing also. An example:
apt-get purge ubiquity-slideshow-mint apt-xapian-index
apt-get install gnome-ppp
14. Clean the system and exit from chroot
apt-get clean
rm -rf /tmp/* ~/.bash_history
rm /etc/resolv.conf
umount /proc
umount /sys
umount /dev/pts
exit
15. Umount edit/dev
sudo umount edit/dev
16. Umount linuxmint-13-mate-dvd-32bit.iso
sudo umount mnt
17. Make ISO
sudo mksquashfs edit extract-cd/casper/filesystem.squashfs
sudo printf $(sudo du -sx --block-size=1 edit | cut -f1) > extract-cd/casper/filesystem.size
- Rename distro
sudo nano extract-cd/README.diskdefines
- Remove old md5sum and make new
cd extract-cd
sudo rm md5sum.txt
find -type f -print0 | sudo xargs -0 md5sum | grep -v isolinux/boot.cat | sudo tee md5sum.txt
- Build ISO
cd ..
sudo mkisofs -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 ../your_own_distro.iso extract-cd
18. Change permissions
cd
sudo chmod 777 your_own_distro.iso
19. Test the new distro using VirtualBox, Qemu, etc

