Hack 21 Create Persistent Knoppix Settings 
Knoppix has the capability of saving changes
you have made during your session to floppies, USB drives, or other
removable media. Use this ability to create a Knoppix setup that you
can take to any computer.
One of
the great things about Knoppix is that it all resides on a single CD,
so you can take the same desktop environment and programs with you to
any accessible computer. One problem, however, is that a CD is
read-only media, so any configuration changes you make or any special
settings you might change to get Knoppix to work on your hardware are
lost the moment you shut down the computer. If you have a USB drive,
a floppy drive, or some other writable media, Knoppix has automated
the process of keeping changes you make to Knoppix persistent across
reboots. You even have the option of saving your entire
/home directory if you want, which means you can
take your data with you too.
3.2.1 Save Settings
To save all of your changes, click K
Menu KNOPPIX Configure Save Knoppix
configuration or run
/usr/sbin/saveconfig
in a console. There are a number of settings that Knoppix can save.
The different types of settings you can choose from are:
- Personal configuration (desktop, programs)
-
Select this option to save the configuration files in your home
directory. KDE and other Linux programs have standardized the saving
of user settings in hidden files and directories, which begin with a
period and are commonly referred to as dot files. So this option
saves any theme or color changes you have made for your desktop, any
settings changes made for any program (so, for instance, this would
save your web browser bookmarks and your email settings), and any
other configuration settings that are stored in these hidden files.
- All files on the desktop
-
This option doesn't save settings per se but instead
backs up the full /home/knoppix/Desktop
directory, so any files you have saved on the desktop will still be
there the next time you reboot if this option is checked. Use this
option in lieu of saving the entire home directory, which is
described below, if you just have a few files on the desktop that you
wish to save and don't particularly care about
keeping configuration changes.
- Network settings (LAN, Modem ISDN, ADSL)
-
Select this option to save special
network-specific directories and settings stored under
/etc so they will be reloaded the next time the
machine is booted. Choose this option if you had to make any special
changes to your network settings, such as set up a wireless, PPPoE,
or dial-up connection.
- Graphics subsystem settings (XF86Config)
-
This
option saves the configuration files under
/etc/X11 and reloads them on reboot. Check this
option to save direct edits you have made to your XF86Config file to
get your graphics environment to load.
- Other system configuration (printer, etc.)
-
This option saves some other miscellaneous configuration settings,
including those for printers and other peripherals.
Saveconfig's default is to
select all these options except for saving desktop files. If you plan
to use Knoppix on many machines with different hardware and network
configurations, you might want to just select the first option,
"Personal configuration," so that
desktop, data, and program settings will be saved, but network and
graphics settings will be detected on each new machine you come to.
After you select which settings to save and click OK, Knoppix
provides a list of all the available writable media you can store
your settings to. This includes any hard drives on your system,
floppy drives, and any USB or other removable storage currently
connected. Select the device to save to, and Knoppix will back up
your settings to that device.
Knoppix stores its configuration settings in the root directory of
the device in a bzipped tar file called
configs.tbz,
along with a script that Knoppix runs to restore this configuration
called
knoppix.sh.
To examine just which files Knoppix has saved, click on
configs.tbz in a file manager (Konqueror
automatically displays the contents of archives) or run the following
command in a console:
knoppix@ttyp0[knoppix]$ tar tvfj configs.tbz
The size of the file varies depending on how many program settings
are being saved and, if you are saving your desktop, the size of any
files stored there.
Now that you have your settings and data saved, you need some way to
use what you've saved in subsequent boots. This is
where myconfig comes in. If you have saved your
settings to a removable USB drive at /dev/sda1,
boot with the cheat code:
myconfig=/dev/sda1
If you don't know which device the settings are
stored on, then boot with:
myconfig=scan
This command instructs Knoppix to scan for your settings on all
devices it finds. In general, it is easier to just use the scan
option unless you have saved settings at different times on different
devices, in which case you may prefer to explicitly tell Knoppix
which device to use.
After Knoppix boots, it then runs the knoppix.sh
script it created when you backed up your settings and extracts the
files from configs.tgz.
 |
