Revision of Customizing a Trisquel iso from Tue, 09/05/2023 - 06:38
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).
Contents
[hide]
- 1 Unpacking
- 2 The Preseed File
- 3 Making Changes
- 4 Cleaning up and setting your computer back to normal
- 5 Repacking
- 6 Optional test
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 rsync -a tmp/ src/ umount tmp
Extract the squashed image files from casper/filesystem.squashfs. Also, create a 'jail' directory (to restrict the commands for the new configuration to affect your own system). This is where most changes take place:
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 -pL {edit,orig}/etc/hosts cp -pL {edit,orig}/etc/resolv.conf
cp -pL {edit,orig}/etc/mtab
tar cf orig/etc-apt-conf.tar -C edit/etc apt
Also 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
The above commands backup and remove the programs that start or set-up some services that run when you start-up your computer. If you are curious, you can type 'man cat' and 'man sh' in your terminal. Then press / and then some words that you would like to find (for example << while reading the manual of sh; this is the procedure to know how almost any linux command works).
- This is optional and you don't really have to do it (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' '~i' > installed.list aptitude search --disable-columns -F '%p=%V %M' '~M' > jail/automatically-installed.list aptitude search --disable-columns -F '%p=%V %M' '~i !~M' > jail/manually-installed.list aptitude search --disable-columns -F '%p=%V %c' '!~i !~v' > jail/purged.list aptitude search --disable-columns -F '%p=%V' '!~aupgrade' > jail/tobe-upgraded.list
If you want to know what all this gibberish means, type 'aptitude' in your terminal, press CTRL T, go to 'Help' and select the manual. When you are there, you can press / to look for each of the terms (try %c, for instance.)
You 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/sys
To install or remove packages, you need to enter the working directory using chroot:
cp /etc/resolv.conf jail/etc chroot jail
The first command allows you to have network access. The second command puts you "inside" your new system.
It may be necessary to update your locale to run some (python) code:
aptitude update aptitude upgrade locales grep en_US /usr/share/i18n/SUPPORTED > /etc/locale.gen locale-gen en_IE.UTF-8 dpkg-reconfigure locales LC_ALL="en_IE.UTF-8" LANG="en_IE.UTF-8" LANGUAGE="en_IE.UTF-8" export LC_ALL LANG LANGUAGE
You can now start doing all the changes that you need. You could install a 'package', for example:
aptitude install package # Install 'package'
- Optionally, if you created the list of packages which are installed in your current system, you can set them in the new system like this (and be ready to deal with unmet dependencies):
aptitude --schedule-only upgrade $(cut -d'=' -f1 /tobe-upgraded.list) aptitude --schedule-only purge $(cut -d'=' -f1 /purged.list) aptitude --schedule-only install $(cat /installed.list) aptitude markauto $(awk 'BEGIN{FS="="} {print $1}' /automatically-installed.list) aptitude install
Note how we didn't really use the 'manually-installed.list'. The intention is to learn a little along the way. Hopefully, you will search for the meaning of the commands posted here.
- Update the hardware information from an Internet database (this is optional and not completely required):
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/stop
Then, 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), but you should do it if you installed or modified a (working) kernel:
chroot jail update-gconf-defaults chroot jail update-initramfs -u
- This is also optional and not completely needed. It 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 autoclean
- You can also try to remove some useless files if you want, but you are not compelled to do it (optional)
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 -p orig/etc-hosts jail/etc/hosts cp -p orig/etc-resolv.conf jail/etc/resolv.conf cp -p orig/etc-mtab jail/etc/mtab
If you replaced the kernel or the boot scripts with a working one, 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.squashfs
To 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.squashfs
2. Compact (using a bigger block size), but slower to compress
mksquashfs jail src/casper/filesystem.squashfs -b 104857
3. More compact (with xz compressor) and slower to compress
mksquashfs jail src/casper/filesystem.squashfs -comp xz
4. Really compact (using a bigger block size and xz compressor) and even slower to compress
mksquashfs jail src/casper/filesystem.squashfs -b 104857 -comp xz
For 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.iso
- If you want, you can also create a md5sum of your file, which is optional. You can use this later to make sure that your distribution hasn't been compromised:
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 512
If 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, [1]) and https://gitlab.trisquel.org/trisquel/makeiso/-/raw/master/makeiso.sh
Attachment | Size |
---|---|
remaster_trisquel.sh | 18.78 KB |