Hacking Virtual-Linux 1.1
A quick attempt to explain how to add or remove things from V.L 1.1
and some explanations for the systems main functions.


Written by Crixz (Mårten Sundling, Author of Virtual Linux)
Edited by Dave Crouse (Webmaster for Virtual-Linux.org on 7/11/2002)


Many people seem to enjoy Virtual Linux, and some of them have asked how to add personal stuff and settings to the iso image. This How To Guide, was written to help those who wish to attempt this. To be able to do this, some Linux knowledge is needed, I am not going to explain every command in detail. If you need more information on linux commands there are several good books available....and much more information for free on the internet.

A good book for you would be: 'Linux in 24 hours' by Bill Ball , Isbn :91-636-0538-4 .

Step by step procedure and information about Virtual-Linux structure follows .

Beginning:

1. Boot into Linux, Virtual-Linux is fine.
2. View the Virtual-Linux cdrom (1.1) and locate the /isolinux and /images folders.
3. ( I believe from now on that you have a harddrive with a partition formatted as ext2 or other linux filesystem, mounted as /mnt/junk)
4. Make a folder named system
# mkdir /mnt/junk/system
5. Copy the folders to /mnt/junk/system
# cp -a images isolinux /mnt/junk/system
6. Make a folder named test in /mnt/junk
# mkdir /mnt/junk/test
# cd /mnt/junk/system
7. Now Gunzip the isolinux/initrd.gz
# gunzip isolinux/initrd.gz
8. Loop mount the filesystem inside to the test folder created earlier.
# mount -o loop -t ext2 isolinux/initrd /mnt/junk/test

What have we done and why?

/isolinux/inird.gz contains everything Linux needs to boot, and everything that needs read/write acess during operation. It is an ext2 filesystem image,in a file , and about 20MB in size. This image is loaded into Ram Memory by isolinux, a cdrom specific bootloader.

We have now mounted it in a folder, the same way you do to access any type of media in linux. If we visit the test folder:
# cd /mnt/junk/test
A structure of well known system folders should appear .
/ bin /sbin /etc /usr and so on.
If you look in /bin for example, you will see that most of the things are linked to somewhere else, and only a few of them are actually binaries.

# ls -al
Should present a lot of red links, for example /bin/vim-minimal -> /.virtual-root/bin/vim-minimal
Tadaa .... what is /.virtual-root ??????, you may ask ...

A compressed image ,/images/iso.compressed is mounted to /.virtual-root when V.L is fully booted, that image contains a normal install of mandrake 8.1, everything that does not need to be writable is ran from there, no questions asked .. This does normally work very well, most apps do not even suspect that something is wrong ....

Adding Apps and Settings

To add apps and settings, all you have to do if you only need a few Mb of space, is to copy binaries and libs to /mnt/junk/test/whatever, change all settings in /mnt/junk/test/etc
You might want to make changes to /mnt/junk/test/bin/vlutil as well, it is the main script that mounts disks, read settings and some more useful stuff, it is written in bash (crappy).

#####CAUTION####### do not remove anything you don't know what it does, it could make the whole thing useless!!!!

After you have made all the changes you want:

# cd / " important !"
# umount /mnt/junk/test
# gzip -v9 /mnt/junk/system/isolinux/initrd.gz
# mkisofs -o /mnt/junk/mand8.iso -R -T -d -D -N -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot \ -boot-load-size 4 -pad -boot-info-table /mnt/junk/system

I hear a question coming, "What is all the other folders doing on the cdrom if i don't need them in the iso ???"
They are only there for you to see, it is the contents of initrd.gz copied to the cdroot, nasty isn't it :)
Some people believe that those folders are used somehow, and scratch their heads to figure it out, *grin*.

When the iso is done, burn it and enjoy, if it doesn't work as intended, backtrack and see what is missing .

One tip might be to do all the settings you need on a running Virtual Linux system, copy all folders to the ramdisk as described above, then you have a hard copy of your favorite system, remember that the custom made cd may not run properly on another computer ...

"What if I can't get all my stuff to fit in the initrd image !!"

Then you'll have to unpack /mnt/junk/system/images/iso.compressed
The uncompressed image contents is about 1.6 Gb in size, and uncompression needs about 1.6 Gb in swapspace or ram+swap combined .

Be aware ! if you try to do this without sufficient swap space, computer will get stuck after a while, and rebooting is the only remedy!!

To unpack the image from within virtual-linux :
# extract_compressed_fs /mnt/junk/system/images/iso.compressed

Remember that the image will be uncompressed in the folder where you type this, so you have to stand in /mnt/junk for example or somewhere else with sufficient space and you must have enough swap space!
Uncompression/Recompression takes ALOT of time ( feels like ages) on a slow computer, about 1 hour on my 700 mhz. You can open another shell and use for example top (# top) to see what is actually happening, the little binary has no output whatsoever during unpack, watch the used swap numbers to see how much has been unpacked.

From another Linux distro :
Copy the executable from VL ramdisk /bin/extract_compressed_fs to your distro. Should work with most modern glibc distributions , like mandrake, redhat and so on.

If not, download cloop from www.knopper/net/knoppix.
A. gunzip the archive to a folder
B. enter the folder
C. type make
D. go get some coffee
E. copy the executables
F. try again.

Then, you can add whatever you like to the structure, remember that links from folders in initrd.gz have to be created for things to work properly. Takes some thinking, but about everything is doable, coffee and time helps.

To repack, use
# mkisofs -r /folder/where/you/unpacked/it | create_compressed_fs - 65536 > iso.compressed

For more info about Cloop , see www.knopper.net/knoppix

Comments, Misshaps, Errors, Questions ??? E-mail me at: [email protected]


My thanks to:
Dave Crouse for helping me with language and grammar and managing my website.
Our co-developers on sourceforge for helping me fix all the bugs and make new things happen.
Everybody else for using my distribution and giving me inspiration to continue !
Mandrakesoft, for their excellent distribution.

Mårten Sundling, alias CrIxZ, Author of Virtual Linux.