分类: LINUX
2009-04-16 12:23:19
Being able to make one's own version of SystemRescueCd is a frequently requested feature. It's now possible to with SystemRescueCd-1.1.0 and newer.
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
850 MB. 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 128 MB of RAM, and at least 850 MB 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 compiles 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 (ext2, ext3, reiserfs, jfs, ...), and that it has at least 850MB free. It must really be a linux filesystem, because other filesystem, such as FAT, NTFS don't supports symbolic links and files permissions. If you only have a FAT partition available, you can 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=fsimage bs=1M count=850
mke2fs -F -q fsimage
mount -t ext2 -o loop fsimage /mnt/custom
If you use 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. To add new packages to your customized rescuecd, you need sysresccd-1.1.0 or newer.
Please, post questions about the customization in this section of the forums:
% mkdir /mnt/custom
% mount /dev/sda /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
% /usr/sbin/sysresccd-custom extract
/mnt/custom is mounted -> ok
there is enough estimated free space here (.... MB) -> ok
You might want 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
Now customize.
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.
This major feature has been introduced in SystemRescueCd-1.1.0. 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 , then use the Gentoo commands such as emerge
and 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.
SystemRescueCd-1.1.0 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 usages, read the official Gentoo documentation which is very well written.
The Gentoo package management system is based on portage. It provides the support for each package that can be installed. The support is implemented as an ebuild script which contains all the instructions requires 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 internet, download the needed files somewhere else and copy the files by hand (using an USB-stick for instance). The sources of the packages have to be copied in /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.
Download a recent portage snapshot archive. Gentoo rebuilds the archive everyday, 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 lzma version which has a better compression ratio to save bandwidth and download time. Here is
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 lzma version (very good compression):
% tar xfp /path/to/portage-YYYYMMDD.tar.lzma -C /mnt/custom/customcd/files/usr/ --lzma
To verify portage has been uncompressed at the right place, check
% du -s /mnt/custom/customcd/files/usr/portage/sys-kernel/vanilla-sources
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
% mount -o bind /proc /mnt/custom/customcd/files/proc
% chroot /mnt/custom/customcd/files /bin/zsh
% 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
% unmount /mnt/custom/customcd/files/proc.
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 separated ebuild file. As an example we will install leafpad lightweight text editor based on GTK.
You can see the following ebuild script:
/usr/portage/app-editors/leafpad/leafpad-0.8.14.ebuild
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 sources files which are required to compile this program:
# emerge -f app-editors/leafpad
WARNING: repository at /mnt/sysresccd/sysresccd-110/portage-overlay is missing a repo_name entry
Calculating dependencies... done!
>>> Fetching (1 of 1) app-editors/leafpad-0.8.14 for /
>>> Downloading '
--2008-07-27 15:22:33--
Resolving distfiles.gentoo.org... 216.165.129.135, 156.56.247.195, 140.211.166.134, ...
Connecting to distfiles.gentoo.org|216.165.129.135|: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 15:22:34 (223 KB/s) - `/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 in /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
...
...
...
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 these
files may be necessary to compile new programs. That's why we kept
important headers files (such as the GTK header files) because many
programs that you want to install requires 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
. 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 -test -vanilla" 17 kB
Total: 4 packages (4 reinstalls), Size of downloads: 17 kB
Gentoo provides a very powerful management system and highly customizable packages. It is not possible to describe everything here, here are the most important things you may want to do:
emerge -pv
emerge -f
emerge -pf
emerge
emerge -C
equery belongs /path/to/a/file
equery files
equery list
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.
/etc/portage/package.keywords
. Here is an example:
echo "www-client/mozilla-firefox ~x86" >> /etc/portage/package.keywords
/etc/portage/package.unmask
.
/etc/portage/package.mask
echo ">=www-client/mozilla-firefox-3.0" >> /etc/portage/package.mask
SystemRescueCd-1.1.0 comes with development tools (such as gcc, automake, autoconf, cmake, ...) because these tools are necessary to compile new programs. They are only useful when you install new packages, so they can be removed if you are sure that you will not customize your SystemRescueCd later. You may also want to remove other kind of packages that you consider useless if you want to make your rescuecd as small as possible. All the commands discussed in this section have to be executed from the chrooted environment (read the previous sections to know how to chroot).
You are free to uninstall packages using unmerge -C
if you consider you won't need them any more, and if you want the
system to take less space. Be careful, it's possible to break the
system with this command. You can even uninstall the gentoo commands
themselves such as emerge
using emerge -C
but you must uninstall all the packages in one go: the command will be uninstall by itself, so it won't be available later.
If you have extracted a portage archive (such as
portage-YYYYMMDD.tar.bz2), you will have to remove the portage files
since they use a lot of space. So you will have to clean /usr/portage
since these files are only necessary to install new packages:
rm -rf /usr/portage/*
To help you to make your system smaller, we have created new
categories of stuff that you may want to remove. At the moment, only
two categories have been created: devtools
and x11tools
.
The first one contains all the development stuff and the gentoo
commands. You should remove that stuff only if you are sure that you
won't have to install new packages. The second category is x11tools
. It has been introduced in SystemRescueCd-1.1.2. It contains all the graphical packages. So you can uninstall x11tools
if you only want to use SystemRescueCd for console programs only, and
if you want the system to be smaller or faster to boot from the network
or to cache to memory with the docache
option.
A command has been developed to help you to remove these categories, this tool is provided with SystemRescueCd-1.1.0 and newer versions. Here is how to use it:
sysresccd-cleansys devtools
It has to be executed from the chrooted environment, unlike sysresccd-custom which is run from the main environment.
You need packages from devtools
to manage the packages. In other words, you wont be able to install or remove packages if you remove the devtools
packages. So if you want to remove both devtools
and x11tools
from the system, you must uninstall x11tools
first, or both in the same time:
sysresccd-cleansys devtools x11tools
You should also consider removing /var/cache/edb/dep/
since this directory contains cache which make emerge faster. It won't
break anything, it will just make emerge slower if you use it in the
future:
rm -rf /var/cache/edb/dep/
If you have installed new packages using the chrooted environment,
umount /mnt/custom/customcd/files/proc
Now files from /mnt/custom/customcd/files/
are read, and put inside the new image and copied to /mnt/custom/customcd/isoroot/sysrcd.dat
.
A squash filesystem is compressed with either gzip or lzma.
/usr/sbin/sysresccd-custom
and add -nolzma
to the line which executes mksquashfs
.
To create the new squashfs filesystem:
/usr/sbin/sysresccd-custom squashfs
This will take longer than the extract took. (for example 17 minutes with gzip and 55 minutes with lzma)
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: /mnt/custom/customcd/isoroot
% 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/
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
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
You may want to edit (options such as docache
or dodhcp
) in the following file:
/mnt/custom/customcd/isoroot/isolinux/isolinux.cfg
You might want to modify the splash screen at:
/mnt/custom/customcd/isoroot/isolinux/f1boot.msg
It might be nice to include a notice like
Based on SystemRescueCd from SysRescCd.org
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
The new ISO image is
/mnt/custom/customcd/isofile/sysresccd-ccyymmdd-hhmm.iso
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.
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 sync
cd / ; umount /mnt/custom ; sync
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 it
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.