OSC UML Instance Filesystem

From SOFTICE

Jump to: navigation, search

Contents

Creating a UML root filesystem using debootstrap

(This information is subject to change, as per discussion in Shared filesystems.)

Basic setup

  • Create the file that will serve as the virtual block device. This command creates a 2 GiB filesystem; if you wish to make it larger or smaller, simply change the count= portion.
begeiger@softice:~$ dd if=/dev/zero of=umlroot-osc.rfs bs=1024k count=2048
2048+0 records in
2048+0 records out
2147483648 bytes transferred in 217.877280 seconds (9856391 bytes/sec)
begeiger@softice:~$
  • Create a filesystem on the virtual block device.
begeiger@softice:~$ /sbin/mkfs -t ext3 -j umlroot-osc.rfs
mke2fs 1.37 (21-Mar-2005)
umlroot-osc.rfs is not a block special device.
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
262144 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
First data block=0
16 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
begeiger@softic"setting locale failed"e:~$
  • Mount the new filesystem somewhere onto the old filesystem.
begeiger@softice:~$ su
Password: [hidden]
softice:/home/softice/begeiger# mount umlroot-osc.rfs newroot/ -o loop
softice:/home/softice/begeiger#
  • Run debootstrap to populate the filesystem.
softice:/home/softice/begeiger# debootstrap sarge newroot/ ftp://ftp.us.debian.org/debian/
I: Validating debootstrap.invalid_dists_sarge_Release
[... much output removed ...]
I: Base system installed successfully.
umount: /home/softice/begeiger/newroot/dev/pts: not mounted
umount: /home/softice/begeiger/newroot/dev/shm: not mounted
umount: /home/softice/begeiger/newroot/proc/bus/usb: not mounted
softice:/home/softice/begeiger#
  • chroot into the new root filesystem.
softice:/home/softice/begeiger# chroot newroot/
softice:/#

The "/" in this case refers to the root of the new filesystem, not the original root.

  • Inside the root FS:
    • Mount the /proc filesystem.
softice:/# mount -t proc none /proc
softice:/
    • Create the device nodes for the virtual block devices.
softice:/dev# mknod ubda b 98 0
softice:/dev# mknod ubda1 b 98 1
softice:/dev# mknod ubdb b 98 16
softice:/dev# mknod ubdb1 b 98 17
softice:/dev# mknod ubdc b 98 32
softice:/dev# mknod ubdc1 b 98 33
softice:/dev# mknod ubdd b 98 48
softice:/dev# mknod ubdd1 b 98 49
softice:/dev#
    • Create /etc/fstab. (Keep in mind that vi and nano are available at this point.)
# file system   mount point     type    options                 dump    pass
/dev/ubda1      /               ext3    defaults,noatime        0       0
/dev/ubdb1      swap            swap    defaults                0       0
none            /proc           proc    defaults                0       0
none            /dev/pts        devpts  gid=5,mode=620          0       0
    • Install aptitude (this works around a bug in the Debian installer):
softice:~# apt-get install aptitude
[... much output removed ...]
softice:~#

Note that it will ask you to install a significant number of other packages. This is normal.

    • Configure the Debian base system.
softice:~# base-config new
[graphical interface]
      • Configure keymap and time zone as you see fit.
      • Set a root password. Do not create a non-root user (yet).
      • Don't set the hostname.
      • Configure apt to use a Debian mirror close to you.
      • Select "Mail Transfer Agent" but nothing else.

It will still install many packages, most of which have nothing to do with the MTA. This is normal.

    • Change /etc/hostname to include the system's hostname. (If you let base-config do it, it'll change the hostname of the host system.)
    • Unmount the /proc filesystem.
softice:/# umount /proc
softice:/#
    • Exit the chrooted filesystem.
  • Unmount the filesystem.
softice:/home/softice/begeiger# umount newroot/
  • Your new UML filesystem is complete and ready to run!


Making sure the kernel works with modules

All our instances are unstable and thus use gcc 4.0. While inside your uml you will compile your modules with gcc 4.0 thus need the uml executable itself to be a kernel compiled with the same gcc. Softice is a stable debian thus running gcc 3.3.5, we therefore compile the 2.6.16 kernel sources inside a uml after mounting them as a device (look at /home/sys/osc/fs/ks.2.6.16.20.rfs for a device containing 2.6.16.20 kernel sources) on /usr/src/linux. Then we compile as usual from within the uml:

 
cd /usr/src/linux/
make ARCH=um defconfig 
make ARCH=um menuconfig

At this point remember to enable msdos file system, hostfs filesystem.

 
make ARCH=um modules 
make ARCH=um modules_install

This makes sure that the latter install the modules in /lib/modules/ in the virtual disk image.


Avoiding Problems /lib/tls

UML doens't support the /lib/tls threading library, you need to make sure that your debian root filesystem image doesn't have this library. Simply rename it as follows;

 
mv /lib/tls /lib/tls.notwithuml

The OSC laboratories are using a so-called configuration device which is mounted and contains scripts to fix-up the root file system image on the fly. This bug will be checked by the script and fixed if necessary.

Personal tools