The move from Linux to FreeBSD

About 2 months ago, I had a spare VPS at my host, Hetzner. So I decided to play with FreeBSD which was being offered for Hetzner servers and VPSes.
That’s how the whole thing started. I didn’t have much problems getting the concepts because it belongs to *nix family of OSes and I have been a pure Linux user since 2008.

First of all the basic difference between FreeBSD and GNU/Linux is that Linux is just the kernel and GNU is the userland. In layman’s terms, the hardware interface is called Linux, while the rest of the part: the shell, core tools, etc are GNU.It’s a piece from there, another from somewhere else and merging the whole thing into one collectively known as GNU/Linux. Linux itself cannot boot without GNU and GNU will not work without Linux (Yes, there is a GNU kernel project called GNU Hurd, but I don’t how far that went).
In FreeBSD, the whole thing is a complete unit. FreeBSD was derived from the original AT&T Unix and open sourced. You can read more about the differences at over-yonder.

So, while playing with my VPS, I found a major difference between Linux and FreeBSD: performance and memory usage. The performance was nearly same as Linux, but slightly better. Memory usage change, was drastic. FreeBSD is just too good at managing memory. My server earlier used to consume over 1 GB of memory for running PHP, MySQL and Nginx. Now, it doesn’t even touch 500 MB! It’s always less than 500 MB. Everything is just same, configuration, etc. Only OS changed.
After the trial VPS, I started moving my stuff from the Gentoo VPS to the new one. Ran it for testing few days, and it continued to amaze me. FreeBSD’s official slogan is “The Power to Serve”. So much true is that! And that ended up as migrating other VPSes to FreeBSD as well.

Meanwhile, I was facing a lot of insufficient memory issues on my desktop, which is a five year old Pentium Dual Core 2 Ghz (E2180) with 3 GB memory. It used to swap out so much; I did try tweaking vm.swappiness, but it still maxed out on memory. After the great experience on my servers, I decided to move my desktop to FreeBSD. Since my hardware doesn’t involve any crazy things like Nvidia GPU or something, it was an easy task. The problem comes with migrating data, FreeBSD <-> Linux data read/write is not so friendly. This was solved by using my external HDD as a tape drive, I just wrote the whole data as a tar archive to the disk :D and restored it after installing FreeBSD. Got this great tip from ##FreeBSD @ FreeNode.

Downloaded memstick image [who uses CD/DVD these days, anyway?] of FreeBSD and it booted. It has a simple command line installer — If you’re a Ubuntu/Fedora user, please install Arch/Gentoo first to get the taste of how command line installation works. Also it is useful to have another computing device which can help you ask for issues or Google around for stuff if you get stuck. The FreeBSD handbook is quite thorough and easy to follow. In my case the another computing device was my Nexus 4. Used it to chat on the FreeBSD IRC channel to ask for help when I got stuck and also search around. :-)

The base installation was complete within 10 minutes, if you remove the time spent in solving issues and the issues were barely because my drive configuration is bit different than normal desktop users: I have one SSD and 3 HDDs. I use SSD for the OS and put these HDD on software RAID-0 for performance, backing up data regularly to an external disk. It is not so simple to do RAID-0 striping in FreeBSD, particularly if you come from Linux background. You need to have similarly sized disks, otherwise it won’t stripe. In my case, I have 2 x 500 GB and 1 x 160 GB. So effectively I can use only two disks in stripe. But I want large storage, so the solution is using stripe and concatenate together.

 The two commands do this: Create a stripe of two disks, ada1 and ada2 which are each 500 GB and then concatenate the third disk to the raid array. The effect of this is, you get whole 1.16 TB for use, while RAID works for the first 1 TB part of the disk. Once the concat disk has been created, it can be partitioned using gpart.

Partitions done: I placed swap, /var, /usr/ports/usr/src on the initial part of the concatenated disk, i.e. /dev/concat/disk and /home with the remaining part. Reason: Those directories have large disk
accesses. Home also does, but only a small part of it would be outside the raid array. There is no filesystem confusion in FreeBSD unlike Linux: There is just one filesystem you need to use for everything: UFS2. It supports everything a modern computer would need, SSD TRIM support too. Simplicity. And there are not many parameters that can be tweaked. Just enable soft updates while formatting (enabled by default) and soft updates journal to prevent data loss in case of a power failure.

