Tag Archives: Rant

NetBSD on a Raspberry Pi

Update 2015-12-03:According to a reader comment (below), NetBSD for RPi has matured significantly since I wrote this post. That sounds great to me! But I have not tested yet.

As a long time Linux user I have always had some kind of curiosity about the BSDs, especially NetBSD and its minimalistic approach to system design. For a while I have been thinking that perhaps NetBSD is the perfect operating system for turning a Raspberry Pi into a server.

I have read anti-BSD rants like this “BSD, the truth“, and I have also appreciated pkgsrc for Mac OS X. I felt I needed got get my own opinion. It is easy to have a romantic idea about “Old Real UNIX”, but my limited experience with IRIX and Solaris is not that positive. And BSD is another beast.

For the Raspberry Pi (Version 1, Model B) it is supposed to be possible to run both (stable) NetBSD 6.1.5 and (beta) NetBSD 7.0. It seemed, after all, that the beta 7.0 was the way to go.

At first it was fine

I followed the official instructions and installed NetBSD 7.0. I (first) used the (800MB) rpi.img. I set up my user:

# useradd zo0ok
# mkdir /home
# mkdir /home/zo0ok
# chown zo0ok:users /home/zo0ok
# usermod -G wheel zo0ok

Then it was time to configure pkgsrc and start installing packages.

The Disk Problem
I did a quick check to see how much available space I have, before installing stuff. To my surprise:

# df -h
Filesystem         Size       Used      Avail %Cap Mounted on
/dev/ld0a          650M       623M      -5.4M 100% /
/dev/ld0e           56M        14M        42M  24% /boot
kernfs             1.0K       1.0K         0B 100% /kern
ptyfs              1.0K       1.0K         0B 100% /dev/pts
procfs             8.0K       8.0K         0B 100% /proc
tmpfs              112M       8.0K       112M   0% /var/shm

It seemed like the filesystem had not been (automatically) expanded as it should be according to the instructions above. So i followed the manual instructions to resize my root partition, with no success whatsover.

So I ran disklabel to see if NetBSD recognized my 8GB SD-card…

# /sbin/disklabel ld0
# /dev/rld0c:
type: SCSI
label: fictitious
flags: removable
bytes/sector: 512
sectors/track: 32
tracks/cylinder: 64
sectors/cylinder: 2048
cylinders: 862
total sectors: 1766560
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0           # microseconds
track-to-track seek: 0  # microseconds
drivedata: 0 

8 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
 a:   1381536    385024     4.2BSD      0     0     0  # (Cyl.    188 -    862*)
 b:    262144    122880       swap                     # (Cyl.     60 -    187)
 c:   1766560         0     unused      0     0        # (Cyl.      0 -    862*)
 d:   1766560         0     unused      0     0        # (Cyl.      0 -    862*)
 e:    114688      8192      MSDOS                     # (Cyl.      4 -     59)

Clearly, NetBSD thought this SD-card was 900MB rather than 8GB, and this is why it failed to automatically resize it.

The sysinst install
I was anyway not very comfortable with getting a preinstalled/preconfigured 800MB system with swap and everything, so I formatted the 8GB SD card with my digital camera (just to be sure the partition table did not contain anything weird), downloaded (6MB) rpi_inst.img and wrote it to the SD card.

NetBSD installation started properly, and I was looking forward to install over SSH. According to the instructions I was supposed to start the DHCP somehow. But DHCP seemed on (the RPi got an IP) but SSH was off, so I installed using keyboard.

Quite immediately I was informed that NetBSD failed to recognise the “disk geometry” properly. I tried the SD card in Linux which reluctantly reported that it had 166 heads and 30 sectors per track (it sounds like nonsense). So I gave this information to the NetBSD sysinst program and now the SD card seemed to be 7.5GB.

Then followed a long and confused period of time when I tried to be smart enough to come up with any working partition scheme that NetBSD could accept. The right procedure was:

  1. Choose entire disk
  2. Confirm to delete the (required) 56MB dos partition
  3. Partition, pretending to be unaware of the need of a dos partition
  4. Magically, in the end, it added the dos partition

