How to customize Linux Mint live cd/dvd

jahid_0903014
  8 years ago
  12

 

Disclaimer:

Customized Mint ISOs for personal use are fine. If you want to share your customization with others, whether for free or for purchase, you'll have to rename it; remove all Mint artwork, branding, and other identity elements; and you can't confuse your intended users about the customization being associated in any way with Mint.

You're free to use the Mint developed softwares (mintinstall, mintupdate, and so on) without renaming those, as they are licensed under GPL. But otherwise, it will be your own creation and no longer Mint's.

The Mint name and identity elements are trademarked and copyrighted. Unless you have approval from Clement Lefebvre and your customized ISO has passed Mint QA team's testing, you can't use those.

regards xenopeek, moderator at community.linuxmint.com


 

This tutorial is all about making a custom cd/dvd of Linux Mint from a fresh new official cd/dvd image. Download the image from the official download page of Linux Mint (latest is recommended). Now follow the steps below to make a customized Linux Mint cd/dvd image:

W: Don't type codes, just copy and paste and make necessary changes after. A simple typo can cause vital system damage.

Conventions adopted in this tutorial:

1. Text with greyed background means warning

2. Blue color means, this part of the code needs editing after copy paste

3. Italic texts means they are technical words/codes

4. Small italic texts means codes.

5. Some codes are so long that they couldn't end in a single line, watch out..