The raid array and concatenation partitions need to be done manually before installing. When the memstick boots, you’ll be greeted with the installer, with an option to exit to shell. Exit to the shell and read the manual pages (and the handbook on your another computing device, as well). Create the partitions and enter installer again by just typing the command bsdinstall.

All that stuff is not at all needed if you have a simple disk configuration.

Once base system has been installed: It’ll just give you a black screen. There is no GUI or anything. You need to install everything yourself using the package manager or ports. The FreeBSD ports system is very, very powerful. You can choose what options are enabled in a particular application and install it without unwanted dependencies. For instance, you don’t want PulseAudio, disable it. Gentoo is quite similar here (because it was developed from the idea of FreeBSD’s ports system), with every package being controlled by USE-Flags. But the difference here is, you need to compile everything on Gentoo, including the core system. In FreeBSD, you get core system updates from the community, tested
properly. All extra applications need to be installed and managed by you. Also, there is a binary package repository from where you can install packages directly, not having to compile them with manually. But in order to do that, you must not convert the package database to the next generation package manager pkgngpkgng installation repositories are not ready yet. I chose the ports way, since I like to keep my system slick and exactly what I want; which was one of my reasons why Gentoo was my favorite Linux distribution.

Configuring GUI on FreeBSD isn’t really a big deal, if you know what and where to look for. Like how to tweak fontconfig to get clean & beautiful fonts, etc.

Currently running FreeBSD 9.1-RELEASE-p3 (it has to be updated after installation of 9.1-RELEASE) with KDE. Firefox-10 tabs, Thunderbird running and KDE. Memory usage is 700M. While I did the same on Linux, memory usage used to go beyond 1 GB and no soon it’d start swapping if I launched more tabs in Firefox. To my surprise, even Chromium doesn’t seem to hog memory on this super-polished OS. Chromium with a couple of tabs, along with Firefox and Thunderbird. Memory usage never went beyond 1.5 GB. In Linux, it’d swap 50-100M there by making it ridiculously slow.

The only things I miss are: Dropbox and Android SDK (adb and fastboot to play with kernels, ROMs and stuff on my phone). Even VirtualBox works and I have got USB support working on it, so it shouldn’t be a big deal to run Arch Linux in a VM and use adb  and fastboot fastboot  from there while exporting the Dropbox folder from Arch VM and connecting it to my system folder, I’ll try that and do that as a separate post when I have time.

FreeBSD gave my computer a new life, otherwise I was nearly going to get a new desktop because of shitty performance. In other words, it saved me ₹35000+ :D

People on the IRC are very helpful to n00bs. One guy even killed his recovery pen drive to try out the earlier mentioned tar backup system, treating a USB disk as a tape drive.

Any amount of thanks won’t be enough to @freebsdhelp on Twitter, who guided me well whenever I got stuck.

