Finally, NetBSD Boots in KVM!

Compared to OpenBSD and FreeBSD the NetBSD install was hard, really hard. It wasn't until I stumbled across this that I managed to convince myself to try it again.

The trick seems to be to ignore as much as you can from other Internet tips. NetBSD runs fine in KVM, so if someone says you need to run it in Qemu mode - don't believe the hype. OK, in virt-manager there is no preset defaults for NetBSD, so I went with a generic OS and tried starting the install from there. The kernel hangs before it probes USB, or it segfaults.

What I did was to stop the guest, and in the details view I disabled ACPI and selected the pcnet NIC instead of the default ne2k-pci. Running the default options in the NetBSD 5.0.2 installer, and the bootloader after install, works fine.

Good Luck!

Sunday, 29 August 2010 at 20:44 | /unix | permanent link to this entry

Syntax Highlighting in less

Yes, it's certainly possible and source code becomes so much easier to read. Try it out by downloading my .lessfilter, save it as ~/.lessfilter in your $HOME.

Then try it out on a C source file: less -R myfile.c, soon you will probably add a line alias less="less -R" to your ~/.bash_aliases file. :-)

Sunday, 09 May 2010 at 19:53 | /unix | permanent link to this entry

HowTo Resize an Irssi Session in Screen

Press Ctrl-a Shift-f

Dead. Simple.

Tuesday, 14 July 2009 at 23:27 | /unix | permanent link to this entry

Howto Setup and run Xen

This is an extremly brief and quick Xen tutorial. There are lots of them already, see your <DISTRIBUTION> wiki, HowtoForge or other places for a starter guide. This particular HowTo deals with setting up Xen as easy as possible using Ubuntu 8.04 LTS as host operating system (dom0 in Xen terms) and Ubuntu 9.04 as guest operating systems (domU in Xen lingo).

Ubuntu 8.04 LTS comes with a Xen kernel that can run as dom0. This is quite important, so pay attention to setting that up correctly. For this I recommend the HowtoForge Tutorial.

Note: you will need to upgrade the default Xen 3.2 to 3.3 to be able to run the latest distributions as guest OS. See this Ubuntu question for more insight. To get Xen 3.3, simply activate the Hardy backports repository in your /etc/apt/sources.list and, as usual, pay attention to your /boot/grub/menu.lst so that it points out the Xen 3.3 image in the "defaults=" option.

More useful help can be found in the Debian and Ubuntu wikis:

When done with the basic setup you should install pygrub on your host, this is a truly magic piece of software that makes it possible to boot all guests using their own kernel and modules. See the Debian wiki for some details on install and setup: http://wiki.debian.org/PyGrub. Then ignore what you read and do like this:

# /var/lib/xend/domains/example/config.sxp - Xen domU example.
# Note the order of partitions in disk=[], the first listed partition
# is the partition where your /boot (grub) resides. 
bootloader  = '/usr/bin/pygrub'

builder     = 'linux'
memory      = '2048'
root        = '/dev/xvda1 ro'

disk        = [
 'phy:/dev/disk/by-uuid/df3418f5-2fc3-443c-8e64-4395828dc678,xvda1,w',
 'phy:/dev/disk/by-uuid/acecf01e-c4d9-4a7b-b18a-681c69f71173,xvda2,w',
]

name        = 'example'

vif         = [ 'bridge=eth1' ]
dhcp        = "off"
ip          = "12.34.56.78"
netmask     = "255.255.255.252"
gateway     = "12.34.56.77"
hostname    = "example"

on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'
vcpus       = 1
extra       = 'xencons=tty1'

When installing grub on your guest, don't pay any attention to grub complaining about not being able to map /dev/xvda1 to a BIOS disk. pyGrub doesn't care about such wordly things as physical disks. Just make sure the /boot directory's partition (often '/') is the first listed in the disk=[] array above.

You may need to edit the /usr/sbin/update-grub script before installing grub. Search for "in_xen", a fairly long way down. Make sure it's set to in_xen=1 before the big if[]-clause that depends on it. Without this fix the Xen able kernels in Ubuntu 9.04, and later, are not detected.

