Data publikacji: May 12, 2011 8:57:22 AM
# apt-get install uml-utilities
# cat /etc/default/uml-utilities
UML_SWITCH_OPTIONS="-tap tap0"
# cat /etc/network/interfaces
auto tap0
iface tap0 inet static
address 192.168.57.1
netmask 255.255.255.0
tunctl_user uml-net
# cat /etc/network/if-up.d/tap0
#!/bin/bash
[ "$IFACE" == "tap0" ] || exit 0;
for IFACE_OUT in eth0 wlan0; do
iptables -t nat -A POSTROUTING -s 192.168.57.0/24 -o $IFACE_OUT -j MASQUERADE
done
# cat /etc/network/if-down.d/tap0
#!/bin/bash
[ "$IFACE" == "tap0" ] || exit 0;
for IFACE_OUT in eth0 wlan0; do
iptables -t nat -D POSTROUTING -s 192.168.57.0/24 -o $IFACE_OUT -j MASQUERADE
done
# ifup tap0
# apt-get install dnsmasq
# cat /etc/dnsmasq.conf
conf-dir=/etc/dnsmasq.d
# cat /etc/dnsmasq.d/config
interface=lo
bind-interfaces
# cat /etc/dnsmasq.d/tap0
interface=tap0
dhcp-range=192.168.57.100,192.168.57.150,255.255.255.0,12h
# /etc/init.d/dnsmasq restart
# /etc/init.d/uml-utilities restart
# mkdir /uml# dd if=/dev/zero of=/uml/rootfs bs=1M count=1000
# mkfs.ext3 /uml/rootfs
# mkdir /uml/mnt
# mount -o loop /uml/rootfs /uml/mnt
# sudo debootstrap --include=ssh,udev lenny /mnt/ http://ftp.pl.debian.org/debian
# chroot /mnt
# passwd root
# apt-get install locales && dpkg-reconfigure locales
# cat /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
# cat /etc/network/hostname
uml
# cat /etc/network/fstab
/dev/ubda / ext3 defaults 0 1
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
# cat /etc/resolv.conf
nameserver X.X.X.X
# exit
# umount /uml/mnt
# mkdir linux
# cd linux
# ... pobranie i rozpakowanie kernela do tego katalogu ...
# make defconfig ARCH=um
# make menuconfig ARCH=um
# make ARCH=um
# cd ..
# ln -s ../linux/linux
# ./linux ubd0=/uml/rootfs mem=256M eth0=daemon,,,/var/run/uml-utilities/uml_switch.ctl xterm=gnome-terminal,-t,-x uml_dir=run umid=linux
# cat /uml/gdb.script
handle SIGSEGV pass nostop noprint
handle SIGUSR1 pass nostop noprint
cont
# ddd -x gdb.script /uml/linux `cat /uml/run/linux/pid` &
# kill -SIGINT cat /uml/run/linux/pid
Znalezione na stronie: http://140.120.7.20/LinuxRef/UML/UmlCompilation.html
#v+
modprobe module failed (09/05/2012)
Modify Line 42 in arch/x86/Makefile.um to START := 0x8048000?
With START := 0x60000000 assignment, Uml kernel will fail to load any module, if memory size >= 504M. Actually, it even fails on any "modprobe", since any address relocation translates to a negative address.
$ diff arch/x86/Makefile.um arch/x86/Makefile.um.orig 42,45c42 < ########################################## < # START := 0x60000000 < ########################################## < START := 0x8048000 --- > START := 0x60000000
Linux.uml Fails to Boot (04/28/2011)
The next two modifications are no longer needed.
On kernel 3.2.23, the thread_info.h file has been modified:
$ diff arch/um/include/asm/thread_info.h ../linux-source-2.6.32/arch/um/include/asm/thread_info.h 52,55c53 < void *p; < < asm volatile ("" : "=r" (p) : "0" (&ti)); < ti = (struct thread_info *) (((unsigned long)p) & ~mask); --- > ti = (struct thread_info *) (((unsigned long) &ti) & ~mask);
On kernel 2.6.?, what we did was as follows:
$ diff arch/um/include/asm/thread_info.h arch/um/include/asm/thread_info.h.orig 50d49 < /* 55,57d53 < */ < register unsigned long sp asm("esp"); < return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
Note: (11/13/2011) After kernel 2.6.32-39, may safely ignore next section.
$ diff arch/um/os-Linux/mem.c arch/um/os-Linux/mem.c.orig 206,208d205 < /*************************/ < extern fchmod(); < /*************************/
Linux Source from Debian (Wheezy) Linux Source from Debian and uml-config.amd64
Note: (09/04/2012) Debian squeeze soon to be replaced by wheezy. 3.2-1um-1 source pkg.
May also scp linux source via: amdm:/var/spool/apt-mirror/mirror/debian.nctu.edu.tw/debian/pool/main/l/linux-2.6/linux-source-3.2*all.deb. (Check for the newest version!)
$ ls -l /var/spool/apt-mirror/mirror/debian.nctu.edu.tw/debian/pool/main/l/linux-2.6/linux-source-3.2*
$ cd $HOME/Downloads $ sudo dpkg -i linux-source-3.2_3.2.23-1_all.deb $ rm linux-source-3.2_3.2.23-1_all.deb $ if [ ! -d /src3/kernel ] then sudo mkdir /src3/kernel sudo chown hsu:hsu /src3/kernel mkdir /src3/kernel/gz cd /src3/kernel/gz else rm /src3/kernel/gz/*; rm -rf /src3/kernel/linux-source-* cd /src3/kernel/gz fi $ sudo mv /usr/src/linux-source-3.2.tar.bz2 . $ cd .. $ tar -xjvf gz/linux-source-3.2.tar.bz2 # We get and install the linux source from Debian, not Ubuntu. If Ubuntu # gets newer version of linux source, we will be asked to upgrade it. We # don't want this to happen, since Ubuntu Linux is error prone!! $ sudo synaptic # remove linux-source package from it so that package system # does not know that we got it. # Get /boot/config-3.2* from any Debian based host. Remember to # upgrade its kernel to newest version and then scp it to /tmp. $ cd linux-source-3.2 # In case we would like to compile and install our own kernel, we use Dconfig # as our configuration file. Here, we compile it for UML linux, Debian has # already prepared it for us, we copy it to .config file. $ mv /tmp/config-3.2* Dconfig $ cp $HOME/Downloads/config.amd64 .config $ sudo apt-get install libncurses5-dev $ make ARCH=um menuconfig # Choose the last item: Save alternate .config file and exit. $ make ARCH=um linux $ echo $? # Check whether linux was successfully made. # Check /src3/kernel/linux-source-3.2/arch/um/Kconfig.net for missing # packages (libraries). Probably, need to install the next few. $ apt-cache search libvdeplug $ sudo apt-get install libvdeplug2 libvdeplug2-dev # [02/05/2012]: On Debian Sid, libvdeplug2-dev is broken, libvdeplug-dev installed. # [03/21/2012]: Forgot to provide the next reference, sorry. # libvdeplug-dev $ apt-cache search libpcap $ sudo apt-get install libpcap-dev $ ls -lia linux vmlinux 9975399 -rwxr-xr-x 2 hsu hsu 5868734 2010-09-10 15:51 linux 9975399 -rwxr-xr-x 2 hsu hsu 5868734 2010-09-10 15:51 vmlinux # We see a huge 5.8 MB executable. $ linux --version 3.2.23 $ linux --help # It seems our new user mode linux kernel is OK! $ make ARCH=um modules $ echo $? # Check whether linux modules were successfully made. $ if [ ! -d /usr/local/lib/uml ] then sudo mkdir /usr/local/lib/uml sudo chown hsu:hsu /usr/local/lib/uml else rm -rf /usr/local/lib/uml/lib/* fi $ make ARCH=um modules_install INSTALL_MOD_PATH=/usr/local/lib/uml # When stripping symbols from binary file, its size becomes smaller, loads fast, # requires less memory. But, you lose debug or warning information. If program # crashs, probably, you have no idea why it crashed. # $ strip linux # $ mv linux linux.uml $ cp linux /usr/local/lib/uml/linux.uml $ make clean $ make distclean
#v-