Revision of Customizing a Trisquel iso from Sun, 09/01/2013 - 16:13
The revisions let you track differences between multiple versions of a post.
To customize a Trisquel .iso image, you must first download it and place it in an empty directory. Open a terminal and go to that directory, then follow these steps. Note that your architecture must be same as the target, i.e. you cannot customize a 64 bit iso from a 32 bit system (beyond editing the preseed file).
Unpacking
- Become root. All commands below will be run as root.
sudo su
- Create an empty directory and mount the iso on it, then extract the contents:
mkdir tmp mount -o loop trisquel-original.iso tmp mkdir src rsync --exclude=/casper/filesystem.squashfs -a \ tmp/ src/ umount tmp
- Extract the squashed image files into casper/filesystem.squashfs:
mount src/casper/filesystem.squashfs \ tmp -t squashfs -o loop mkdir jail rsync -a tmp/ jail/ umount tmp
The Preseed File
Trisquel comes with a preseed file which allows preloading values into the debconf database. You can find the file at src/preseed/trisquel.seed. The file contains commented examples on the changes it can make, like changing the default locale, setting a static network configuration, or automagically installing an extra set of packages before the live-to disk install process (which you need internet access during the install to do).
Making Changes
Now you have the Trisquel system files in the jail directory, and you can start to apply changes.
First, we will backup some important files (Internet connection, data about mounted filesystems in the LiveCD and the repositories)
mkdir orig cp -a {edit,orig}/etc/hosts cp -a {edit,orig}/etc/resolv.conf
cp -a {edit,orig}/etc/mtab
tar cf orig/etc-apt-conf.tar -C edit/etc aptAlso the start-up scripts:
SCRIPTS="sbin/start-stop-daemon usr/sbin/invoke-rc.d usr/sbin/service" for i in $SCRIPTS do mv "$CHROOT/$i" "$CHROOT/$i.REAL" cat <<EOF > "$CHROOT/$i" #!/bin/sh echo echo "Warning: Fake /$i called, doing nothing" EOF chmod 755 "$CHROOT/$i" done cat <<EOF > "$CHROOT/usr/sbin/start" #!/bin/sh echo echo "Warning: Fake start called, doing nothing" EOF
cat <<EOF > "$CHROOT/usr/sbin/stop" #!/bin/sh echo echo "Warning: Fake start called, doing nothing" EOF chmod 755 $CHROOT/usr/sbin/start $CHROOT/usr/sbin/stop
- This is optional (copy your currently available packages to the new system and make a list of the packages that you have installed in your system):
rsync /var/cache/apt/archives/*.deb /edit/var/cache/apt/archives aptitude search --disable-columns -F '%p=%V %M' '~i' > \ installed.list aptitude search --disable-columns -F '%p=%V %M' '~M' > \ automatically-installed.list aptitude search --disable-columns -F '%p=%V %M' '~i !~M' > \ manually-installed.list aptitude search --disable-columns -F '%p=%V %c' '!~i !~v' > \ purged.listYou need to mount some parts of your current system to work and install packages:
mount -t proc none jail/proc mount -t devpts none jail/dev/pts mount -t sysfs none jail/sysTo install or remove packages, you need to enter the jail using chroot:
cp /etc/resolv.conf jail/etc chroot jailThe first command allows you to have network access. The second command puts you "inside" your new system.
You can now start doing the changes that you need. First update aptitude:
aptitude update aptitude install 0
- This is optional (update the hardware information from an Internet database):
update-pciids update-usbids
Cleaning up and setting your computer back to normal
You need to undo some of the changes that you have made to set your computer to work nicely when you are done. First, re-enable services within the system that you just created:
dpkg-divert --rename --remove /sbin/initctl SCRIPTS="sbin/start-stop-daemon usr/sbin/invoke-rc.d usr/sbin/service" for i in $SCRIPTS do mv "/$i.REAL" "/$i" done rm -f /usr/sbin/start rm -f /usr/sbin/stopThen, detach the created system from your actual computer
exit umount -fl jail/dev/pts umount -fl jail/dev umount -fl jail/sys umount -fl jail/proc
- This is optional (update gconf and kernel):
chroot jail update-gconf-defaults chroot jail update-initramfs -uIt is better if you remove the packages that you downloaded to make your ISO smaller and the compression faster
chroot jail apt-get clean chroot jail apt-get autocleanYou can also remove some useless files
find jail |grep [.-]old$ | xargs -r rm -v find jail |grep [.-]bak$ | xargs -r rm -v
for dir in jail/var/lib/update-notifier/user.d/ jail/var/lib/apt-xapian-index/ do [ -d $dir ] || continue find $dir -type f |xargs -r rm done
rm -rf jail/tmp/*You should now put the default Internet configuration and the table of mounted devices as they were in the LiveCD:
rm -f jail/etc/hosts jail/etc/resolv.conf jail/etc/mtab \ jail/root/.bash_history jail/root/.Xauthority \ jail/etc/resolvconf/resolv.conf.d/original \ jail/etc/resolvconf/resolv.conf.d/tail
rm -v jail/usr/lib/locale/locale-archive
cp -a orig/etc-hosts jail/etc/hosts cp -a orig/etc-resolv.conf jail/etc/resolv.conf cp -a orig/etc-mtab jail/etc/mtabIf you replaced the kernel or the boot scripts, copy the new kernel binary and initrd image as needed:
KERNEL="$(chroot jail echo `uname -r`)" cp "jail/boot/vmlinuz-$KERNEL" \ src/casper/vmlinuz cp "jail/boot/initrd.img-$KERNEL" \ src/casper/initrd cp jail/boot/vmlinuz-custom src/isolinux/vmlinuz cp jail/boot/initrd.img-custom src/isolinux/initrd
Repacking
After your modifications are done, you will need to rebuild the squashfs and .iso images. Install squashfs-tools:
apt-get install squashfs-tools genisoimage
- Update the list of packages and remove the old squashfs
chroot jail dpkg-query -W --showformat='${Package} ${Version}\n' > \ ./filesystem.manifest mv -f ./filesystem.manifest src/casper/filesystem.manifest
rm src/casper/filesystem.squashfsTo compress your new system into the squashfs file, you have four options:
1. Normal version (this will work with most BIOS)
mksquashfs jail src/casper/filesystem.squashfs2. Compact (using a bigger block size), but slower to compress
mksquashfs jail src/casper/filesystem.squashfs -b 1048573. More compact (with xz compressor) and slower to compress
mksquashfs jail src/casper/filesystem.squashfs -comp xz4. Really compact (using a bigger block size and xz compressor) and even slower to compress
mksquashfs jail src/casper/filesystem.squashfs -b 104857 -comp xzFor Trisquel 2.0 to 3.0 add -nolzma. This option was removed in Trisquel Awen 3.5. The option was to "use ZLIB compression method instead of LZMA", but ZLIB is now the default as shown in the man-pages.
- Update the information of the integrity of the files:
chmod 644 src/casper/filesystem.squashfs printf $(sudo du -sx --block-size=1 jail | cut -f1) > \ src/casper/filesystem.size nano src/README.TXT #if you want to edit your distribution README rm src/md5sum.txt cd src find . -type f -print0 | xargs -0 md5sum > md5sum.txt
- Finally, create a new .iso image (notice the dot at the end of the last line):
mkisofs -D -r -V "My Trisquel modified version" -cache-inodes \ -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot \ -boot-load-size 4 -boot-info-table -o ../trisquel-modified.iso .... and prepare the iso to be bootable by removable media other than CD:
cd .. isohybrid trisquel-modified.isoIf you want, you can also create a md5sum of your file:
md5sum "$outfile" > "$outfile".md5
Optional test
Install qemu
aptitude install qemu
- For a 64-bit system:
qemu-system-x86_64 -boot d -cdrom trisquel-modified.iso -m 512
- For a i386 (486 and 586) system:
qemu-system-i386 -boot d -cdrom trisquel-modified.iso -m 512If it runs well, congratulations, you are done! If it doesn't, review your steps or get in touch. To actually make a bootable CD or USB use Xfburn or the USB-installer (usb-creator-gtk.)
Please make clear to anyone you distribute your version to that it is not an official Trisquel .iso image. If any non-free software is included, please rename your project and do not use our logo.
In the making of this manual, some information was taken from d2 (david /at/ decotigny point fr, http://david.decotigny.fr/wiki/wakka.php?wiki=RemasterUbuntu) and http://devel.trisquel.info/makeiso/makeiso.sh
Attachment | Size |
---|---|
remaster_trisquel.sh | 17.71 KB |