Also, if you happen to plan one such installation, do follow this guide: A FreeBSD 9 Desktop How-to

  • Francesco

    Thanks for your post. You know, I understand what you say about Dropbox, but I miss it much less now that I’ve discovered BitTorrent Sync. You should give it a try.

    • Nilesh Govindrajan

      It doesn’t suit my use case: I need files on the go on my phone. Can’t really keep my computer on all the time + power and internet connection is not very stable in my place.

  • michaelmd

    maybe thats why the old shared server running freebsd 4.1 on decade-old hardware could handle 100 times more traffic than my linux vps running on much newer hardware (and that old server had less total ram than the vps and was shared with lots of other users) – and I thought it was just due to virtualisation slowness and bloat in newer versions of php and apache! .. maybe its time I revisited planet freebsd!

  • bleader

    Something that is missing to be sure the memory consumption thing is really relevant, you didn’t talk about flavors of Linux/FreeBSD, if by any chance one was 64bits and the other 32bits, it can make quite some difference because of the pointer size. (maybe not really 2x, but still sufficient to be notified). Do you have both linux and freebsd target architecture at hand?

    • Nilesh Govindrajan

      Both of them are 64 bits

  • Mads Worsøe Duun

    Crazy things like Nvidia GPU??? Nvidia GPU are the best supported GPU’s in FreeBSD.

    • Nilesh Govindrajan

      Lol, that’s what I was told on IRC. Anyway, I have an on board Intel GPU.

    • laffer1

      Only if it’s old or a desktop chip. The Optimus hybrid NVIDIA GPUs in newer laptops do not work. If you’re buying a new laptop, the only thing you can buy is Intel.

      • Nilesh Govindrajan

        Kind of. First time experience. Will probably post one more article after using it enough.

      • Nilesh Govindrajan

        Intel has open source drivers (?) which is why it works pretty good almost everywhere.. The newer Haswell iteration has even better GPUs (anyway, I’m not upgrading for at least 1.5-2 years now).

    • Nilesh Govindrajan

      Lol, that’s what I was told on IRC. Anyway, I have an on board Intel GPU.

  • Jesse Griffin

    If you want to use pkgng, PC-BSD maintains a repo of pkgng packages. See this wiki page for using it: Note that you don’t have to install the PC-BSD utilities, which are really the only difference between FreeBSD and PC-BSD.

    • Nilesh Govindrajan

      Wow, that’s great. Thanks for the information. Any issues I should be aware of while using it?

  • hadrons123

    why does memory usage matters so much to you?

    My system still uses only 10% of my total memory in Gnome-shell with all my desktop apps loaded(firefox, chrome, deluge, nautilus) in Fedora 19.

    FreeBSD still doesn’t support all of my hardware (AR8161ethernet, Intel Corporation Centrino Wireless-N 2200). No optimus support either from nvidia or the community.

    • Nilesh Govindrajan

      It matters to me because my computer has low memory and easily used to get swapping with just basic multitasking.

      • hadrons123

        Ok. fair enough.

        I used Fedora>Arch>Debian>FreeBSD for quite some years.

        I used FreeBSD 9.0 in my old computer for more than 6 months and was experimenting all the flavors of FreeBSD to figure that
        whatever that’s given in is full of lies. Matt carefully ignores the deficiencies of FreeBSD and highlights only the features what FreeBSD can do comparably with Linux. But Linux can do hell a lot what FreeBSD can’t do. FreeBSD is stuck in the past and it can’t even have a decent binary package management yet. They barely started to have KMS now from FreeBSD 9.1. Sorry if it all sounds so negative.

      • laffer1

        If you consider the number of commercial interests and sheer volume of the developers on the Linux kernel vs any BSD project, you should be impressed by how far FreeBSD has come. The only company interested in FreeBSD for the desktop right now is ixsystems. There’s a big difference in support there.

        As for package management, pngng has some promise, but there’s a reason I started working on mport for MidnightBSD years ago. This is a big defect n the BSD world.

      • pkubaj

        It’s not that it’s full of lies, it’s simply outdated. The guy mentions 5.2-RELEASE being the newest version, with 5.3-RELEASE on its way. Both were released in 2004.

      • Nilesh Govindrajan

        I’m sure you didn’t read the post.

      • hadrons123

        KMS arrived in FreeBSD 6 months ago from 9.1, whereas KMS exists in Linux since 2008.

      • hadrons123

        Things have changed a lot in last 10 years in linux and matt’s page exist for quite some time since 2005. It has been carefully edited in course of time , if you keenly observed over years.

  • canadensis

    Have you looked at FreeBSD Jails yet? On one FreeBSD server you can have many Jails which hardly use any hardware resources but give you multiple virtual servers. I use ezjail-admin and configure /etc/natd.conf so that I can access the Jails via port numbers. Fantastic technology. See my (rather messy) notes here

    • Nilesh Govindrajan

      I read upon that, and it is interesting. Wondering how I could use it to create a secure shared hosting environment.

      • canadensis

        Most providers of FreeBSD VPSs or VMs would use jails. I use them to provide FreeBSD VMs for my students so that they can learn some UNIX admin – they have root access in their jails.
        The wonderful PC-BSD provides a great tool for managing jails, have you tried PC-BSD on your desktop?

      • Nilesh Govindrajan

        Didn’t go for PC-BSD because I prefer total customization :-)

        Regarding jails as VMs, I was exactly thinking about it! Also, thanks a lot for that guide, nicely explained.

  • Mitchel

    Do you expect us to believe that 3Gb of ram isn’t enough to run a Linux desktop? That’s just bullshit and you know it.

    FreeBSD is a great OS but don’t lie to us about Linux.

    • Nilesh Govindrajan

      I’m not lying lol. These days browsers have become memory hoggers. But I am still dumbfounded as to why the same browser consumes much lesser memory on FreeBSD and system doesn’t even touch swap, which used to be a frequent thing for me on Linux.

      • Dean Rose

        If you mean web browsers, FreeBSD has Opera which uses less memory than firefox or chrome in my opinion

      • Nilesh Govindrajan

        Opera has been discontinued for *nix since late after they moved to Blink. Also, Chromium = Blink. Opera = Blink. I don’t see a reason to use the latter when it is a duplicate of the former plus may be some additions like a mail client and stuff.

    • Dean Rose

      It depends on what your desktop is, if you had read the article
      you would know, that the person uses KDE desktop. my laptop
      has 3GB of memory (2.85), and I can’t run KDE unless I compile
      from source (gentoo).

  • Nilesh Govindrajan

    Kind of. First time experience. Will probably post one more article after using it enough.

  • name

    this looks like a very superficial review. linux has advanced a great deal in the last years and I haven’t seen any such difference in resources as you say. I use a Pentium 4 with 1GB memory at home and never had any problem with linux. this looks like a big exaggeration.

    • Nilesh Govindrajan

      This was never meant to be a review. It is just my personal experience and I don’t have anything against Linux. I have been using Linux since 2007.

      Also, I’m not exaggerating. If you can, give a try to FreeBSD on your machine. I’m sure you’d be surprised like I was (if you know your way around shell, etc).

    • G-Man

      Typical Linux a-hole that comments without trying herself first.

  • sreadystare

    PC-BSD is BSD for newcomers.

  • Sanatan

    FreeBSD is really really great for server. But in desktop I would say, PCBSD is best. Nothing can give full solution in one answer… FreeBSD’s advanced customization is very useful on server and time spent on it would be rewarded. Wappalyzer in my Firefox detects that you are using Apache, give a try to nginX. It is same miracle doer as FreeBSD-

    • Nilesh Govindrajan

      On the VPS, I was using nginx. Migrated to a dedicated server now running Gentoo (could not choose FreeBSD because virtualization is nascent there ATM).

  • ppzfs

    you have to try a ZFS pool. It is more stable than a ufs storage pool and you can create snapshots on the fly.

  • dan

    Hmmm…nice to see a change of pace but arch wih lxde and firefox hand handbrake doing 1080p i finally break a 1GB. Did you run prelink?

    • Nilesh Govindrajan


  • Jingjok Pairao

    i think FreeBSD can be good desktop for home also :) had installed the system on my PC and laptop computers and all the time it worked just perfect. I met many people who would like to move to FreeBSD but all of them have the same “problem” – ain’t nothing but console just from the “box”, so i like to install different environments on the system :) The most popular is Gnome.

    Here is short “how-to” about how to install Gnome 2 on FreeBSD 9.2 :)

    • Nilesh Govindrajan

      Guess they didn’t hear of PC BSD

  • Anonymous
  • Zbigniew

    I compared the requirements of Slackware 14.1 and FreeBSD 10.0 – and Slackware takes LESS memory and CPU time. Besides: maybe you can be interested in reading – the guy obviously doesn’t like xBSDs, but maybe not with no reason at all?

    • Nilesh Govindrajan

      For some reason I feel the article is a bit exaggerated. While much of it could be true that it’s slower because they moved to clang. I don’t really know nor have the time to test it.

      Also, compiling Xorg on i5-4670 takes less than 10 or 15 minutes (on gentoo, which I use).