{"id":525,"date":"2007-02-13T12:03:04","date_gmt":"2007-02-13T16:03:04","guid":{"rendered":"http:\/\/adterrasperaspera.com\/blog\/2007\/02\/13\/how-to-make-a-uml-image-on-debian\/"},"modified":"2013-11-13T04:53:05","modified_gmt":"2013-11-13T09:53:05","slug":"how-to-make-a-uml-image-on-debian","status":"publish","type":"post","link":"https:\/\/adterrasperaspera.com\/blog\/2007\/02\/13\/how-to-make-a-uml-image-on-debian\/","title":{"rendered":"How to make a UML image on Debian"},"content":{"rendered":"<p>Out there, on the Internet, there is a lot of conflicting information on how to properly build a UML image on Debian. These instructions are for Debian Sid, but should work on Etch and Sarge as well. The instructions are partially based on the ones available <a href=\"http:\/\/uml.nagafix.co.uk\/Debian-3.1\/install.html\">here<\/a>.<\/p>\n<p>First, you want to <code>apt-get install user-mode-linux uml-utilities bridge-utils debootstrap realpath<\/code>. Then, become root either by <code>su<\/code> or <code>sudo bash<\/code>. Make an empty directory (such as <em>~\/uml<\/em>) and <code>cd<\/code> into it. Now, follow this psudeo script:<\/p>\n<p><code><br \/>\n# setup environment, feel free to change DEBIAN_MIRROR to your closest mirrror, IP to an IP not already being used on your network, and GATEWAY to your LAN's gateway (not your host machine)<br \/>\nexport TMPDIR=`pwd`\"\/tmp\"<br \/>\nexport IMAGE=\"root_fs\"<br \/>\nexport DEBIAN_MIRROR=\"ftp:\/\/ftp.debian.org\/debian\/\"<br \/>\nexport HOSTNAME=\"NameThisMachine\"<br \/>\nexport IP=\"a.ip.to.use\"<br \/>\nexport GATEWAY=\"ip.to.talk.to\"<br \/>\nmkdir $TMPDIR<\/p>\n<p># produce a 1GB image, fudge with seek to change size<br \/>\ndd if=\/dev\/zero of=$IMAGE bs=1 count=1 seek=1G<\/p>\n<p># make partition, and mount it; Debian Sid kernels can only mount ext2, ext3, cramfs, iso9660, and reiserfs, ext3 is the only one worth using<br \/>\nmkfs.ext3 $IMAGE<br \/>\nmount -o loop $IMAGE $TMPDIR<\/p>\n<p># download and install Debian into your image: change arch to the arch you're using, and change sid to sid, etch, or sarge; this step takes awhile<br \/>\ndebootstrap --arch i386 sid $TMPDIR $DEBIAN_MIRROR<\/p>\n<p># install a correct fstab, proc and sys are automatically loaded on boot<br \/>\necho \"\/dev\/ubd0 \/ ext3 defaults 0 0\" > $TMPDIR\/etc\/fstab<br \/>\necho $HOSTNAME > $TMPDIR\/etc\/hostname<\/p>\n<p># tweak inittab<br \/>\ncp $TMPDIR\/etc\/inittab $TMPDIR\/etc\/inittab.save<br \/>\ngrep -v \"getty\" $TMPDIR\/etc\/inittab.save > $TMPDIR\/etc\/inittab<br \/>\necho \"# We launch just one console for UML:\" >> $TMPDIR\/etc\/inittab<br \/>\necho \"c0:1235:respawn:\/sbin\/getty 38400 tty0 linux\" >> $TMPDIR\/etc\/inittab<br \/>\necho \"# UML modification: use tty0 or vc\/0\" >> $TMPDIR\/etc\/securetty<br \/>\necho \"tty0\" >> $TMPDIR\/etc\/securetty<br \/>\necho \"vc\/0\" >> $TMPDIR\/etc\/securetty<\/p>\n<p># add networking stuff<br \/>\necho \"auto lo\" >> $TMPDIR\/etc\/network\/interfaces<br \/>\necho \"iface lo inet loopback\" >> $TMPDIR\/etc\/network\/interfaces<br \/>\necho \"\" >> $TMPDIR\/etc\/network\/interfaces<br \/>\necho \"auto eth0\" >> $TMPDIR\/etc\/network\/interfaces<br \/>\necho \"iface eth0 inet static\" >> $TMPDIR\/etc\/network\/interfaces<br \/>\necho \"address $IP\" >> $TMPDIR\/etc\/network\/interfaces<br \/>\necho \"netmask 255.255.255.0\" >> $TMPDIR\/etc\/network\/interfaces<br \/>\necho \"gateway $GATEWAY\" >> $TMPDIR\/etc\/network\/interfaces<\/p>\n<p># clean up<br \/>\numount $TMPDIR<br \/>\nrmdir $TMPDIR<br \/>\n<\/code><\/p>\n<p>You now have an image full of Debian named root_fs. To run, simply execute <code>linux mem=64M ubd0s=root_fs<\/code>. If you need more memory, increase the <code>mem<\/code> paramater. By default, there is no password for root, so just use root as your login and press enter when it asks for password.<\/p>\n<p>A little aside on networking:the auto tuntap method (<code>eth0=tuntap,,,the.ip.to.use<\/code>, which basically does ARP proxying on the host machine) does not work properly as it only allows host-&gt;UML traffic. The only way I&#8217;ve been able to get UML networking to work properly is to build a full bridge setup. The following commands in <code>\/etc\/network\/interfaces\/<\/code> sets up the bridge. You probably have something like:<\/p>\n<p><code>auto eth0<br \/>\niface eth0 inet dhcp<br \/>\n<\/code><\/p>\n<p>Comment that out with #s, and change it to:<\/p>\n<p><code>auto br0<br \/>\niface br0 inet dhcp<br \/>\npre-up tunctl -u user-to-run-uml -t tap0<br \/>\npre-up ifconfig eth0 0.0.0.0 promisc up<br \/>\npre-up ifconfig tap0 0.0.0.0 promisc up<br \/>\npre-up brctl addbr br0<br \/>\npre-up brctl stp br0 off<br \/>\npre-up brctl setfd br0 1<br \/>\npre-up brctl sethello br0 1<br \/>\npre-up brctl addif br0 eth0<br \/>\npre-up brctl addif br0 tap0<br \/>\npost-down tunctl -d tap0<\/p>\n<p>allow-hotplug eth0<br \/>\niface eth0 inet manual<br \/>\npre-up ifconfig eth0 0.0.0.0 promisc up<br \/>\npre-up brctl addif br0 eth0<br \/>\npre-down brctl delif br0 eth0<br \/>\npre-down ifconfig eth0 down<br \/>\n<\/code><\/p>\n<p>Add the additional parameter to <code>linux<\/code>&#8216;s command line: <code>eth0=tuntap,tap0<\/code>. That will make UML connect to tap0, and use the IP set above when you built the image. If you use a firewall, you need to change the interface to firewall from eth0 to br0, and to allow br0->br0 traffic.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Out there, on the Internet, there is a lot of conflicting information on how to properly build a UML image on Debian. These instructions are for Debian Sid, but should work on Etch and Sarge as well. The instructions are partially based on the ones available here. First, you want to apt-get install user-mode-linux uml-utilities [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[404],"tags":[],"_links":{"self":[{"href":"https:\/\/adterrasperaspera.com\/blog\/wp-json\/wp\/v2\/posts\/525"}],"collection":[{"href":"https:\/\/adterrasperaspera.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adterrasperaspera.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adterrasperaspera.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/adterrasperaspera.com\/blog\/wp-json\/wp\/v2\/comments?post=525"}],"version-history":[{"count":5,"href":"https:\/\/adterrasperaspera.com\/blog\/wp-json\/wp\/v2\/posts\/525\/revisions"}],"predecessor-version":[{"id":2248,"href":"https:\/\/adterrasperaspera.com\/blog\/wp-json\/wp\/v2\/posts\/525\/revisions\/2248"}],"wp:attachment":[{"href":"https:\/\/adterrasperaspera.com\/blog\/wp-json\/wp\/v2\/media?parent=525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adterrasperaspera.com\/blog\/wp-json\/wp\/v2\/categories?post=525"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adterrasperaspera.com\/blog\/wp-json\/wp\/v2\/tags?post=525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}