Sunday, May 20, 2007

Firefox Keys

Not having my keybindings in my browser is annoying. When filling out a form C-a should jump to the start of a line not highlight all of the text. C-u should clean out the text before a line, not show the page source. All I had to do was:
echo "gtk-key-theme-name = \"Emacs\"" > ~/.gtkrc-2.0
and restart firefox. See Emacs Keybindings - Firefox for more information.

Saturday, May 19, 2007

Network Basics

Gateway

When I set up my NetBSD system I only added the following to my /etc/rc.conf:
dhclient=YES
This worked but after a few days of leaving the system unattended I found that I was unable to ping outside of my network. I was able to fix this by adding a default route:
route add default 192.168.1.1
The above is just like the Linux command except 'gw' comes before the IP. The above can be set permanently by adding the following to /etc/rc.conf:
defaultroute="192.168.1.1"
Note how this varies across BSDs. In FreeBSD it's defaultrouter (with an 'r' at the end). OpenBSD encourages using /etc/mygate for this setting, which NetBSD supports but recommends using the above instead. "route add default gw 192.168.1.1"

Static IPs

Rather than guess how my hosts have changed based on who booted when, I prefer to hard code IPs. I think I'll run a home DNS server at some point, but for now my small network can just share /etc/host files. It's easy enough to have this kind of set up with a few boxen and a WRT54G. My mac is set with the following:

To do something similar in NetBSD I removed the DHCP entry from my /etc/rc.conf and added the following:

ifconfig_fxp0="inet 192.168.1.101 netmask 255.255.255.0"
Note that you should also make sure that DHCP is no longer running:
/etc/rc.d/dhclient stop
kill `cat /var/run/dhclient.pid`
My /etc/resolv.conf was set correctly by DHCP so I don't need to update it. Now I just share my /etc/hosts which I derived from properties of both systems:
# Sat May 19 12:23:11 EDT 2007

::1                     localhost           
127.0.0.1               localhost           
255.255.255.255         broadcasthost

# RFC 1918 specifies that these networks are "internal".
# 10.0.0.0      10.255.255.255
# 172.16.0.0    172.31.255.255
# 192.168.0.0   192.168.255.255

192.168.1.100   nenya  
192.168.1.101   narya

Thursday, May 17, 2007

Kill NFS Client Process

Yesterday I had a 8-core system with 16GB of RAM running a load average of 4. It was trying to connect to an NFS mount that it could no longer reach. Trying to view the mounted directory resulted in hangs. You get around those by doing:
killall -9 rpciod
But that won't kill the process since it's really using a kernel thread which will keep trying to get to the mount on NFS's behalf. I added a local firewall rule which was enough to convince it to give up:
iptables -I OUTPUT -d x.x.x.x -j REJECT
where x.x.x.x is the IP of the NFS server. I was then able to umount it after a little bit of delay from the above. The load average then dropped to 0.01. Looks like I'm on some kind of RedHat kick since I gleamed this from Interrupting those pesky "uninterruptible" processes. I'm curious about all of this and the following seem helpful: While looking around for how to kill the process I found Useless use of kill -9 which has a fitting picture for its content.

Tuesday, May 15, 2007

NIC Options

I recently had to change the speed, duplex and other parameters on an Ethernet card. It's easy to do this in redhat. I haven't yet had to do it on a BSD but it seems that I can pass an option to rc.conf (see Optimizing Your Configuration) and read the ifmedia man page. I was tweaking these settings to try to get a PowerEdge 1955 blade working with an older switch that doesn't support gigabit ethernet. Turns out that the chasis for these blades can't do that. It has to be plugged into a newer switch that supports gigabit ethernet. Dell told me that I could plug into a gig switch and then negotiate to 10 or 100, but that misses the point.

Sunday, April 29, 2007

First things first...

If I'm going to be working on NetBSD I might as well get comfortable.
  • Base Install:

    Followed steps 3, 4 and 5 of a standard installation of NetBSD 3.1

  • Base Packages:

    Mounted pkg CD (/mnt/cdrom/packages/i386/All) and did a

    pkg_add bash-3.2.tgz wget-1.10.2nb1.tgz
    

    Then I did a wget and pkg_add of emacs from the FTP site.

  • X:

    Again from the pkg CD:

    pkg_add fluxbox-0.9.15.1nb1.tgz
    echo "exec startfluxbox" > ~/.xinitrc
    

    logged in and did a startx and it worked. Note that I had modified my /etc/X11/XF86Config before.

    My mouse wheel didn't scroll at first. At the boot prompt I did a boot -c to get into userconf. I then did a disable pms and it's working now.

  • Firefox

    Again from the pkg CD:

    pkg_add firefox-2.0.0.1.tgz 
    

    The binary firefox package for NetBSD 3.1 seems to chmod your preference/profile files so that they are not writeable. So, none of my preferences were saved and I couldn't bookmark anything.

    In ~/.mozilla/firefox/fo6yv9d7.default/ I saw:

    > ls -g bookmarks.html
    -r--r--r--  1 users  9764 Apr 25 20:10 bookmarks.html
    >
    
    

    After chmod'ing them 644 I was able to bookmark pages. Other files had the same issue:

    > find . -perm 444 -print
    ./chrome/userChrome-example.css
    ./chrome/userContent-example.css
    ./localstore.rdf
    ./mimeTypes.rdf
    ./search.rdf
    ./bookmarkbackups/bookmarks-2007-04-11.html
    ./bookmarkbackups/bookmarks-2007-04-12.html
    ./bookmarkbackups/bookmarks-2007-04-25.html
    >
    

    Easy enough to fix what I have:

     find . -perm 444 -exec chmod 644 {} \;
    
    The initial preference files are copied from the package's defaults, which have the wrong modes. It's been fixed in pkgsrc since March 31st so the future binary package should not have this problem.