Linux Kernel hacking platform

(1) login the Linux server that is set up for your experiments
If you log in from machines outside Engineering Building or its wireless network,
ssh [-l username] (its IP is
Otherwise use:
ssh [-l username] (its IP is
(The username is your accessID, and the passwd is the last four digits of your accessID)
(2) Once you login, you are in your home directory /home/ab1234 (assume your accessID
is ab1234)
You can 'pwd' to check your current directory
(3) You MUST immediately change your password after your first login to protect your
(4) copy UML root file system (root_fs) into your own UML home directory (supposedly
UML stands for User Mode Linux)
mkdir UML
cd UML (now you are in /home/ab1234/UML -- this is your UML home directory.)
cp /home/UML/root_fs . (While root_fs is about 1.6GB, this operation may take several
cp /home/UML/swap . (swap is about 1.1GB, this may take several minutes)
mkdir mnt (prepare a directory as a mount point for root_fs )
(5) uncompress a Linux kernel source code tree in your UML home directory, which is
used to generate a UML Linux kernel. Then refer linux2.6.18.3/Documentation/uml/UserModeLinux-HOWTO.txt for more information about
tar xvfj /home/UML/linux-
cd linux- (now your are in /home/ab1234/UML/linux-
(6) fix the kernel using the its UML patch and create a configuration file to build a kernel
patch -p1 < /home/UML/
make menuconfig ARCH=um (when a menu appears, simply select EXIT and then
SAVE. After this, you can find a '.config' file by using 'ls -a')
/**** NOTE: the following steps will be repeated each time you change kernel source
code and want to build/run a new kernel. *****/
(7) Build up an executable kernel as its modules
make linux ARCH=um (It takes about 10 minutes for you to compile the kernel for the
first time.)
make modules ARCH=um
(8) mount root file system (root_fs) into the mount point
cd .. (now your are in /home/ab1234/UML/)
mount root_fs (./mnt is the default mount point, you should not specify it. Now you can
enter the ./mnt and see what are inside the root file system. you can also use 'umount mnt'
to unmount the fs. )
(9) install kernel modules into the mounted root file system.
cd linux- (now your are in /home/ab1234/UML/linux-
make modules_install INSTALL_MOD_PATH=/home/ab1234/UML/mnt ARCH=um
(change ab1234 to your accessID)
umount ../mnt
(10) run the newly generated kernel
cp linux ..
cd ..
./linux ubd0=./root_fs ubd1=./swap con0=fd:0,fd:1 root=/dev/ubda mem=256M
(11) Now you're waiting your own kernel to boot a UML virtual machine for you .... Log
in as 'root' and play the kernel.
(12) REMEMBER: shut down your linux before you leave!
halt (if you exit without 'halt', you'll have trouble with your next reboot. If you do have
trouble (1) file system inconsistency, run 'fsck', or (2) initialization with IRQ, run 'killall
linux' to remove trash 'linux' processes)
Now you can use 'root' to log in the system running your kernel without providing a
NOTE: (1) While user-mode linux is running, you SHOULD leave root_fs unmounted
and stay away from it to ensure its consistency!
(2) How to copy files from the file system on the host machine to root_fs?
Initially all directories/files in root_fs have 'root' permissions and don't allow others to
write them except '/tmp', which is intentionally left with all permissions open. So you can
copy files into /home/ab1234/UML/mnt/tmp after you mount root_fs and copy files there.
However, if you start your UML, you cannot find your files there, the reason is that UML
mounts a memory-resident temporary file system. If you don't need this fs, just umount it
then you'll see your files. Other wise, you create a directory and open its permissions for
trasfering files between your host file system and root_fs.