I am clearly stupid. There are no words for how confused I am about the a:, c: and e: partitions (that seems to reuse the DOS naming, but for other purposes), the empty space, the disk labels, the BSD partitions inside a (non existing) primary partition.

Anyway, just after I gave up and then gave it a final try I convinced sysinst to install. Then came a phase of choosing download paths, which clearly was non-trivial since I installed a Beta, and I am fine with that.

Installation went on. In the end came a nice menu where I could configure stuff. I liked it! (I wish I knew how to start it later). It managed to get my network settings from DHCP (except the GW), but it failed to configure and test the network itself (despite it had downloaded everything over the network just a few minutes ago). I configured a few other things, I restarted, network was working and I was happy… for a while.

I configured pkgsrc, and it seems ALL other systems where pkgsrc exist have been blessed with the pkgin tool, except NetBSD where you are supposed to do all the job yourself. Well, I added the PKG_PATH to the .shrc (of my user, not root) and enjoyed pkg_add.

(not) Compiling NodeJS
I want to install node.js on my NetBSD Raspberry Pi. It is not in pkgsrc (which is it for Mac OS X, but whatever) so I had to build it myself. I am used to building node.js and I was looking forward to fix all the broken dependencies. If I had ever gotten there.

I downloaded the source and started unpacking it… it is about 10000 files and 100MB of data. My SD card (a SanDisk Ultra, class 10) is not super fast, dd-ing the image to it earlier wrote at a speed of 3MB/s. The unpacking speed of node.js; roughly 1 file per second. I realised I need a (fast) USB-drive or a faster SD card, so I (literally) went out to town, bought a fast USB drive (did not find the SD card I wanted) and a few other things. When I came back more than 8000 files had been extracted and less than 2000 remained. I started reading about how to partition and format a USB drive for NetBSD, and at some point I inserted it in the Raspberry Pi. A little later I noticed my ssh sessions were dead, and the RPi had restarted. It turns out what reality was worse than the truth in “BSD, the truth”:

[…] the kernels of the BSDs are also very fault intolerant.

The best example of this is the issue with removing USBs. The problem appears when USBs are removed without unmounting them first. The result is a kernel panic. The astounding aspect of this is that this problem has been exhibited by all the major BSD variants Free, Open, Net and DragonflyBSD ever since USB support was implemented in them 5 to 6 years ago and has never ever been fixed. FreeBSD mailing lists even ban people who dare mention about it. In Linux, such things never and happen and bugs as serious as this gets fixed before a release is made.

Fact is, NetBSD 7.0 Beta for RPi, crashes, immediately, when I insert a USB drive.

This actually did not make me give up. I really restarted the system with the USB drive inserted, with the intention of treating my USB drive as a fixed disk and not inserting/removing it unless I shut the RPi down first. This was when I did give up: deleting the 16GB dos partition and creating a NetBSD filesystem was just too difficult for me. Admittedly, my patience was running out.

More on memory card performance
I found this very interesting article (linked to, by the Gentoo people, of course). Without going into details; clearly a Raspberry Pi with an SD card root filesystem needs a filesystem and block device implementation that works well with actual SD cards. This is not trivial and this means doing things very differently from rotating media.

I did the same unpacking of the node.js source on Raspbian (I installed Raspbian on exactly the same SD card as I used for NetBSD): 22 seconds (tar: 18s, sync 4s), compared to 3h for NetBSD.

In theory, NetBSD would be a beautiful fit for the Raspberry Pi. The ARMv6 is not supported by standard Debian. Raspbian comes with a little “too much” for my taste (it is not a real problem), and it does not have the feeling of “Debian stable”, but more some “inoffical Debian test” (sorry Raspbian people – I really appreciate your job!).

I have wondered why Noobs does not come with NetBSD… but I think I know now. And, sometimes I am surpised that Linux seems to work better than Mac OS X, perhaps now I know why.

My romantic idea that NetBSD would be perfect for the RPI was just plain wrong. Installing NetBSD today made me remember installing Slackware on a Compaq laptop in 1998.

Perhaps I will give Arch a try. Or put OpenWRT on the RPi.

TV på Mina villkor

