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

53 thoughts on “The move from Linux to FreeBSD

    1. 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).

      1. Sorry for posting on a comment from three months ago. Just so you know, though, the aboutthebsds website is a troll site. Trust me, nothing on there if factually correct. For example, he says it takes at least 2 minutes to boot up just the kernel of FreeBSD 10. I’m not sure about your system, but on mine, it only takes 1 for the whole system. Another example is where he states that almost all of the money donated goes to buying beer for the developers, who become so drunk they write awful code. The foundation publishes reports of where the money goes, and beer is not on there. Plus, the code for the FreeBSD operating system is widely regarded as outstanding. I write this because I’ve seen a fairly large amount of people reading this website, and getting a completely wrong picture of the BSD ecosystem.

      2. Going by my experience when I wrote this article, I was impressed with its performance in many aspects, but the needs work more to enable the average desktop user to be able to use it easily. Ask Windows user to use Linux distribution like Ubuntu or Fedora, they’ll be able to make their way out. But FreeBSD, difficult. I had difficulties in adjusting sound jack, there was no GUI for that!

        That said, it was and still is great for servers. Best example is WhatsApp.

  1. 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 :) http://youtu.be/y2MeoQwPrG4

  2. 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?

  3. 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.

    1. 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).

  4. 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.

    1. 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.

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

      2. 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.

      3. Usually the time when my Win XP 64 sux the most is when i open many pages in browser and try to save it all on hdd as .html .mht or single archive .maff or print to pdf. But ignoring security topic, i like this OS for desktop-usage, especially after putting cygwin and gnu-tools paths into PATH, so i can use many tools like ls,grep,tr, | , less just from “cmd” even without “chrooting” into cygwin.
        I did a test. All os installed on virtualbox with 1gb ram and swap 2gb or more. Everytime i used the same amount of about 50 “big” webpages (html with folder, all pages about 400-500 mb on hdd).
        Win XP 32 similar like 64 = total virtual memory used: full ram 1gb+ pagefile size increased to 2xx mb= 12xx mb (so Firefox used 12xx – 180mb of starting value used by OS.

        WinXP 32/64 = 12xx mb VMem (firefox 32 in both cases) (starting ram usage 180-2xx mb)
        Win 7 32 = 14xx mb (firefox 32) (starting ram usage 300-4xx mb) b means B (byte), not b (bit)
        Win 7 64 = 14xx mb (firefox 32) (starting ram usage 300-4xx mb)
        Win 7 64 = 18xx mb (firefox 64) (starting ram usage 300-4xx mb)
        Fedora,Ubuntu,Debian,Slackware, and few other i tested (most of them 64bit os, xfce/gnome) : about 12xx mb minimum of total ram+swap (starting value about 180-220 mb or more)
        So for all these OSes VMem usage increased quite similary by about +1GB of VMem (except Firefox64+ Win 7 64).
        FreeBSD 10 64bit = 650 mb [xfce] (on Xfce starting usage about 5x mb/1GB, on Gnome about 100mb/1GB)
        VMem usage by Firefox 27 in this case increased not by 1GB but about 600mb
        I thought maybe its because on FBSD Firefox was installed from ports with Make compile settings good for this PC. So i installed Funtoo Linux and installed Firefox from source.
        Funtoo Linux = 147x mb (xfce, starting value 13x mb)
        So, i thought, maybe its because of kernel – i tried to install Gentoo FreeBSD. OS installed, Twm works, but i had problems with emerging Firefox, Thunar and running Xfce in general.
        For all Win and Gnu/Linux OSes the VMem usage was full ram taken or 8xx – 9xx mb and 2xx-5xx of Swap. In case of FreeBSD, the final stabilised status of VMem usage was 70mb ram and 580mb Swap. I noticed difference between Ubuntu and Fedora. Ubuntu when loading pages, first used only ram, when it was about max usage its started to increase swap usage starting from 0 mb / 2GB. Fedora started loading swap earlier, when it was about 80% ram usage.
        This is interesting lol, its seems Win+Vbox_FreeBSD+Firefox is better than Win+Firefox only, maybe not in speed but in mem usage. 1gb vs ( 600mb + vbox_OS 50mb Xfce / 100mb Gnome/140 mb Kde)= 1gb vs 650-750mb. Adding Vbox program default usage still should be about 200 mb less.
        Im going to delete Gentoo-FreeBSD VMachine, if Sb can compare memory usage by Firefox (or Opera
        or other browser) between Gentoo/Funtoo Linux and Gentoo FreeBSD or knows a
        link to a site with such test im curious of results.

      4. Interesting stuff.
        When I wrote this post, I had an old E2180 machine on which I tried FreeBSD 9.1. Now I have a Haswell machine, and recently FreeBSD got Haswell gfx support. So I’m planning to try FreeBSD 10 after exams. Should be exciting :D.

      5. you ignored my post, but maybe its good. i checked screenshots from my testing again and this FreeBSD VMem value was not stabilised. i did test again. Firefox pages seemed to be loaded but swap was gradualy growing. Slowly slowly it grew from 6xx mb total, to 1050mb (ram+swap).
        DesktopBSD also +900mb
        PC-BSD = incresed by 900mb-1gb
        To be precise on gnuLinux the result several times also was about 900mb. So firefox on xNIX uses similar amount of vmemory like on Windows XP/7 (in best case its 900mb vs 1gb)

        Maybe swap usage depends also on filesystem. e.g. on Ext3/ext4 fsystems “allocation unit” is usually 1KB (minimal). In Windows XP NTFS it can be set to format disk with allocation unit (block size) 512B/1kb/2kb/4kb. Default is 4KB. When we have lots of small files on one “1KB” partition and same files on other “4KB” partition, in 2nd case space taken from disk will be bigger.

    2. 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).

  5. 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 http://157.85.32.130/freebsd/jails.html.

      1. 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?

      2. 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.

  6. 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.

      1. 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 http://www.over-yonder.net/~fullermd/rants/bsd4linux/01 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.

      2. 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.

      3. 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.

      4. 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.

    1. 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.

      1. 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).

  7. 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?

  8. 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!

  9. 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.

Leave a Reply