You are not logged in.

#1 2005-05-24 11:03:26

thogie
Member
Registered: 2005-05-24
Posts: 11
Website

archlinux inside archlinux (user-mode-linux) howto

Uh how exciting. My first post ever in this forum.

I've just finished a basic installation of archlinux inside a user-mode-linux file system. I accomplished this with the help of the archbootstrap script and much, much googleing. If some people are interested in this topic and are willing to review this post for quality assurance I will write a wiki article.

Why?
I use uml to sperate sftp, ftp and www server. Furthermore I am dreaming of running a mail server inside a uml machine - but I think, I am simply too stupid for mail server installation guides (and much to less motivated ;-))

Prerequisites:

1.) User-mode-linux kernel; pacman -Sy user-mode-linux should do it
2.) The archbootstrap script. It is discussed in this topic.

Let's go:
1.) First we have to create a single, big file into which we will install arch and a second, smaller file for swapping.

ddd if=/dev/zero of=archRootFs bs=1MB count=1000
dd if=/dev/zero of=swap bs=1MB count=1000

The root filesystem archRootFs is now about 1GB - this should be sufficient for a basic installation.

2.) After the build process you have to format the root filesystem image and the swap file. To keep it simple I used ext2 filesystem for the root fs, but any other fs should work too (other opinions? what about /boot ??).

mke2fs archRootFS
mkswap swap

This command will complain about archRootFs not being a block device. You can safely ignore this or surpress the message by adding -F to mke2fs.

3.) After formatting the file you have to mount it. Executing the following command as root does the job:

mount -o loop archRootFs /mnt

4.) Now the installation of the basic system may start. For this, I used the archbootstrap script, which mainly does the same thing as the installation cd, but for a certain directory.

sh archbootstrap /mnt/ ftp://ftp.archlinux.de/pub/archlinux

5.) Before the system can be booted with user-mode-linux, some files inside the arch basic system have to be customised. Add these lines to /mnt/etc/fstab:

/dev/ubd0 / ext2 defaults 0 0
/dev/ubd1 swap swap defaults 0 0

To avoid problems I disabled hotplugin (It took ages until the image was booted with hotplugin turned on - any suggestions how to avoid this and still use hotplug?)

DAEMONS=(syslog-ng !hotplug !pcmcia network netfs crond)

6.) Next step is to setup networking. Therefore you create a so called tun device (Please visit the uml howto for further information about tun/tap), and give it an IP adress:

tunctl -u users
chmod root.users /dev/net/tun
ifconfig tun0 192.168.0.100 up

7.) Now you can boot the image. To use the network you have to announce the proper device to the uml kernel. (Mind that the user running the uml command needs enough rights to access the tun device!)

linux ubd0=archRootFs ubd1=swap eth0=tuntap,,,192.168.0.100

I personaly prefer to run the image inside a vnc session because I'm running a headless server without screen nor keyboard, just remote access.

Have fun playing around with uml!

Offline

#2 2005-05-24 12:26:46

i3839
Member
Registered: 2004-02-04
Posts: 1,185

Re: archlinux inside archlinux (user-mode-linux) howto

1) Shouldn't that be:

dd if=/dev/zero of=archRootFs bs=1MB count=1000
dd if=/dev/zero of=swap bs=1MB count=100

Why don't you use a file within archRootFs as swapfile? Why use a swapfile at all, UML can be swapped by the real kernel can't it?

2) Ext2 is fine, it is no real filesystem anyway. Having a journalling fs on top of a real journaling fs makes not much sense.

3) Perhaps add it to fstab so you can mount it easily and at each bootup with the correct mount options? (noatime,nodiratime)

4) Perhaps promote to use a close mirror here (archlinux.de seems to redirect/point to archlinux.org).

5) Hm, what about something like

lsmod | sed 's/ .*//' > /mnt/tmp/modulelist

and then in UML load all modules from that file? Then you can still use hotplug for real hotplugging, but use that for the coldplug which is already done by the real system. This won't work if you have scripts that must be run by hotplug of course, but for loading the moduels only it's fine.

6) Tell in which package tunctl can be found and make it more clear that this must be done in the host Arch system and not in UML.

