4

I'm re-posting this here because it's off topic on Askubuntu.

I installed Linux Mint 17.3, customized the theme, removed and added packages, made many changes to the file manager etc. I want to know an easy way to turn all of what I have done into a bootable ISO that I can distribute among my friends. I can get rematersys and relinix to create an ISO but for reason I can't get them to boot. I assume they are no longer supported because they haven't been updated in years. What can I use and how do I use it? Google brings up many guides but they lack information and are out of date.

Systemback was recommended as another alternative but returns this error:

Traceback (most recent call last):
File "/usr/lib/linuxmint/mintSources/mintSources.py",
    line 1455, in <module> codename = config_parser.get("general", "base_codename") 
File "/usr/lib/python2.7/ConfigParser.py",
    line 330, in get raise NoSectionError(section) ConfigParser.NoSectionError: No section: 'general
AReddy
  • 3,122
  • 5
  • 35
  • 75
Andrew H
  • 41
  • 1
  • 1
  • 2
  • http://superuser.com/questions/220125/create-an-image-file-of-a-running-linux-system –  Feb 08 '16 at 16:45

2 Answers2

7

I think you can do it with these steps (these are the first and second part of the step-by-step guide) ....

Preparing the host

sudo apt-get install squashfs-tools 
sudo apt-get install chroot

setting up our working environment. First, we are going to mount the iso under /tmp/livecd:

mkdir /tmp/livecd
sudo mount -o loop ~/Desktop/ubuntu-7.10-desktop-i386.iso /tmp/livecd

Then create a directory containing our future CD image (cd) in our working directory and copy all the CD content but casper/filesystem.squashfs in our ~/livecd/cd directory

mkdir ~/livecd
mkdir ~/livecd/cd
rsync --exclude=/casper/filesystem.squashfs -a /tmp/livecd/ ~/livecd/cd

Now we need to mount casper/filesystem.squashfs onto a directory called ~/livecd/squashfs in order to copy its content in a directory where we are going to edit our live CD filesystem: ~/livecd/custom

mkdir ~/livecd/squashfs
mkdir ~/livecd/custom
sudo modprobe squashfs
sudo mount -t squashfs -o loop /tmp/livecd/casper/filesystem.squashfs ~/livecd/squashfs/
sudo cp -a ~/livecd/squashfs/* ~/livecd/custom

And finally, let copy /etc/resolv.conf and /etc/hosts to our ~/livecd/custom/etc so we will be able to access network from within the image we are going to customize (through chroot)

sudo cp /etc/resolv.conf /etc/hosts ~/livecd/custom/etc/

Getting into our future image

In order to customize the image, we will chroot into ~/livecd/custom directory, mount some necessary pseudo-filesystem (/proc and /sys). From there, we will be able to customize our Live CD.

sudo chroot ~/livecd/custom
mount -t proc none /proc/
mount -t sysfs none /sys/
export HOME=/root

Customizing our future live CD

Remove some packages or something ...

Updating the existing image

Now that we have remove softwares we do not need, we can update our /etc/apt/sources.list in order to enable universe and multiverse repository along with gutsy-updates, gutsy-security and the partner repository so we can install vmware-server

vim /etc/apt/sources.list

(You can view the final file in the second link, at the top of that post)

Now we can update the image by running:

apt-get update
apt-get dist-upgrade

Installing new packages

Install some packages you want...

Well, that's about it, we now have whatever software that you will need when using your live CD. It is now about time to do some clean up

Cleaning up the chroot

When we install packages, apt caches the packages, we will need to remove them in order to save some space:

apt-get clean

Also, there is some files in /tmp that need to be removed:

rm -rf /tmp/*

Before chrooting, we have added 2 files: /etc/hosts and /etc/resolv.conf, let remove them:

rm -f /etc/hosts /etc/resolv.conf

Finally, we are ready to exit the chroot and repack the CD. We need first to umount /proc and /sys:

umount /proc/ 
umount /sys/
exit

Finally, we are back to our host, as we have modified some packages, we need to rebuild some manifest files, recreate the squashfs and recreate the ISO

Recreating the ISO

Fisrt, lets recreate the manifest files:

chmod +w ~/livecd/cd/casper/filesystem.manifest
sudo chroot ~/livecd/custom dpkg-query -W --showformat='${Package} ${Version}\n' > ~/livecd/cd/casper/filesystem.manifest
sudo cp ~/livecd/cd/casper/filesystem.manifest ~/livecd/cd/casper/filesystem.manifest-desktop

And regenerate the squashfs file:

sudo mksquashfs ~/livecd/custom ~/livecd/cd/casper/filesystem.squashfs
Parallel mksquashfs: Using 2 processors
Creating little endian 3.0 filesystem on ~/livecd/cd/casper/filesystem.squashfs, block size 65536.
....
....

Now, alternatively, you might want to customize the file: ~/livecd/cd/README.diskdefines and finally, update ~/livecd/cd/md5sum.txt which contains the files in ~/livecd/cd md5 sums:

sudo rm ~/livecd/cd/md5sum.txt
sudo -s
(cd ~/livecd/cd && find . -type f -print0 | xargs -0 md5sum > md5sum.txt)

We are now almost done, the last thing left is too create the ISO with the following command:

cd ~/livecd/cd
sudo mkisofs -r -V "Ubuntu-Live-Custom" -b isolinux/isolinux.bin -c isolinux/boot.cat -cache-inodes -J -l -no-emul-boot -boot-load-size 4 -boot-info-table -o ~/Desktop/Ubuntu-Live-7.10-custom.iso .

Here you go, you can now test your image by either booting your computer with or by using a virtualization/emulation software such as qemu, kvm, vmware.....

eduardogr
  • 215
  • 1
  • 7
  • Hi and welcome to the site! We expect answers to be more comprehensive here. Please [edit] your answer and explain what commands/programs the OP should use to create this image. Answering the question "how do I create an image" with "create an image" is not very useful. – terdon Feb 08 '16 at 17:29
  • 1
    Hi, is it better in this way? – eduardogr Feb 08 '16 at 18:08
  • 1
    Wow! Much better, thank you. You really put in a lot of work and +1 for effort! Sadly, I'm not sure how much this will help the OP. They want to make an ISO of their existing system. What you describe seems to be a method for modifying the default installation image. This is very useful, but is not a way of making an installable ISO based on the already installed system. – terdon Feb 08 '16 at 18:11