User Mode Linux
One problem with RPM is that installing RPM packages almost inherently requires
(administrator) access on the target machine. Not only do packages typically want to be installed in global directories such as
access is required, but RPM also registers installed packages in a global database in
which is also owner by
. While it is possible to use a relocatable RPM packages and another database, we will not do that for the RPM exercises.
Instead, we are going to use User-Mode Linux
(UML). UML allows you to run any number of virtual Linux machines under Linux. Disk storage for such machines is stored in regular files (disk images
). In principle any Linux distribution can be installed on such virtual disks. Anything you do inside the virtual machine does not affect the outside world.
UML only runs on Linux systems, so you should log in onto one of the Linux systems in BBL-401 or BBL-406 (remotely, if necessary, as described in LearnSubversion
). You should also add the directory containing UML to your path, as described in LearnSubversion
Try to run UML by typing
on the command line. You should see the Linux kernel start, and eventually the message
Kernel panic: VFS: Unable to mount root fs on 62:00
That is, we have to specify a disk image for the kernel to use.
An image of Red Hat Linux 7.2 has been provided in
. You can run it as follows:
is the name of the disk image device. In order to save disk space we use UML's copy-on-write
feature: any changes you make to the virtual disk will be written to the file
in your home directory instead of
. This saves you from having to make a complete copy of that file, which is rather big.
Note that the COW file may appear
to be very big (600+ MB), but in fact it takes up much less disk space than that due to the use of sparse files
(parts of the file that are not actually written to do not take up disk space). However, if you run out of disk space, you can use /net/tmp instead.
A common problem is that UML makes zero-byte COW files if some error occurs when you first try to create it. Subsequent attempts to start UML will then fail with the error message "Failed to read COW header." Deleting the COW file will fix this.
After a while a login prompt should appear. You can login as user
Play with it
You can now use RPM inside the virtual machine. For example,
will show you what packages are installed. Or we can ask what package
rpm -qf /bin/sh
We see that belongs to package
. We can try to uninstall the package:
rpm -e bash
which will complain. If we really want to we can force removal:
rpm -e --nodeps bash
Congratulations, you have destroyed your system. No matter, you can just delete the
file and start with a fresh copy.
The UML machine can be shutdown cleanly using the
To install RPMs built on the host system in the virtual machine you have to have some way to transfer files from the host to the virtual machine. In fact, the entire host file system in mounted under
, so you can find your home directory in
(a symbolic link has been provided so that
has been mounted read-only
(so that, for example,
rm -rf /
doesn't destroy your real home directory). If you want to copy things to the host file system you have to remount
mount -o remount,rw /mnt/host