7) "eth0=tuntap,,,192.168.0.100" is a bit strange, perhaps care to tel what the ,,, are for? Doesn't eth0=tuntap,192.168.0.100 work too? Isn't using screen + ssh better than vnc or can vnc handle it when the client disconnects? And wasn't vnc for graphical stuff, surely you don't have X on your server?

Other comments: Make clear what UML can be used for and main reason why it is good (security).

Thanks for the howto, you really should add it to the wiki.

Offline

#3 2005-05-24 19:52:45

cjdj
Member
From: Perth, Western Australia
Registered: 2004-05-07
Posts: 121

Re: archlinux inside archlinux (user-mode-linux) howto

For the last few weeks, I've been thinking about looking into UML.   I had looked into it about a year ago, but didnt have the time to start messing with it.

From your howto, looks like I can get it going without as much trouble as I thought it would be.

Thanks heaps!

Offline

#4 2005-05-25 02:52:14

cjdj
Member
From: Perth, Western Australia
Registered: 2004-05-07
Posts: 121

Re: archlinux inside archlinux (user-mode-linux) howto

thogie wrote:

6.) Next step is to setup networking. Therefore you create a so called tun device (Please visit the uml howto for further information about tun/tap), and give it an IP adress:

tunctl -u users
chmod root.users /dev/net/tun
ifconfig tun0 192.168.0.100 up

Cool, I've managed to get a working UML filesystem, but I was unable to get the network working.  When I followed the instructions you have there, it told me:

Failed to open '/dev/net/tun' : No such device

I did use a username that is valid.  I looked in /dev/net/tun and there is a file there.  Is there a module that needs to be loaded?

By the way, I'm using teh 2.6 kernel, could that be the problem?   To I need to recompile my kernel in order to get tun to work?

Reading stuff online, but not really getting anywhere....

Offline

#5 2005-05-25 03:11:38

cjdj
Member
From: Perth, Western Australia
Registered: 2004-05-07
Posts: 121

Re: archlinux inside archlinux (user-mode-linux) howto

Ok, I seem to have got my tun/tap thing working.
I needed to remove the /dev/net/tap, and then do modprobe tun

now tunctl seems to be working.  Dont know what was wrong with it.

Offline

#6 2005-05-25 16:40:06

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: archlinux inside archlinux (user-mode-linux) howto

Xentac did some work with Arch and UML a while ago, he was trying to build some kind of automated build system, IIRC. I have no idea what kind of documentation he wrote on the process -- you know Xentac and documentatino. ;-) (ie: scrpac -h = who needs a man page?)



Dusty

Offline

#7 2005-05-26 08:26:54

thogie
Member
Registered: 2005-05-24
Posts: 11
Website

Re: archlinux inside archlinux (user-mode-linux) howto

An answer after 1,5h?? I am definitly impressed. And at the moment over 120 views? You people out there seem to be very interested in this topic... A good reason to make this a good one  big_smile.

i3839 wrote:

1) Shouldn't that be:

dd if=/dev/zero of=archRootFs bs=1MB count=1000
dd if=/dev/zero of=swap bs=1MB count=100

Why don't you use a file within archRootFs as swapfile? Why use a swapfile at all, UML can be swapped by the real kernel can't it?

You are right! Thanks for correcting the typo. As you are right for the swap file - here is the correspondig quote from the uml command line help:

mem=<Amount of desired ram>
    This controls how much "physical" memory the kernel allocates for the system. The size is specified as a number followed by one of 'k', 'K', 'm', 'M', which have the obvious meanings. This is not related to the amount of memory in the host.  It can be more, and the excess, if it's ever used, will just be swapped out.

i3839 wrote:

2) Ext2 is fine, it is no real filesystem anyway. Having a journalling fs on top of a real journaling fs makes not much sense.

Fine :-).

i3839 wrote:

3) Perhaps add it to fstab so you can mount it easily and at each bootup with the correct mount options? (noatime,nodiratime)

Uh oh, I knew I would forget something. Unmount the image before starting!! Do not change anything inside your mounted file image, while the uml linux is running! (e.g. under /mnt/) This may lead to significant filesystem corruption inside your uml machine and may kill it.

i3839 wrote:

4) Perhaps promote to use a close mirror here (archlinux.de seems to redirect/point to archlinux.org).

Ok.

i3839 wrote:

5) Hm, what about something like