Remember that if you make any new changes that you would like to
save, you must run the saveconfig script again.
|
|
3.2.2 Save Your Home Directory
Through
the use of the mkpersistenthome script and the
home cheat code, Knoppix also supports saving your
entire home directory to an image that can be restored in later
boots. The mkpersistenthome script backs up the
complete /home/knoppix directory with all of its
hidden and unhidden files, including the desktop. This makes it
different from the saveconfig script, which just
backs up the hidden configuration files and the desktop. Another
difference with this method is that creating a persistent home
directory means that Knoppix mounts this new image as the home
directory, so that as long as you pass the home
cheat code at boot, any changes or new files in the home directory
are still changed the next time you reboot without the need to run
the script again.
To create the persistent home directory image, run K
Menu KNOPPIX Configure Create a persistent
KNOPPIX home directory or from a console run:
knoppix@ttyp0[knoppix]$ /usr/sbin/mkpersistenthome
The execution of this script is similar to the
saveconfig script. When run, it presents you
with a list of detected drives on which to create the persistent home
directory. One main difference is that after you choose your drive,
you have the potentially dangerous option to format the drive and use
the entire drive for the home directory. The safest choice is to tell
Knoppix to create a loopback file on the device
that it will save to. A loopback file is an entire filesystem
contained within a single file, like a CD image. Loopback files can
be formatted and mounted just as though they were full filesystems.
You must also choose a size for the loopback file. The size of your
loopback file depends greatly on how many extra files you plan to
store. See how much space you are currently using for your home
directory by typing the following command:
knoppix@ttyp0[knoppix]$ du -sh ~
12M /home/knoppix
Keep in mind that this loopback file does not grow even if there is
more free space on the drive. Therefore, choose a file size based on
how much space you think you will need in the future, not just how
much you need now. Otherwise, when you need more space, you will have
to create a brand-new persistent home directory and copy your files
over. To resize the image to size megabytes, type:
knoppix@ttyp0[knoppix]$ resize2fs knoppix.img size
M
After configuring the loopback file, Knoppix creates and formats the
loopback file and then copies the full home directory to it.
When the script finishes, you should see a
knoppix.img file on your storage device. To view
the contents of the file, mount it with the following command:
knoppix@ttyp0[knoppix]$ mkdir ~/temp
knoppix@ttyp0[knoppix]$ sudo mount -o loop /mnt/sda1
/knoppix.img ~/temp
Replace /mnt/sda1 with the path to your Knoppix
image, then see the contents of the file at
/home/knoppix/temp.
To tell Knoppix to use the loopback file for your home directory at
boot, use the home cheat code. This cheat code
works just like the myconfig cheat code covered
earlier in this hack. You can either pass it a specific device that
contains knoppix.img or boot with
home=scan for Knoppix to scan all available drives
for knoppix.img. For example, to use a
persistent home directory created in
/mnt/sda1/knoppix.img, boot with:
home=/mnt/sda1/knoppix.img
If you have a Linux partition available on your system and are
willing to add the Knoppix home directory to it, you can also create
a full Knoppix home directory without reformatting a drive or being
limited by the space to which you have assigned an image. This method
is particularly useful to add an extra directory to your
desktop's home directory just for use by Knoppix. On
the underlying Linux system, it looks just like a new user named
knoppix has been added.
First, choose the partition you wish to use and make sure that it is
writable—changing read/write mode is covered in [Hack #10] .
For these examples, I use /mnt/hda3, which
contains my regular Linux home directories on this system. To create
the new home directory and make sure that the
knoppix user owns it, open a terminal and type:
knoppix@ttyp0[knoppix]$ sudo mkdir /mnt/hda3
/knoppix
knoppix@ttyp0[knoppix]$ sudo chown knoppix:knoppix /mnt/hda3
/knoppix
To copy your Knoppix home directory, run:
knoppix@ttyp0[knoppix]$ rsync -av /home/knoppix/ /mnt/hda3
/knoppix/
To use this directory the next time you boot, use the
home cheat code, but make sure to pass it the path
to this new home directory. In this example, type:
home=/dev/hda3
/knoppix
Now you can have a special Knoppix home directory along with all of
your other user accounts. Similar to other persistent home directory
methods, this method uses this directory in place of a ramdisk for
/home/knoppix, so any changes you make or files
you create are always saved—without running any extra commands.
Knoppix's persistent cheat codes are especially
handy if you use Knoppix frequently, as it bypasses many of the
disadvantages of booting from a read-only media and allows you to
save changes you have made. Combine these persistent settings with a
small USB key drive, and your settings and files can follow you to
any computer with a CD-ROM drive and a USB port.
|