January 14, 2013

uml and console job control

I started uml with my host debian file system:


./linux rootfstype=hostfs rw init=/home/tzhang/uml/init-uml.sh mem=64M TERM=linux eth0=tuntap,,,192.168.6.88

However the shell I get does not have job control. I tried multiple things found on internet but none did the trick for me. This is what finally solved the problem:

1. get busybox and build it with the "cttyhack" enabled (in shell section of menuconfig)
2. ln -sf busybox cttyhack
3. run that in your init. My init.sh looks like this:


#!/bin/bash
export PS1="[\\u@\\h:\\w] $"
export HOME=/home/tzhang
. /home/tzhang/.bashrc
ifconfig eth0 192.168.6.99
hostname -b R1
export PATH=/usr/local/bin:/usr/bin:/bin:/sbin:/usr/local/sbin:/usr/sbin
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t tmpfs tmpfs /var/run -o rw,nosuid,nodev
mount -t tmpfs tmpfs /var/log -o rw,nosuid,nodev
cd $HOME/uml


mount -t tmpfs /dev/ /dev/

/etc/init.d/udev start
/home/tzhang/uml/dropbear -r dropbear_rsa_host_key
exec setsid /home/tzhang/uml/cttyhack bash

This solved the problem beautifully. The last line is what did the trick for job control.
the udev daemon and dropbear made ssh possible.

=============UPDATED 4/10/2017=====================
init.sh:
#!/bin/bash
export PS1="\u@\h:\w $"
export HOME=/home/tzhang
. /home/tzhang/.bashrc
ifconfig eth0 192.168.6.99
hostname -b R1
export PATH=/usr/local/bin:/usr/bin:/bin:/sbin:/usr/local/sbin:/usr/sbin
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t tmpfs tmpfs /var/run -o rw,nosuid,nodev
mount -t tmpfs tmpfs /var/log -o rw,nosuid,nodev
cd $HOME/uml

mount -t tmpfs /dev/ /dev/
ifconfig eth1 192.168.3.2
ifconfig eth0 192.168.2.2

busybox mdev -s
mkdir /dev/pts
mount -t devpts /dev/pts /dev/pts

#dropbear -r dropbear_rsa_host_key -p 2222
exec setsid /home/tzhang/uml/cttyhack bash


run.sh
./linux rootfstype=hostfs rw init=/home/tzhang/uml/init.sh mem=64M TERM=linux \
eth0=tuntap,tap0,,192.168.2.88 \
eth1=tuntap,tap1,,192.168.3.88

Host /etc/network/interfaces
# The primary network interface
auto ens33
iface ens33 inet manual
auto ens38
iface ens38 inet manual
auto tap0
iface tap0 inet manual
    pre-up ip tuntap add tap0 mode tap user tzhang
    up ip link set dev tap0 up
auto tap1
iface tap1 inet manual
    pre-up ip tuntap add tap1 mode tap user tzhang
    up ip link set dev tap1 up
auto br0
iface br0 inet dhcp
        bridge_ports ens33 tap0
auto br0:1
allow-hotplug br0:1
iface br0:1 inet static
        address 192.168.2.1
        broadcast 192.168.2.255
        netmask 255.255.255.0
auto br1
iface br1 inet dhcp
        bridge_ports ens38 tap1
auto br1:1
allow-hotplug br1:1
iface br1:1 inet static
        address 192.168.3.1
        broadcast 192.168.3.255
        netmask 255.255.255.0

No comments:

Post a Comment