6. Texts appear after double slash (//) are comments not codes.

7. Red colored text tells you to pay serious attention to it

1. Install the required softwares:

sudo aptitude install squashfs-tools genisoimage

2. Prepare the temporary system:

 

linuxmint-17-cinnamon-64bit-v2.iso is used as the base iso image throughout this tutorial. Change the name according to the downloaded image.


mkdir ~/mylivecd

cp /path_to_the_downloaded_iso_directory/linuxmint-17-cinnamon-64bit-v2.iso ~/mylivecd

cd ~/mylivecd
mkdir mnt
sudo mount -o loop linuxmint-17-cinnamon-64bit-v2.iso mnt
mkdir extracted
sudo rsync --exclude=/casper/filesystem.squashfs -a mnt/ extracted
sudo unsquashfs mnt/casper/filesystem.squashfs
sudo mv squashfs-root edit


3. Prepare network connection in the temporary system:

sudo cp /etc/resolv.conf edit/etc/
sudo cp /etc/hosts edit/etc/


4. Prepare a chroot environment:
xhost +        //it will enable you to run GUI applications like synaptic but                       this will disable the x server access control, so use it at your own risk.
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
export HOME=/root
export LC_ALL=C


Now this terminal is in your new system. Don't close this in any circumstances. We will call this the chroot terminal and let's open another terminal and run

cd ~/mylivecd

su

and call this the host terminal. We will use this terminal when needed. You can differentiate between these two by comparing the command history. (This is very important, don't mix up these two terminals in anyway.)

Run codes in chroot terminal if nothing is specified about which terminal to use.

5. Preparing customization:

dbus-uuidgen > /var/lib/dbus/machine-id

dpkg-divert --local --rename --add /sbin/initctl

ln -s /bin/true /sbin/initctl

6. Now customize at your hearts content:

The filesystem is now the "edit" folder inside "mylivecd" directory. You can modify this filesystem to meet your needs. But you only have access to the chroot terminal. So make sure you can do everything with only a terminal. You can use this terminal to run GUI applications too.

To view installed packages by size:

dpkg-query -W --showformat='${Installed-Size}\t${Package}\n' | sort -nr | less

 


6.1 Installing softwares:

 

First update the repository (in chroot terminal):

apt update

Install softwares from the chroot terminal by:

apt install some-package
or
aptitude install packag1 package2 ....
or
dpkg -i some_package.deb

or

synaptic

then use synaptic package manager to install software.You can run other GUI applicaions too.

If you use synaptic then you will probably need to delete the edit/home/* manually and also delete the edit/run/synaptic.socket in the cleaning step.


In this case the some_package.deb must be located somewhere inside the "edit" directory. So copy the deb files that you want to install by dpkg to a location inside that edit folder and use correct path to the files or use my conventions as below (in chroot terminal):

mkdir /mydir
chmod -R 777 /mydir
cd /mydir


Now use your file manager (open as root) to copy files for your packages to this folder or you can use the host terminal too (to copy files here). Now you can use the chroot terminal to install softwares from that directory (.deb files or source). To install softwares you can see the methods written in this tutorial:
Installing softwares in linux
and to get a menu entry for the installed software (if it doesn't have any by default) you can see my other tutorial:
Adding menu item in linux mint

If you have the latest .deb packages then you can copy them into the "/var/cache/apt/archives" directory so that you will be able to install them with the

apt install package_name

command in chroot terminal without downloading them. But if they are not latest, then this will do no good at all.

To install all the .deb packages in any directory simply run in chroot terminal:

cd path_to_that_directory
dpkg -i *.deb



6.2 You can do other types of modifications as you have full access to the whole filesystem, if you know how to do it in any regular distro. The main problem is, you have no GUI (Desktop) for making modifications, all there is to edit the config files and the filesystem to modify everything. So you need to be sure about the modifications that they will work correctly beforehand.

6.3 Kernel installation (optional):

First install any kernel (see this for reference) with the chroot terminal then to boot this kernel in live cd/dvd run these codes in the host terminal:

cp edit/boot/vmlinuz* extracted/casper/vmlinuz
cp edit/boot/initrd.img* extracted/casper/initrd.lz


If you install more than one kernel then replace * in the above two commands with correct version codes.

6.4 At last, run this code in chroot terminal to make sure the Linux mint installation application (in live dvd/cd) is up-to-date:

apt install ubiquity-frontend-gtk

7. Cleanup your new system:


aptitude clean
rm -r /var/cache/apt/archives/*
rm -r /mydir
rm -rf /tmp/* ~/.bash_history
rm /var/lib/dbus/machine-id
rm /sbin/initctl
dpkg-divert --rename --remove /sbin/initctl


umount /proc || umount -lf /proc                   //ignore warning in this command
umount /sys
umount /dev/pts

exit                                                                  //if fails try exit 0                      
sudo umount edit/dev                                  //ignore error/warning in this command

xhost -

If you used synaptic (or any other GUI) then you will probably need to do this extra cleaning:

sudo rm -rf edit/run/synaptic.socket

sudo rm -rf edit/home/*

From this moment the chroot environment is no more, but this terminal will be used for the rest of the commands, you can close the other (host) terminal.


8. Regenerate manifest (ignore any warning):
su
chmod +w extracted/casper/filesystem.manifest

chroot edit dpkg-query -W --showformat='${Package} ${Version}\n' > extracted/casper/filesystem.manifest

cp extracted/casper/filesystem.manifest extracted/casper/filesystem.manifest-desktop

sed -i '/ubiquity/d' extracted/casper/filesystem.manifest-desktop
sed -i '/casper/d' extracted/casper/filesystem.manifest-desktop


9. Compress:

rm extracted/casper/filesystem.squashfs
mksquashfs edit extracted/casper/filesystem.squashfs -comp xz


10. Update some required files:
 

printf $(sudo du -sx --block-size=1 edit | cut -f1) > extracted/casper/filesystem.size
 

open extracted/README.diskdefines file with a text editor and change the name of the disk.

Remove old md5sum and calculate new md5sums:

cd extracted
rm MD5SUMS
find -type f -print0 | sudo xargs -0 md5sum | grep -v isolinux/boot.cat | sudo tee MD5SUMS


11. Create the ISO image:
 

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 ../Linux-Mint-cinnamon-x64_custom.iso .

exit

sudo chmod 777 ~/mylivecd/Linux-Mint-cinnamon-x64_custom.iso

12. Test the ISO image:
 

You can use qemu, kvm, virtualbox for a test run of the iso or you can use your physical computer for testing (making a live usb or burning the iso to cd or dvd). If everything is satisfactory then you can make this  a final release of your new custom Linux Mint dristro.

 

13. Other ways:

You can use customization tools to do all the hard works and prepare you the chroot terminal for modification. I know of two tools that can do such thing:

13.1 One is developed by me and all CLI based: JLIVECD

I have tested it in:

  • LM 17 cinnamon
  • LM 17 xfce
  • Xubuntu 14.04.1
  • Ubuntu 14.04.1 LTS
  • Ubuntu 14.04.3 LTS

It is expected to work with Ubuntu and it's derivatives.
 

13.2 And the other is Ubuntu customization kit (uck) which uses GUI for taking user preferences. It's in the repo. You can install it by running

apt install uck

I haven't tried it......yet.....

 

Reference: help.ubuntu.com

Comments
zpangwin 5 years ago

Thanks jahid_0903014 for this tutorial. Still working great for me under Mint 19.

One thing I've been curious about for awhile just in case anybody happens to know... I've noticed for some time now that gparted is installed on the live disc itself but is never installed on any target system when I run the install wizard off the live disc.

Any clue how I could change this behavior so that I not only have gparted on the livedisc but so that it is also automatically installed on any new system that I use the live disc installer on?

I have searched for this a few times but never found anything so guessing that either my google foo is weak, its some obscure setting that is not well documented, or gparted is explicitly removed by the install wizard.


revian 6 years ago

The JLIVECD works perfectly for Linux Mint 18.2 Cinnamon. Thank you!


jahid_0903014 8 years ago

And also, "Rerun JLIVECD using the remastered iso as base iso and examine the file structure. "
You don't need to do that. JLIVECD works on project basis. Every project with all of its changes are saved in the directory specified. You can just skip to the chroot and make more changes or examine things, whatever you want.


jahid_0903014 8 years ago

@ictskills 
There's an option to add user with Jlivecd. After exiting from chroot you will be prompt: "Want to retain the home directory? Y/n". You need to give it "y" to keep the home directory intact. The default option deletes the home directory.


jahid_0903014 9 years ago

Look at the additional info section on this page:
http://mdjahidulhamid.github.io/JLIVECD


jahid_0903014 9 years ago

very comprehensive solution, @CRomer . Thnks, I will try that when i experiment on cinnamon again..


CRomer 9 years ago

Using Cinnamon for my build (linuxmint-17-cinnamon-64bit-v2). Here is what I found (adapted from older UCK instructions and the schema reference), in case anybody else needs it.

1) To set the values for the Themes panel, while customizing the Live CD in chroot:
nano /usr/share/glib-2.0/schemas/linuxmint-artwork.gschema.override
[org.cinnamon.desktop.interface]
gtk-theme='Mint-X' \\ Controls in Other tab
icon-theme='gnome' \\ Icons in Other tab
clock-use-24h=false \\ Add if you want 12h clock

[org.cinnamon.desktop.wm.preferences]
theme='Mint-X' \\ Window Borders in Other tab

[org.cinnamon.theme]
name='Linux Mint' \\ Theme in Theme tab

2) Compile after changed, in chroot
glib-compile-schemas /usr/share/glib-2.0/schemas

3) Before running "apt-get upgrade" in chroot, put the following on hold (can use "unhold" after). These are marked by MintUpdate as dangerous, and were causing issues in the Cinnamon 64bit distro.

sudo apt-mark hold dbus dbus-x11 libdbus-1-3 libdbus-1-3:i386 linux-firmware linux-headers-3.13.0-24 linux-headers-3.13.0-24-generic linux-image-3.13.0-24-generic linux-image-extra-3.13.0-24-generic linux-libc-dev libpam-systemd


jahid_0903014 9 years ago

And I have been succeeded to change the theme and icon so that it works in live system and also the panel preferences and custom launchers in panel, and window decoration settings, thunar (file manager) custom actions, and preferences of my favourite softwares..

All these were in xml files except the software configs. For those you just need to copy the folders from /home/user to edit/etc/skel and delete any user specific identification files


jahid_0903014 9 years ago

And about copying config files from host system to chroot system, always be careful not to copy user specific files and not those files which uses the username to work correctly.

Though xml files are always safe


jahid_0903014 9 years ago

In xfce,
the window management configs are in xfwm4.xml file
the theme and icon configs are in xsettings.xml file

These files are in /home/user/.config/xfce4/xfconf/xfce-perchannel-xml/


jahid_0903014 9 years ago

The configuration for themes, icons and window decoration are generally written in xml files. As I am using xfce now, thery are in /home/user/.config/xfce4 directory.


jahid_0903014 9 years ago

this may help:
change settings in host system. It will create some files/folders in your home directory, copy them with relevant parent directory in edit/etc/skel directory. Whatever you put here (edit/etc/skel) will be copied into new users home directory and the configurations will be applied as well.


jahid_0903014 9 years ago

this may help:
change settings in host system. It will create some files/folders in you home directory, copy them with relevant parent directory in edit/etc/skel directory. Whatever you put here (edit/etc/skel) will be copied into new users home directory and the configurations will be applied as well.


CRomer 9 years ago

...and I just realized I said "install", which I am also working on with UCK. Those notes were in my JLiveCD, but I will double check to make certain I am not confused.


CRomer 9 years ago

I tried "cinnamon-settings themes" and also:
gsettings set org.cinnamon.desktop.interface icon-theme 'gnome'

These are accepted, but don't persist for the install. I believe what I want is in distro.conf, in the [gui] section. Looking for the GTK icons config option but can't find it.


jahid_0903014 9 years ago

you can run the settings manager in chroot. try if changing there changes anything...


CRomer 9 years ago

Jahid, can you point me in the right direction for setting the Icons to gnome for the Live CD/USB? Is this still done with xinitrc, or is there an improved method in Mint 17? Having a devil of a time finding this info, and I'm so close to my ultimate customization! :)


jahid_0903014 9 years ago

As you have synaptic now, you can install/uninstall languages by searching them in synaptic. And if you want to make something default then you need to find the configuration files that are used to make the configurations default. You can use graphics applications too and use them to change system configuration as you wish, but you need to be clever and knowledgeable enough to know what can be changed and what can' be.


piro_eu 9 years ago

Nice tutorial and well explained,
for customization of languages, and the azerty keyboard in the terminal and graphics applications, have you any ideas?
Thanks


CRomer 9 years ago

Jahid,

The update/upgrade issue appears to be D-Bus and kernel updates. I tried with UCK as well, with no change. I noticed that 3.13.0.24-47 (over 46) update was failing, and nothing I tried could get that to work. When I checked my other machines, I noticed that MintUpdate has these updates flagged as dangerous (level 4/5).

I tried getting Cinnamon up in chroot. It crashes to fallback mode on my environment. MintUpdate crashes immediately after you click Update as well (either in fallback mode or from chroot command line). So I used synaptic to update Cinnamon and some other components. The resulting iso from this approach works fine.

I'll go with this partially updated Live CD for now. Hopefully they fix the D-Bus/kernel update, or I can get MintUpdate to run and update everything else. Until then, this will work fine.

Thanks for the help!


CRomer 9 years ago

Robdog, did you copy the entire line with the trailing period (editing the name in blue).

Also, give his JLiveCD utility a shot? Much easier.


CRomer 9 years ago

Thank you for all the info. Building a community center lab and instructing later (both projects with Mint), but I'll have time to work through this tomorrow (Friday). The Live USB environment is for a class at up to 15 public library labs which have Windows computers that can't be changed :)


jahid_0903014 9 years ago

There are some interesting things though, which I haven't mentioned in my tutorial. Like you can run the whole system (cinnamon session) in chroot terminal. first you need to run synaptic (it will create a home directory in your subsystem), then the required command to run the cinnamon session. The code which needs to be run is: x-session-manager. It will run an x session over your existing session with the default settings in your subsystem. You will not be able to close this session without closing the chroot terminal.

I haven't investigated the usefulness of this option yet.


jahid_0903014 9 years ago

and there are other things like rebuilding the initrd, If your upgrade inserted new driver modules or changed the init scripts then you need to rebuild the initrd. If the subsystem and host system has same kernel version then JLIVECD will automatically rebuild it, but if not, it will prompt for manual entry (you will need to enter the kernle verison). And if your upgrade has installed new updated kenel like 3.13.0-24 to 3.13.0-35 or something like that, then it's best to use the option which says "have you installed new kernel and want to boot it in livecd (Y/n)?: " It will take care of any kenel/module change and init script or boot theme change.

And I have updated the JLIVECD several times and finalized it 4 days ago, which takes care of a serious mistake of leaving the edit/home directory not empty and added timer for user input (for my own convenience though). So if you are using JLIVECD downloaded more than 4 days ago, then you should use the latest one.


jahid_0903014 9 years ago

If you are talking about dbus, then probably edit/home directory isn't empty...
It should be empty for normal cases. Check if it's true...


CRomer 9 years ago

The files you suggested looked good, so I dug back through SYSLOG. I would have tried this sooner had I realized the trackpad drivers weren't loading (external mouse works), making it seem that the UI was more hung than it was. I had tried an HP and Dell, yet both were laptops.

In syslog I found "the permission of the setuid helper is not correct" when trying to start PolicyKit1. After some digging, I found the following command to fix properties on the helper:
sudo chmod u+s /usr/lib/dbus-1.0/dbus-daemon-launch-helper

I was able to test this without rebuilding, since I am using a persistent Live USB. It works, but there are still some things not loading. I'll copy off the syslog from the fully working non-upgraded environment, and compare.

Both of the fully working non-upgrade and partially working upgrade environments were built with JLiveCD, and then Universal USB Installer (UUI) to USB. The upgrade was done from the existing build (i.e. Is this a fresh start? N). I was finding the same UI issue when I followed the manual steps though when I used upgrade. This info is all FYI, as this could very much be me or UUI doing something still.


jahid_0903014 9 years ago

There might be some problem with the x-session-manager. Some packages automatically change the link of x-session-manager to a DE which is only relevant to that package, like nautilus in xfce will change the link to gnome-session while it's not even installed. You can check if that's the case. Go to edit/etc/alternatives and find x-session-manager and check the link target. you might also check the link in edit/usr/bin/x-session-manager (which generally points to edit/etc/alternatives/x-session-manager). For cinnamon all this links should finally point to cinnamon session, not anything else.

But as I remember there's no problem of upgrading with the v2 iso (with codecs). And you shouldn't use that xfce fix if there is no error report like xfce.

Or you can check the upgrade process from the terminal history, it will tell you if it has changed some of the links. Or you can post the output of apt upgrade to the forums and give me the link of your post, or you can post it to some site like pastebin.com and give me the link, so I can check it out.


CRomer 9 years ago

Jahid,

Thank you for all the hard work. I've used the manual process and JLiveCD option multiple times now. Both work lovely, especially in conjunction with UUI (persistent storage on USB, YES!).

I haven't been able to get UPGRADE to create a usable environment in 17v2 Cinammon 64bit w/ codecs. It will boot, but fails to fallback mode at the desktop. I also tried the XFCE upgrade fix, in case it was relevant. The environment I have without upgrade works nifty.

Thoughts or feedback very welcome.


jahid_0903014 9 years ago

I have developed a Live cd/dvd customization tool based on this tutorial to make the hard task easy. If anyone is interested, it's on the github:
repository
Download


jahid_0903014 9 years ago

In Linux Mint 17 XFCE there's a little bug. To fix this edit /usr/sbin/invoke-rc.d file (in chroot) as:
replace exit 100 with exit 0 at line 285 and 421, then apply upgrade. after upgrading revert this modification (must).

more info on this bug


jahid_0903014 9 years ago

Tanks @interknighterrant, for your suggstion. But if this command is DE specific then I will be needing all of them. Actually I need a generic one, if there is a command like that to work on all terminals....

And you have pointed out a pretty major thing that can cause vital errors if some commands are misplaced. So i will add a warning to not mix up these twor terminals in anyway......
thnx again..


jahid_0903014 9 years ago

Thanks, @xenopeek


xenopeek 9 years ago

Customized Mint ISOs for personal use are fine. If you want to share your customization with others, whether for free or for purchase, you'll have to rename it; remove all Mint artwork, branding, and other identity elements; and you can't confuse your intended users about the customization being associated in any way with Mint.

You're free to use the Mint developed software (mintinstall, mintupdate, and so on) without renaming those, as they are licensed under GPL. But otherwise, it's now your creation and no longer Mint's.

The Mint name and identity elements are trademarked and copyrighted. Unless you have approval from Clement Lefebvre and your customized ISO has passed Mint QA team's testing, you can't use those.