Now run update-grub and answer yes to the questions. Take good care to verify that the script actually finds one active (server) kernel and adds it properly to your /boot/grub/menu.lst file.

Another common problem is the lack of a console login. Usually you don't need one, but if you'd like to check your domU from within your dom0 you need to add the file "console" to /etc/event.d

# console - getty
#
# This service maintains a getty on the Xen serial console
# from the point the system is started until it is shut
# down again.

start on stopped rc2
start on stopped rc3
start on stopped rc4
start on stopped rc5

stop on runlevel 0
stop on runlevel 1
stop on runlevel 6

respawn
exec /sbin/getty 38400 console

That should do the trick! If it doesn't, then there's plenty of help to find in the Debian and Ubuntu wikis, see links above. Good luck!

Monday, 08 June 2009 at 22:05 | /unix | permanent link to this entry

Network Programming — Link Collection

This is a first effort at collecting information about network programming structs and APIs available in UNIX. I plan on updating this as I find more.

There are of course, in addition to these fine sources, the entire catalogue of work by Richard M. Stevens. May he rest in peace. His works are considered the reference litterature on this subject, see for instance the UNIX Network Programming (review).

Tuesday, 10 February 2009 at 21:56 | /unix | permanent link to this entry

The joy of colors

Ever so often, as I have mentioned before, I lose myself in trying to find new ways of working and doing my daily tasks, one such digression is the topic of editors. I mainly use GNU Emacs for development and other major tasks, for everything else I use vim.

Vim is quick to start, capable, good looking and easy to use, contrary to other vi implementations. (Most notably nvi, which I hate with a passion!) Today I found a neat colorscheme that works well on terminals with a black background. It's called 'advantage' and is available from the Vim Color Scheme Test.

To install it you simply download advantage.vim and copy it to your /usr/share/vim/vim71/colors/ directory. Then you open your current C source in vim and type :colorscheme advantage.

Thank you Shan Leung Maverick Woo! :-)

Sunday, 09 November 2008 at 00:39 | /unix | permanent link to this entry

Regexp replace in many files

I just have to blog about this exceptional tool I just found. It is called regexxer and is a tool in the true UNIX spirit — it does one job only, and does it well.

Sunday, 13 July 2008 at 21:38 | /unix | permanent link to this entry

Top Ten UNIX Shell Commands

Current trend is to run the following one-liner from IBM. I'm usually logged in to the following three systems, with very different results:

vmlinux.org

$ history |awk '{print $2}'|sort|uniq -c|sort -nr|head -10
    144 ls
     61 cd
     58 sudo
     29 less
     23 emacs
     19 bzr
     16 vim
     11 rm
     10 wget
     10 mv

My personal life. Not much different from my professional dito. Most visible difference maybe is my use of bzr instead of svn. At the time we decided on svn at work bzr had not matured enough and darcs didn't (still doesn't) have a Windows client as good as TortoiseSVN.

Build server @work

$ history |awk '{print $2}'|sort|uniq -c|sort -nr|head -10
    108 cd
     63 svn
     44 search
     41 ls
     25 sudo
     23 less
     23 ./build.sh
     21 make
     17 ./netprobe
     16 man

Mostly work stuff, 'search' is a small wrapper around find that skips .svn dirs and semantic.cache files and other annoying things you constantly run in to when looking for something. The build script is a small wrapper around make for our Snapgear and uClinux-dist trees. Netprobe was one of the last prototypes I wrote to investigate some UNIX peculiarities involving libnet and libpcap.

troglobit (my laptop)

$ history |awk '{print $2}'|sort|uniq -c|sort -nr|head -10
    140 sudo
     47 ifconfig
     45 less
     27 ps
     26 ssh
     25 iwconfig
     21 ping
     21 man
     15 ls
     15 cd

Well, I'm having trouble with my laptop network. The wlan (wpa_supplicant) doesn't like suspend/resume on my ThinkPad T43.

Update: I had to make an update to this, even at first I had my doubts about the first script. It didn't feel right, now after revising it, and reading Planet Debian, I noticed Erich Schuberts entry. There it was, the working script, which I only had to bashify! Thanks Erich!

Saturday, 23 September 2006 at 23:02 | /unix | permanent link to this entry