Ganska många innehållsleverantörer av TV-tjänster marknadsför sig med “TV på Dina Villkor”. Det gillar jag inte. Det är Mina villkor ifall jag har bestämt dem. Ifall leverantören bestämt villkor så är det Deras villkor.

Så här kommer nu mina villkor:

  1. Ingen bindningstid
  2. Ingen uppsägningstid
  3. Ingen krypteringsavgift
  4. Ingen kryptering alls
  5. Inget “baspaket” som krävs för att teckna “tilläggspaket” eller “tilläggskanaler”
  6. Kunna zappa bland alla kanaler utan att betala för dem, börja betala för en kanal när jag tittat 3 minuter
  7. Kunna betala bara för de minuter eller för de program jag tittar på
  8. Box bara om jag själv vill
  9. HTML/Standard-streaming som fungerar utan propritär mjukvara (Flash, Silverlight)
  10. Stöd för AppleTV och ChromeCast
  11. Kunna använda tjänsten på flera enheter samtidigt (och självklart betala för det jag tittar på – varken mer eller mindre)
  12. Bred tillgång till utländska nationella kanaler (ex BBC1, BB2 osv), inte bara internationella varianter (ex BBC World)
  13. Kunna spara/prenumerera program för att se off-line (som PodCasts)
  14. Inte betala för kanaler som redan är reklamfinansierade
  15. Hela Play-utbudet tillgängligt som PayPerView
  16. Kunna använda tjänsten när jag är utomlands

Inget av detta är konstigare än att jag kan gå in på en restaurang, beställa bara det jag vill ha, äta, betala, gå och aldrig komma tillbaka.

Eller att jag kan gå till en livsmedelsbutik och köpa ett paket sockerbitar utan att samtidigt behöva köpa bryggkaffe, kokkaffe, koffeinfritt kaffe, snabbakaffe, kaffebönor och kaffepraliner eller nudlar eller dagstidningar eller kiosklitteratur. Inte heller behöver jag förbinda mig att köpa mer socker de närmaste 24 månaderna.

Visual Studio alternative folder – a joke?

I was thinking about installing Visual Studio 2013 Express… if nothing else to compile my program from my last post.

Well, 5.3Gb was not so bad, but I do not really want Visual Studio on my C drive, since:

  • C is an expensive SSD drive, that I want to avoid filling up
  • I am not going to use Visual Studio a lot, and it is fine for me if it is a little slower – can live on my Q-drive (an old IDE drive)
  • I am just going to use the command line tools that come with Visual Studio anyway, so I really don’t need to waste my SSD C-drive with 5.3 GB of dev tools

Perhaps my arguments are just stupid, but they make sense to me.

This is the funny dialog I got when installing…


I mean, seriously??? I can change installation directory, which will move 1GB to the other drive, and keep over 4GB on C. Why did you even bother with an alternative install path, Micro$oft? Why does Windows support more than one hard drive at all?

Obviously there are other people being annoyed with this too. And there are ideas about using symlinks in Windows to solve the problem… but the problem is that a lot of those 4GB may go just everywhere on the C-drive anyway.

The people who design Windows are obviously retarded and Windows is a mess. I am not going to make my Windows gaming computer dirty by installing stupid Visual Studio on it. I remain happy to use Windows as little as possible.

This was annoying with my Nokia N8 that put plenty of stuff on the little C-partition that could not be moved to the big D-partion. But Windows 7 not being better than Symbian – come on?

How it is done right
For those of you who only ever used Windows, I will quickly explain how this is done right. You give the user the option of installing anywhere, in particular

  • Standard system path – so everyone can use it (c:\Program files)
  • Non standard path – so everyone can use it, but it does not get in the way for those who dont care (q:\extra\devtools)
  • The users home directory!

The last option obviously requires no admin rights whatsoever. This is very good, because you know for sure nothing is installed elsewhere.

For development tools, this has several advantages:

  • If installing the dev tools does not modify the system in any way, you can be sure that the programs you build behave the same way for your end user as they do for you – and with behave, I typically mean “work”
  • You can install several dev tools/versions side by side, and be sure they do not disturb each other or rely on each other
  • You can be sure that your system works just as it used to, even after you installed dev tools

