Creating a Slackware UML Root FS

A while back I had a Debian Woody server, and was attempting to run modern software on it… Hah! So, I looked into creating a User Mode Linux install of Slackware to run my newer apps on. It worked well, and I documented some of the stuff I did.

This is an older version of my site, content that I never transferred over to this new one.

Note: These instructions apply to Slackware 10.0 and have not yet been updated for 10.1 or anything later

Creating a Slackware Filesystem

First, you want to create an empty file to hold the filesystem. The easy way:

dd if=/dev/zero of=my_new_filesystem bs=1M count=1000

This will create a 1GB file full of zeroes. You can change count to create a file of whatever size you want. However, this will take a long time, and will actualy create a file that consumes 1GB of space. The more intelligent way:

dd if=/dev/zero of=my_new_filesystem bs=1M seek=999 count=1

This will create what is known as a “sparse file”. Examing the file size with ls will show that the file is 1GB, but, if you use du, you can see the file only takes 1MB on the disk (since that is all is what was written). The file will begin to take more space on the disk the more you add to the file. Modify seek= to change how large you want your sparse file to be.

Next is to create a filesystem on this file. I don’t see the point of using more robust filesystems like ReiserFS or XFS, so I stuck with good ‘old ext2/ext3.

mke2fs -j my_new_filesystem

Mount the filesystem via loopback so we can start installing files onto it.

mount -o loop my_new_filesystem mountpoint/

We can now begin to install all the Slackware packages we want. All we need to is set the ROOT environment variable, or pass the “-root” option to Slackware’s installpkg to point to the new filesystem.

For example:

installpkg -root /path/to/mountpoint/ aaa_base*.tgz

If you’re not creating this image on Slackware, you’re on your own to figure out how to install the Slackware packages. Remember that Slackware .tgz files are just tarballs, and can just be extracted, though you’ll miss the creation of /var/log/packages/ and other pkgtool-specific things.

The packages you want to install are basically everything from the “a” disk except some things you know you won’t need, such as anything to do with hardware and filesystems you won’t be using (isapnptools, pcitools, jfsutils, etc). I installed:

a/aaa_base-10.0.0-noarch-1.tgz a/aaa_elflibs-9.2.0-i486-1.tgz a/bash-2.05b-i486-3.tgz a/bin-9.2.0-i486-2.tgz a/bzip2-1.0.2-i486-5.tgz a/coreutils-5.2.1-i486-1.tgz a/cpio-2.5-i386-1.tgz a/cxxlibs-5.0.6-i486-1.tgz a/dcron-2.3.3-i386-4.tgz a/devs-2.3.1-noarch-21.tgz a/e2fsprogs-1.35-i486-1.tgz a/etc-5.1-noarch-9.tgz a/findutils-4.1.7-i386-1.tgz a/gawk-3.1.3-i486-1.tgz a/gettext-0.14.1-i486-1.tgz a/getty-ps-2.1.0-i386-1.tgz a/glibc-solibs-2.3.2-i486-6.tgz a/glibc-zoneinfo-2.3.2-noarch-6.tgz a/grep-2.5-i386-2.tgz a/gzip-1.3.3-i386-2.tgz a/infozip-5.51-i486-1.tgz a/kbd-1.12-i486-2.tgz a/less-382-i486-1.tgz a/logrotate-3.6.8-i486-1.tgz a/mkinitrd-1.0.1-i486-2.tgz a/module-init-tools-3.0-i486-1.tgz a/openssl-solibs-0.9.7d-i486-1.tgz a/pkgtools-10.0.0-i486-1.tgz a/procps-3.2.1-i486-1.tgz a/sed-4.0.9-i486-2.tgz a/shadow-4.0.3-i486-11.tgz a/slocate-2.7-i486-3.tgz a/sysklogd-1.4.1-i486-9.tgz a/sysvinit-2.84-i486-50.tgz a/tar-1.14-i486-4.tgz a/tcsh-6.13.00-i486-1.tgz a/utempter-1.1.1-i486-1.tgz a/util-linux-2.12a-i486-1.tgz

n/links-2.1pre15-i486-1.tgz n/openssh-3.8.1p1-i486-1.tgz n/openssl-0.9.7d-i486-1.tgz n/tcpip-0.17-i486-29.tgz n/tcpdump-3.8.3-i486-2.tgz n/wget-1.9.1-i486-1.tgz

ap/vim-6.3.004-i486-1.tgz ap/rzip-2.0-i486-2.tgz ap/lsof-4.71-i486-1.tgz

If you don’t like devfs (I know I don’t), you’ll also need to create dev entries for UML’s ubd devices. In /path/to/mountpoint/dev, run:

for i in 0 1 2 3 4 5 6 7; do mknod ubd$i b 98 $![ $i * 16 ]; done

Lastly, you need to setup your fstab. If you’re going to run your UML with this filesystem as ubd0, put into /path/to/mountpoint/etc/fstab:

/dev/ubd0 / ext3 defaults 1 1

Modify the filesystem column depending on what filesystem you’re using. Also, if you’re using devfs, change the device to be “/dev/ubd/0”.

Lastly, you’ll need to run ldconfig to create the right symlinks to your libraries. Run:

ldconfig -r /path/to/mountpoint

That should be it, and your new filesystem should be ready for booting with User Mode Linux.

Compiling a Custom UML Kernel

To be added

Type: 

Like this article? Please support my writing! Flattr my blog (see my thoughts on Flattr), tip me via PayPal, or send me an item from my Amazon wish list.