Sysresccd-manual-en How to personalize SystemRescueCd
Being able to make one's own version of SystemRescueCd is a frequently requested feature. By combining the restoration software and your backups you can make your own system and data recovery disk. The recovery software is already part of the standard SystemRescueCd so the most important thing to add is your backups and you may also add your own scripts to make the recovery procedure automatic. All you need is a recent SystemRescueCd and some space on your hard drive.
This means you can add files to the
sysrcd.dat compressed image file, which is the file system of SystemRescueCd. For example, you can add script files that make a full backup of a server, or a binary program that you need. It's also possible to add data files, in order to have everything on the CDRom (data and system files which allow you to restore data). For now, it's not possible to change the kernel. If you need a kernel improvement, please submit requests in the forums.
The goal is to produce a new ISO image file, with an updated
sysrcd.dat. You will need a recent official version of the SystemRescueCd CDRom, and a partition with read-write access from within linux, with at least 1.5 GB. If you add additional items you may need more space.
This operation requires a large amount of memory (both RAM and space on the hard disk). If you don't have 256 MB of RAM, and at least 1.5 GB free on your hard disk, it will fail. You can create a swap partition in order to avoid problems with the squashfs step in the script.
You may also be interested in a procedure which explains how to build a SystemRescueCd with your own kernel. Basically, you first compile a new kernel, and then you make a customized CD using the new kernel and its modules.
Personalization is processed from the CDRom system with a script. This means you must burn an official SystemRescueCd version, boot from an official version, and then make your own version. The script runs from the CDRom system. All necessary files are included.
Assume that the
/dev/sda1 partition is formatted for linux (ext3, ext4, xfs, btrfs, ...), and that it has at least 1.5 GB free.
It must be a linux filesystem, because other filesystems, such as FAT, NTFS don't support symbolic links and file permissions.
If you only have a FAT partition available, create a virtual linux filesystem image inside the FAT partition:
mkdir /mnt/fat mount /dev/sda1 /mnt/fat cd /mnt/fat dd if=/dev/zero of=/mnt/fat/fsimage bs=1M count=1500 mkfs.ext4 -F -q /mnt/fat/fsimage mount -t ext4 -o loop /mnt/fat/fsimage /mnt/custom
If you used the
docache boot option, the original SystemRescueCd disc must be mounted when you run the first step (extract) of the script.
This procedure makes the directory
customcd at the root of this partition. Files located in other directories won't be affected by this script. If you have an old version of a personalized CDRom in this directory, make a backup. All files of
/dev/sda1/customcd/ will be lost! You must use the name
/mnt/customcd since the script expects that.
Post questions about the customization in this section of the forums: http://www.sysresccd.org/forums/viewforum.php?f=25
Step-01: Mount the working partition
% mkdir /mnt/custom % mount /dev/sdan /mnt/custom
If you don't want the main temporary directory to be written to the root of /mnt/custom, choose another directory. For example, if the free space is on an NFS share, use:
% mount -o bind /mnt/nfs/remote-directory /mnt/custom
Step-02: Extract the current files from the sysrcd.dat image
% /usr/sbin/sysresccd-custom extract
/mnt/custom is mounted -> ok
there is enough estimated free space here (.... MB) -> ok
You might want to press
[Alt][F4] to switch to another virtual console and run
df to see that it is still running. ( This has been known to take over 15 minutes from a cached sysresccd !)
If there are no errors, the files have been copied to /mnt/custom/customcd/files/ with isoroot containing about 43MB and files containing about 835MB.
% du --max-depth=1 -h
Step-03: Customize (optional)
You can do this from the SystemRescueCd, or restart and do it from another installed linux system. If you choose to restart, you must restart from the SystemRescueCd, and mount
custom partition again (step-01 ). All the changes must be made in
/mnt/custom/customcd/files/ This is the root of the new filesystem.
Step-04: Add your own packages (optional)
You can add new packages to SystemRescueCd using the Gentoo-Linux advanced package management tools. In other words, if you need a program which is not provided with the official SystemRescueCd, and if this package is supported by Gentoo, then use the Gentoo commands such as
equery to manage the packages. Gentoo is based on the sources, so these tools will automatically download the sources and compile the program and all its necessary dependencies.
Step-04a: Requirements to compile programs
SystemRescueCd comes with development tools (such as gcc, automake, autoconf, cmake, ...) which are necessary to compile programs. Header files are also included. For instance, installing and compiling a GTK program requires the GTK header files. That's why important header files are included on the official SystemRescueCd. If you install a program which has other dependencies, and header files have been removed to save space, reinstall dependencies even if they are already part of the system according to the package management system.
Here is the basic information for using the Gentoo tools. In case of problems or for more advanced usage, read the official Gentoo documentation which is very well written.
The Gentoo package management system is based on portage. It provides support for each package that can be installed. The support is implemented as an ebuild script which contains all the instructions required to download the sources, the dependencies, and to compile and install packages. The portage ebuilds are stored in /usr/portage which is about 400MB uncompressed, so it's not included in the official SystemRecueCd. You will have to download and extract the new portage.
Don't forget that you may need a large amount of space to compile and install the new packages and their dependencies. Having several Gigabytes of free space in /mnt/custom is recommended.
You need an internet connection to download a recent portage tarball and the sources of the packages. If the computer you are working on is not connected to the internet, download the needed files somewhere else and copy the files by hand (using a USB-stick for instance). The sources of the packages have to be copied into /usr/portage/distfiles in the chrooted SystemRescueCd. This directory will be accessible in /mnt/custom/customcd/files/usr/portage/distfiles if you have followed the procedure correctly.
Step-04b: Download and extract a recent portage snapshot
Download a recent portage snapshot archive. Gentoo rebuilds the archive every day, so the best portage you can have is from the day before. The archive is named portage-YYYYMMDD.tar.bz2. You can also download the xz version which has a better compression ratio to save bandwidth and download time. Here is an ftp mirror
Create the directory where the files will be uncompressed: % mkdir -p /mnt/custom/customcd/files/usr/portage/distfiles
Extract the bzip2 version (good compression):
% tar xfjp /path/to/portage-YYYYMMDD.tar.bz2 -C /mnt/custom/customcd/files/usr/
-or- the xz version (very good compression):
% tar xfJp /path/to/portage-YYYYMMDD.tar.xz -C /mnt/custom/customcd/files/usr/
To verify portage has been uncompressed at the right place, check
% du -s /mnt/custom/customcd/files/usr/portage/sys-kernel/vanilla-sources
Step-04c: Chroot in the sysresccd environment
The installation commands have to be executed from the temporary SystemRescueCd. For that reason, we have to run in a chrooted environment:
% mkdir -p /mnt/custom/customcd/files/proc % mkdir -p /mnt/custom/customcd/files/dev % mkdir -p /mnt/custom/customcd/files/sys % mount -o bind /proc /mnt/custom/customcd/files/proc % mount -o bind /dev /mnt/custom/customcd/files/dev % mount -o bind /sys /mnt/custom/customcd/files/sys % chroot /mnt/custom/customcd/files /bin/bash % gcc-config $(gcc-config -c)
You can check that you are in the chrooted environment by listing the ebuild for the vanilla sources:
% ls -l /usr/portage/sys-kernel/vanilla-sources
To leave the chrooted environment, type
exit from the shell (don't do that now), and
% umount /mnt/custom/customcd/files/proc % umount /mnt/custom/customcd/files/dev % umount /mnt/custom/customcd/files/sys
Step-04d: How to install a new package
Now, let's install a new package. You can see all the supported packages in /usr/portage/profiles. Packages are in categories such as app-editor and each supported version is implemented in a separate ebuild file. As an example, we will install leafpad lightweight text editor based on GTK.
You can see the following ebuild script:
This is the script which will be used when we install this package.
First, we run
emerge with -p and -v to see what other packages are needed and how it would compile:
# emerge -pv app-editors/leafpad These are the packages that would be merged, in order: Calculating dependencies... done! [ebuild N ] app-editors/leafpad-0.8.14 USE="-emacs" 264 kB Total: 1 package (1 new), Size of downloads: 264 kB
It means that this is a new package (flag 'N'), and all the dependencies are already installed.
You can now download all the source files which are required to compile this program:
# emerge -f app-editors/leafpad Calculating dependencies... done! >>> Fetching (1 of 1) app-editors/leafpad-0.8.14 for / >>> Downloading 'http://distfiles.gentoo.org/distfiles/leafpad-0.8.14.tar.gz' --2008-07-27 15:22:33-- http://distfiles.gentoo.org/distfiles/leafpad-0.8.14.tar.gz Resolving distfiles.gentoo.org... 188.8.131.52, 184.108.40.206, 220.127.116.11, ... Connecting to distfiles.gentoo.org|18.104.22.168|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 269496 (263K) [application/x-gzip] Saving to: `/usr/portage/distfiles/leafpad-0.8.14.tar.gz' 100% [===============================================>] 269,496 223K/s in 1.2s 2008-07-27 - `/usr/portage/distfiles/leafpad-0.8.14.tar.gz' saved [269496/269496] * leafpad-0.8.14.tar.gz RMD160 SHA1 SHA256 size ;-) ...
If you have no internet access on this machine, the download will fail. You can just copy the URL, download it on another machine, and copy the file into
/usr/portage/distfiles/ (location in the chrooted environment). You don't have to run
emerge -f before you install a new package, in that case emerge will download it at install time.
To install the package, just run emerge on that package with no option:
# emerge app-editors/leafpad Calculating dependencies... done! >>> Verifying ebuild manifests >>> Building (1 of 1) app-editors/leafpad-0.8.14 for / * leafpad-0.8.14.tar.gz RMD160 SHA1 SHA256 size ;-) [ ok ] * checking ebuild checksums ;-) [ ok ] * checking auxfile checksums ;-) [ ok ] * checking miscfile checksums ;-) [ ok ] >>> Unpacking source... >>> Unpacking leafpad-0.8.14.tar.gz to /var/tmp/portage/app-editors/leafpad-0.8.14/work >>> Source unpacked. >>> Compiling source in /var/tmp/portage/app-editors/leafpad-0.8.14/work/leafpad-0.8.14 ... ... ...
Step-04e: Troubleshooting compilation problems
A lot of files have been removed from SystemRescueCd so that the system is smaller. For instance, many header files have been removed since they are not required to run the software. The problem is that these files may be necessary to compile new programs. That's why we kept important header files (such as the GTK header files) because many programs that you want to install require these headers. But sometimes you may have compilation errors because of that. For instance, if you try to upgrade mozilla-firefox, it will probably complain about a missing header file such as
prtypes.h and the compilation will fail. This header file belongs to dev-libs/nspr, which is a dependency of mozilla-firefox. This kind of header file has been removed because not many new programs may need dev-libs/nspr and these files were using too much space on the system.
As a consequence, all you have to do is to reinstall the dependencies using emerge, so that these headers files are reinstalled on your system. To see what are the dependencies of a package, you can run
emerge -epv <package-name>. It will list all the dependencies of a program:
# emerge -epv sys-devel/binutils These are the packages that would be merged, in order: Calculating dependencies... done! [ebuild R ] sys-devel/gnuconfig-20080123 0 kB [ebuild R ] sys-apps/findutils-4.3.13 USE="-nls (-selinux) -static" 0 kB [ebuild R ] sys-devel/binutils-config-1.9-r4 0 kB [ebuild R ] sys-devel/binutils-2.18-r3 USE="-multislot -multitarget -nls" 17 kB Total: 4 packages (4 reinstalls), Size of downloads: 17 kB
Step-04f: Summary of the Gentoo commands
Gentoo provides a very powerful management system and highly customizable packages. It is not possible to describe everything here, but these are the most important things you may want to do:
- check how a package will be installed and what are its dependencies:
emerge -pv <package-name>
- download the sources of a package and all the dependencies:
emerge -f <package-name>
- list the addresses of the files required to install a package:
emerge -pf <package-name>
- install a package and all its dependencies:
- uninstall a package but keep its dependencies:
emerge -C <package-name>
- ask what package a file belongs to:
equery belongs /path/to/a/file
- see all the files that belong to a package:
equery files <package-name>
- see the list of the packages installed:
Step-04g: States of the packages in gentoo
Here are some useful things to know about the state of the packages. It may be required in case a package you need is marked as unstable.
- In case you want to install a package marked as stable (it has the keyword 'x86') there should be no problem.
- If you want to install a package which is not marked as stable (it has the keyword '~x86'), you will have to add the package name (and possibly its dependencies) in
/etc/portage/package.keywords. Here is an example:
echo "www-client/mozilla-firefox ~x86" >> /etc/portage/package.keywords
- If the package you need is masked, you will have to add it to
- To install an old version of a package, you can mask the new versions in
echo ">=www-client/mozilla-firefox-3.0" >> /etc/portage/package.mask
Step-05: Remove unneeded development tools from the system (optional)
SystemRescueCD comes with development tools (gcc, automake, autoconf, cmake, ...) these tools are necessary to compile new programs. They are only useful when you install new packages, they can be removed if you are sure that you will not customize your SystemRescueCD later. You may also remove other packages that you consider unneeded to make your rescuecd smaller.
All the commands discussed in this section have to be executed from the chrooted environment (read the previous sections to know how to chroot).
Uninstall packages using
unmerge -C <pkg1> <pkg2> <pkg3> ....
Be careful, it's possible to break the system with this command. You can uninstall the gentoo commands themselves such as
emerge -C but you must uninstall all the packages at once: the command will uninstall itself, so it won't be available later.
If you have extracted a portage archive (such as portage-YYYYMMDD.tar.bz2), remove the portage files since they use a lot of space and are only necessary to install new packages:
rm -rf /usr/portage/*
We have created two categories of files that you may want to remove:
devtools contains all the development stuff and the gentoo commands. The
x11tools</code contains all the graphical packages. Uninstall <code>x11tools if you want to use SystemRescueCd for console programs only, and if you want the CD to be smaller or, faster to boot from the network or to cache to memory with the
from the chrooted environment (unlike sysresccd-custom which is run from the main environment).
To remove both
x11tools from the system, uninstall
x11tools first, or both in the same time:
sysresccd-cleansys devtools x11tools
/var/cache/edb/dep/ (if it is present) which is the cache that makes
rm -rf /var/cache/edb/dep/
Step-06: Create the new squashfs image
If you have installed new packages using the chrooted environment,
Now files from
/mnt/custom/customcd/files/ are read, and put inside the new squashfs image and copied to
A squash filesystem is compressed with either gzip or lzma.
- Gzip is very fast (compress and uncompress) but has a poorer compression ratio (the file is bigger).
- Lzma has better ratio than bzip2, but it's very slow to compress. It decompresses faster so the system will be faster while you are using the CDROM. Lzma is the default squashfs algorithm in SystemRescueCd. If you don't want to use lzma, edit
-nolzmato the line which executes
To create the new squashfs filesystem:
This will take longer than the extract took. (for example 17 minutes with gzip and 55 minutes with lzma)
Step-07: Add files to the ISO image (optional)
Only the big squashfs image file and the isolinux directory are required.
You may add other files to the ISO image, outside of the squashfs image. For example, you can put big backup files on the CDROM, and outside the squashfs image, to avoid overloading the squashfs.
Copy the files along with the sysrcd.dat, in this directory:
% cp -a my-files /mnt/custom/customcd/isoroot
You may add an autorun script to the root of the CDROM, outside of the squashfs image to be run at startup. It allows automation of tasks, such as doing a backup. See the autorun section for more details.
% cp autorun /mnt/custom/customcd/isoroot % chmod 755 /mnt/custom/customcd/isoroot/autorun
Make sure the size of the isoroot directory is not too big for the CDROM (usually 700 MB).
% du -sh /mnt/custom/customcd/
Step-08: Select your keymap (optional)
In the official version, SystemRescueCd asks you to select a keymap at startup. If you want to avoid seeing this menu and define a permanent keymap, you can run this command:
/usr/sbin/sysresccd-custom setkmap <your-keymap>
The second parameter is the name or the number of your keymap in the menu. For example, French users will use this:
/usr/sbin/sysresccd-custom setkmap fr
Step-09: Edit boot options (optional)
You may want to edit boot options (options such as
dodhcp) in the following file:
You might want to modify the splash screen at:
It might be nice to include a notice such as...
Based on SystemRescueCd from SysRescCd.org
Step-10: Create the new ISO image
You just have to type this command. The second parameter to provide is the volume name for the CDRom.
/usr/sbin/sysresccd-custom isogen my_srcd
Step-11: Burn the ISO image
The new ISO image is
If you booted with docache, umount /dev/cd .
Burn it with wodim, cdrecord, Nero ... Tell this software that the CDRom drive to use is the virtual ISO-image file drive.
If you don't want to burn a CDR, you can test it with VMWare or qemu.
Step-12: Synchronize your disks
Before leaving the system and rebooting, you should make sure all your disks are cleanly unmounted. The best way to be sure not to lose data is to umount all mounted partitions, especially the temporary one (/dev/sda1 in this example), and then type
cd / ; umount /mnt/custom ; sync
Result of your changes
When you start your computer with your own SystemRescueCd version, you can see all the files in
/mnt/livecd. If your new files belong to a standard directory, you can access them without a problem. If you made a new directory in the root of the filesystem, it will appear in
/mnt/livecd, but you won't see that in the root of the system. In fact, the root of the system contains symbolic links to
/mnt/livecd. You may have to make the link yourself.