You are not logged in.
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=1000The 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 swapThis 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 /mnt4.) 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/archlinux5.) 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 0To 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 up7.) 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.100I 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
1) Shouldn't that be:
dd if=/dev/zero of=archRootFs bs=1MB count=1000
dd if=/dev/zero of=swap bs=1MB count=100Why 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/modulelistand 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
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
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
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
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
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
.
1) Shouldn't that be:
dd if=/dev/zero of=archRootFs bs=1MB count=1000 dd if=/dev/zero of=swap bs=1MB count=100Why 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.
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 :-).
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.
4) Perhaps promote to use a close mirror here (archlinux.de seems to redirect/point to archlinux.org).
Ok.
5) Hm, what about something like
lsmod | sed 's/ .*//' > /mnt/tmp/modulelistand 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:.
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.
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,ipexample:
eth0=tuntap,tap0,3f:2a:bb:00:00:00,192.168.3.23Without 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).
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.
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
Go out and enjoy the sun too (if you can))
Offline
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
Here you can find the wiki article:
Offline
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
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