lsmod | sed 's/ .*//' > /mnt/tmp/modulelist

and then in UML load all modules from that file? Then you can still use hotplug for real hotplugging, but use that for the coldplug which is already done by the real system. This won't work if you have scripts that must be run by hotplug of course, but for loading the moduels only it's fine.

Sorry, but this is behind my knowdledge of linux. Maybe someone can explain me in detail and with short words what this does? To be honest, at the moment I am simply happy that uml works and do not have the need to load any modules :oops:.

i3839 wrote:

6) Tell in which package tunctl can be found and make it more clear that this must be done in the host Arch system and not in UML.

The tunctl util is part of the uml_utilities.

i3839 wrote:

7) "eth0=tuntap,,,192.168.0.100" is a bit strange, perhaps care to tel what the ,,, are for? Doesn't eth0=tuntap,192.168.0.100 work too?

The ",,," means (Isn't there a joke about three shells?)

eth0=transport,tuntap device,MAC adress,ip

example:

eth0=tuntap,tap0,3f:2a:bb:00:00:00,192.168.3.23

Without the 3 commas the network did not work in my case.
It is for example possible to pre define a tap0 device with a certain MAC and IP adress. Especialy useful if you don't want to throw away 2 adresses for each uml instance you run. But I think I will keep it simple. There is more than one way to get network running under uml (http://user-mode-linux.sourceforge.net/ … WTO-6.html).

i3839 wrote:

Isn't using screen + ssh better than vnc or can vnc handle it when the client disconnects? And wasn't vnc for graphical stuff, surely you don't have X on your server?

I use vnc mainly to watch boot messages (for example waiting 5min till the hotplug daemon fails ;-)) My suggestion is, to use screen + ssh as soon as it is clear that the uml machine starts and brings up network + services automatically.

i3839 wrote:

Other comments: Make clear what UML can be used for and main reason why it is good (security).

I will stretch the "Why?" section a little bit.

(It is now 10:30h here in germany, it is already slightly above 15 degree, a holiday and I will now go out and do a little tour with my motorcycle big_smile
Go out and enjoy the sun too (if you can))

Offline

#8 2005-05-26 11:14:28

i3839
Member
Registered: 2004-02-04
Posts: 1,185

Re: archlinux inside archlinux (user-mode-linux) howto

Ah yes, unmounting is a very good idea indeed.

Ignore my point 5, just don't use hotplug with UML, of course it doesn't need the modules, as it has no real hardware anyway. Silly me.

It's 27 degrees here now, I'll go outside after working through the forum and doing other slightly more important things, like eating.

Offline

#9 2005-05-28 10:05:04

thogie
Member
Registered: 2005-05-24
Posts: 11
Website

Re: archlinux inside archlinux (user-mode-linux) howto

Here you can find the wiki article:

http://wiki2.archlinux.org/index.php/us … de%20arch)

Offline

#10 2006-02-21 00:49:54

ben017f
Member
From: Auckland, New Zealand
Registered: 2006-01-06
Posts: 18

Re: archlinux inside archlinux (user-mode-linux) howto

I have a PKGBUILD for a 2.6 UML kernel is anyone wants it. one the other hand it didn't take long to convert from the kernel package in abs so u might want to do your own!


The map is not the territory

Offline

#11 2007-04-12 21:05:23

prhlava
Member
Registered: 2007-04-12
Posts: 2

Re: archlinux inside archlinux (user-mode-linux) howto

few points about UML howto page on wiki.

the networking using the tun/tap driver steps (modprobe tun, the tunctl and ifconfig tap) are not necessary (if the /dev/net/tun is read and write by user running UML).

just specify:

eth0,tuntap,,,ip-adddress-1

when running uml

then in the guest do:

ifconfig eth0 ip-address-2 up

the uml_net script will automatically configure host system tap driver and host system routing. add default gateway on guest (+ modify the /etc/resolv.conf also on guest) and networking is up.

also, there is a quirk if the guest distribution is Debian Etch - one has to specify an existing MAC address for relevant eth? interface for tun/tap (i got the hint about this on Gentoo user mode linux page). not sure this is necesarry if the guest distro is Arch.

vlad

ps: i would edit the wiki page directly but i am not sure about rules on editing the wiki so i post here...

Offline

Board footer

Powered by FluxBB