Finally, I want to remind that even though dev tools (compilers, linkers, libraries, IDEs) are very advanced stuff… in the end of the day they only produce regular files; sequences of bytes. No privileged access is needed to produce a binary file! There is no magic about it.

It is not only unnecessary that Visual Studio installs itself in C – it is a suspicious behavior. Only bad things and bad practices can come from it.

Finally, clever software providers get this right! And Valve have ambitious Linux plans… just because they are clever.

Book Review: The Satanic Verses

With the release of Joseph Anton there was some attention around Salman Rushdie – the author who was sentenced to death by Iran for writing The Satanic Verses. Well, I decided it was time to get my own opinion and ordered a paperback The Satanic Verses (hard to find in stores).

I really had no idea what I was about to read – except that fundamental muslims were upset about the work.

It is a thick book. First pages are very… poetic, tricky to read. Then it is a more normal book. The Satanic Verses is funny and entertaining, very well written, and very enjoyable without much knowledge about Islam (perhaps more so, since some muslimes are obviously not entertained). It is full of references and symbols (religious, historical, cultural) and it does not hurt to google and read on wikipedia.

And, with limited knowledge about islam, I do not really understand what the problem is. Mr Rushdie said he expected some people to be a little provoked by it, but he was completely surprised with the death sentence – so am I.

If you like reading, but think The Satanic Verses is not for you, give it a try!

Problem with Pagefile on second drive in Windows 7

My Windows 7 computer has 4GB of RAM and a 128GB SSD drive. I dont want to page on my SSD drive (because I believe it will shorten the life of it, and I dont believe in paging anyway), so I disabled paging. However, occationally Windows claimed it ran out of memory and killed my applications. I am very suspicious it really ran out of memory (4GB should have been plenty for what I did), but nevertheless it killed my applications.

I decided to install a second drive, an old rotating hard drive, that I assigned the drive letter b: and named backup. That is where I want my pagefile.sys (and some backups).

When configuring Windows the way I wanted, I got the error:
Windows created a temporary paging file on your computer because of a problem that occured with your paging file configuration when you started your computer. The total paging file size for all drives may be somewhat larger than the size you specified
What this really meant was that I got a pagefile on c: anyway. And the error message popped up every time i started my computer.

Like many other people who have written about similar problems, I tried all combinations of disabling and enabling pagefile for the different drives, but very very hard to get it the way I wanted.

Finally it worked – and as usual with Windows it is impossible to know what really made the difference. And I dont want to break the configuration just to fix it again to learn!

Anyway, these are things I did that MIGHT have had anything to do with it (perhaps it had to do with the stars or something):

  1. I renamed b: to q: (in case Windows 7 does not believe in paging on its second floppy drive) (Most Likely This One!)
  2. I first obtained a working configuration with pagefile on both c: and q:, both of them using an interval, none of them System managed
  3. I reduced c: in steps, first to 16-256, next to 16-16
  4. I finally effectively disabled pagefile on c: by setting “initial size”, to 0 (not by using No Pagefile)

I recommend that you change your folder view setting so you can see systems/hidden/protected files along the way.

Sometimes people say Windows is good. Sometimes I say, “well, yes, Windows 7 is ok, they got it right now”. But the truth is that Windows f***ing sucks. This reconfigure/reboot/pray-way of solving problems is so braindead. And it is impossible to learn or understand.

Remote Desktop & Windows 7 Home Premium

Windows 7 Home Premium seems to be the right version of Windows for home usage, right? I mean for media, gaming, communication and casual work. And it is the version MS ships with a PC you can buy in a store. Well, Microsoft believes that Remote Desktop (the server part) is not a Home Premium feature, but a Professional feature. I think there are plenty of home-related uses for Remote Desktop (supporting a relative remotely, sitting in the sofa with your tablet while controlling your PC, access your computer from work or when traveling).

The upgrade to Professional is 180 Euros, and requires some work. This is simply Microsoft making their products suck for their paying customers! I’d say people who buy a PC in a store really don’t have the choice to pick Professional or Ultimate. The wares people are probably smart enough to not bother with anything less than Ultimate.

Luckily, there is a simple hack for Home Premium, and this one works today (well, yesterday), despite SP1 and everything.