Latest Posts

Latest Tweets

    Viktor on Open Source, Scaling, Unix/Linux and Entrepreneurship.

    This really bugs me…

    December 14, 2011 4:39 am    Posted by Viktor Petersson    Comments (0)

    If you’ve ever tried to install ImageMagick on FreeBSD, you’ve probably run into this issue too. You have a head-less box in some datacenter, you don’t want to bloat the machine with X11.

    You try to install the no-X11-version of Image Magick:

    cd /usr/ports/graphics/ImageMagick-nox11 && make install

    The next thing you know, you the dependency ‘print/ghostscript9-nox11′ gets installed. Notice that this is the ‘no-x11′ version. Yet, look at the fifth option from the top:
    FreeBSD Ports-failure

    Isn’t it pretty obvious that I don’t want X11 if I install the ‘nox11′ port? Why is that even an option?

    How to use Virtio on FreeBSD 8.2+

    October 20, 2011 9:08 am    Posted by Viktor Petersson    Comments (4)

    In the past few years, virtualization has been the big topic everybody keeps talking about. There are good reasons for that, but one thing that really annoys me as a hardcore FreeBSD-fan is how poorly FreeBSD performs virtualized.

    For some time, the Linux-community have been using the Virtio-drivers to boost both I/O and network performance. Simply put, Virtio is a driver written to cut out any unnecessary emulation on the host and as a result both reduce load from the host and improve performance.

    Unfortunately the FreeBSD-community haven’t been able to utilize this, as there were no port for this. Luckily that just changed and here’s how you enable it.

    Just as a disclosure, I’ve only tried the I/O driver on CloudSigma, and it seems to be stable both on 8.2 and 9.0-RC1. According to other this post, the network driver should work too though. It should however be said that the I/O performance on 8.2 is significantly slower than on 9.0-RC1.
    more>>

    Last weekend I was staying at a Holiday Inn in the UK. As most geeks, one of the first thing I did after checking in was to hop on the wireless connection to pull down my email. Like many hotels, Holiday Inn outsource the management of their wireless guest network. This particular hotel was using a provider named Swisscom (I’m not sure if this true for all Holiday Inn hotels).
    more>>

    Is it possible that Facebook know more about how many visitors a given website has than Alexa or Hitwise? I’m not talking about people sharing a link on Facebook and then tracking outbound clicks. I’m talking about capturing all visitors. Both Alexa and Hitwise used to both rely on browser-addons to capture this data. Since only a small percentage of users will install this add-on, they will have really rough data (and skewed towards non-technical users).

    So how can Facebook then acquire more accurate data than these traditional companies? It’s pretty simple. You know that Like-button that is showing up all over the web these days? Turns out that Facebook is hosting all those images (and you cannot host this yourself as that is a Term of Service breach).

    Since Facebook is hosting all those images, they know exactly (or at least could know) how many visitors you have on your website for each page you got a Like-button. No estimates, but exact up-to-date metrics. If you’re logged into Facebook and visit a site with a Like-icon, they can also track that you have visited.

    The bottom line is that Facebook knows a lot more than you might think about the web as a whole.

    One of my favorite Open Source appliances is pfSense. It can turn any old machine into a very powerful firewall/router in 10 minutes or less. Also, it comes with a very handy GUI and the fact that it is based on FreeBSD makes it even greater.

    While version 2.0 isn’t stable yet, the 2.0RC is more or less considered stable. It’s also a major update to the 1.2-branch. I’ve used 2.0 on two ‘production’ firewalls now, and I think it more reliable than 1.2.
    more>>

    Today as I was installing PostgreSQL 9.04 on a new server I encountered the following error:

    [root@host ~]# /usr/local/etc/rc.d/postgresql initdb
    su: unknown login: %%PG_USER%%

    Something obviously went wrong when the port was being installed. Most likely it’s a bug in the build-instructions for the port. No stress though, as there is an easy fix. Just open up /usr/local/etc/rc.d/postgresql and modify the line

    postgresql_user=${postgresql_user:-"%%PG_USER%%"}

    with

    postgresql_user=${postgresql_user:-"pgsql"}

    (or I suppose you could add “postgresql_user=pgsql” to rc.conf).

    You should now be able to initiate PostgreSQL.

    The most exciting new feature in OS X Lion for all paranoid techies out there was the introduction of full-disk encryption (FileVault 2). The previous version of FileVault only enabled you to encrypt your home directory. That was a good start, but it forced you to log out once in a while to recover disk space. This was extra painful if you were using a small SSD-drive.

    Another issue with FileVault 1 was that it prevented you to effectively use Time Machine. In order to backup your home directory, you had to log out. First then would Time Machine back up your files. This was inconvenient to say the least.

    On the topic of Time Machine, OS X Lion also introduced a new feature when it comes to Time Machine. You can now encrypt your backups. That’s great, as if you were to use FileVault 2 and Time Machine without encryption, your backups would be entirely unencrypted.

    As I was setting up my encrypted Time Machine-drive, I took a closer look how this was done. As it turns out, Time Machine is using a new partition type in OS X Lion to accomplish this. What’s even better is that you can do this on any drive.

    All you need to do is to re-format the partition in Disk Utility, and select ‘Encrypted.’

    Now you can easily encrypt all your external drives, while making it entirely seamless for day-to-day operations. If you chose to store the passphrase in your keychain, you won’t even notice that the disk is encrypted (other than perhaps less I/O throughput and more CPU usage).

    If you ran one of the beta releases of Mac OS X Lion, you probably ran into a problem when trying to upgrade to the final release of OS X Lion.

    When I tried to upgrade one of my dev-machines, I was prompted with an error saying “A newer version of this app is already installed on this computer”

    Of course, you know that isn’t the case, as OS X Lion, just came out.

    After some digging, I found the solution. It turns out that all you need to do is to hold the option key (⌥) while pressing install. That will force the Lion to install.

    Rebuilding a Linux software RAID array

    June 18, 2011 9:49 am    Posted by Viktor Petersson    Comments (0)

    The process is pretty straight forward, and I’m writing this as a ‘Note-to-self’ for future references than anything else. If anyone else find it useful, that’s great.

    Identify the broken drive

    Start by identifying the device as the system know it (ie. /dev/sdX or /dev/hdX). The following commands should provide you with the information:

    cat /proc/mdstat
    mdadm --detail /dev/mdX
    cat /var/log/messages | grep -e "/dev/hd" -e "/dev/sd"

    Once you’ve identified the drive, you want to know something more about this drive, as /dev/sdX doesn’t really tell us how the drive looks like. In my case, I have three identical drives, so the following command didn’t help me much, but maybe it does for you.

    hdparm -i /dev/sdX

    That should give you both the model, brand and in some cases even the serial number. Hence this should be plenty to identify the drive physically.

    Replace the drive

    Not much to be said here. I assume you already know this, but you need a drive of equal size or larger.

    Partition the new drive

    If your system boot up in degraded mode, then just boot up your system. If not, boot it off of a Live CD (I used Ubuntu’s LiveCD in ‘Rescue mode’).

    Once you’ve made it to a console, the first thing we need to do is to partition the new hard drive. The easiest way to do this is to use sfdisk and use one of the existing disks as the template.

    sfdisk -d /dev/sdY | sfdisk /dev/sdX

    (where sdY is a working drive in the array, and sdX is your new drive)

    Rebuilding the array

    The final step is to add the new drive to the array. Doing this is surprisingly easy. Just type the following command:

    mdadm /dev/mdZ -a /dev/sdX1

    (assuming you want to add the partition sdX1 to the RAID array mdZ)

    Of that went fine, the system will now automatically rebuild the array. You can monitor the status by running the following command:

    cat /proc/mdstat

    Do you have a few long commands that you keep typing in the terminal? Things like ‘cd /some/long/path/that/takes/forever/to/type’ or ‘mycommand -with -lots -of -variables’?

    If so, here’s something you’ll enjoy.

    Just open up ~/.profile in your favorite editor, and add the following lines:

    alias foo="cd /some/long/path/that/takes/forever/to/type"
    alias bar="mycommand -with -lots -of -variables"

    Now you don’t need to type those long commands ever again. All you need to do is to typ ‘foo’ or ‘bar’. You can of course replace foo and bar with anything you want, as well as the command.