Msata Is Not Msata

I upgraded my system disk from a SSD to a PCI SSD. Mostly because the Dell T20 has only 4 SATA ports. So I bought a 'DeLock PCI-Express-x4 Kontroller' and a 'Samsung 850 EVO M.2'. Which was not the smartest choice because there are two types of M.2 SSDs some have a PCI interface and others have a SATA interface and you need the ones with PCI. That is why I bought a few days later a 'Samsung SSD SM951 128GB Workstation' which worked as expected, well almost. The card should work with out drivers and it should be possible to boot from it. And here comes the fun part of course I couldn't boot from it, so I had the smart idea it should be easy to bootstrap my FreeBSD from a USB drive and then boot from the PCI SSD card. And here is how you can do it:

First of all you should know the name of your devices (you can use something like camcontrol devlist) in my case:

USB drive: da1 
PCI SSD: ada0

Now we can delete all data and partitions on these two devices. This assumes of course that you don't have any data you need on it. And I would recommend to disconnect and backup all disk you also have connected to your Server. It's just to easy to wipe the wrong disk or copy things in the wrong partition. If you losing any data it's not my fault! That said here is how to clean out the old partition and create the new ones.

# clean out old partitions
gpart destroy -F da1
gpart destroy -F ada0

# create partitions
gpart create -s gpt da1
gpart create -s gpt ada0

gpart add -a 4k -s 512K -t freebsd-boot da1
gpart add -a 4k -t freebsd-zfs da1

gpart add -a 4k -s 4G -t freebsd-swap ada0
gpart add -a 4k -t freebsd-zfs ada0

With that out of the way we can copy the boot code to the USB drive.

gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da1

The next step is to create the the zfs pools and datasets for a FreeBSD install.

# create pools
zpool create -o altroot=/mnt -o cachefile=/tmp/zpool.cache usbboot /dev/da1p2
zpool create -o altroot=/mnt -o cachefile=/tmp/zpool.cache ssdboot /dev/ada0p2

zfs set mountpoint=none usbboot
zfs set mountpoint=none ssdboot

zfs set checksum=fletcher4 usbboot
zfs set checksum=fletcher4 ssdboot


# create datasets
zfs create -o mountpoint=none ssdboot/ROOT
zfs create -o mountpoint=/ ssdboot/ROOT/default
zfs create -o mountpoint=/home ssdboot/home
zfs create -o mountpoint=/usr ssdboot/usr
zfs create -o mountpoint=/var ssdboot/var
zfs create -o mountpoint=/tmp ssdboot/tmp

chmod 1777 /mnt/tmp

zfs create -o mountpoint=/uboot -o compression=off usbboot/boot
zpool set bootfs=usbboot/boot usbboot


zpool import -f -R /mnt usbboot 
or 
zfs mount


zpool set bootfs=none ssdboot

After all this we can finally copy the FreeBSD files to the file system.

cd /usr/freebsd-dist
for i in base kernel src ports games lib32; do
xz -d -c $i.txz | tar -C /mnt -xf -
done

chroot /mnt
touch /etc/rc.conf
touch /etc/fstab
touch /boot/loader.conf

Before we can reboot we need to configure a few settings in various files. This should load your FreeBSD from the SSD and mount your swap.

# /etc/rc.conf
zfs_enable="YES"

# /boot/loader.conf
zfs_load="YES"
vfs.root.mountfrom="zfs:ssdboot/ROOT/default"

# /etc/fstab
/dev/ada0p1    none    swap    sw    0    0

As a last step we need to copy /boot on the USB drive.

mkdir /mnt/uboot/boot
cp -r /boot/* /mnt/uboot/boot/
cp /tmp/zpool.cache /mnt/uboot/boot/zfs/

Now is the time to reboot an pray, if everything worked it should boot FreeBSD. If everything works we can symlink the boot directory.

rm -rf /boot/
ln -s /uboot/boot /boot

This works except one thing somehow it forgets after a reboot which pools are mounted. So after every reboot I mount my pools manually.

sudo zpool import usbboot
sudo zpool import tank
sudo ezjail-admin start

This is not as bad as it sounds since I only reboot for kernel updates but if you know why this happens or how to fix it, there is a FreeBSD forums thread for it. You can also contact me directly over mail, twitter whatever.

Chromecast Revisited

I'm a huge fan of the Chromecast, the small streaming dongle from google. And I already wrote about the first version here: Chromecast. There where always rumours that a Chromecast 2 is around the corner. And now it happened. They have finally presented one with features I'm waiting since I bought the first one. Mostly 5ghz WLAN, I don't understand why the first Chromecast was lacking this.

Chromecast

I use my Chromecast mostly for three apps: BeyondPod (which is the best podcast client on android), Plex (self hosted netflix) and YouTube (a platform for videos, you know that, right?). And these are the three apps I tested with the new Chromecast. Nothing really surprising but all these apps are much smother to use, which is cool. Also nice was the on-boarding experience.

New is the Chromcast Audio, which is at least for me not that exciting. But this is probably because I already have a Sonos sound system and I build something quite similar called Radio Pi. But interesting is the price point it's much cheaper than Sonos and even cheaper than a self build solution with a Raspberry Pi.

So if you have already a Chromecast there is no real reason to upgrade, but it's a nice to have. If you haven't one it's a good time to buy one.

Balccon2k15 Trip Report

If you follow me on twitter you probably saw that I was at BalCCon2k15. It was fun. I really enjoy this smaller events, the larger events like the CCCongress are very cool, but sometimes just a bit too much to handle for me. So what is BalCCon2k15? It stands for Balkan Computer Congress and is organized by LUGoNS the Linux Users Group of Novi Sad. This year was the 3th edition and everything was well planed and organized. Meaning the WLAN worked fine, even if it was a bit slower than normally on such events. But hey you don't need much WLAN to socialize.

On the first day I helped to deploy WLAN AP. As you can see we did this like professionals! Also there was a loop for bits.

bit loop and wlan ap

The location was a museum of some sort and it was perfect. Enough space, but not to much that you think it's empty. And they had a painted tank. I mean how cool is that.

painted tank

I can't say much about the talks. Because I only attended three or four. If you planning on building your own backbone you should watch "lecture: how you could build a backbone". And then there was that one talk which was very impressive, it was about "Touchless Control in Our World". It was held by Onuralp SEZER. He showed a 3D printed arm which can be controlled by Myo. I don't think there will be a recording for that, so here is just an image of it. (And if Onuralp SEZER writes about it I will include here a link to the project)

3D printed arm

Oh and the food was absolutely amazing.

food

Some images are made by @4x01071, thanks!

I Killed My Digital Ocean Droplet

I'm not at vBSDcon but I'm at BalCCon2k15 which is a small conference in serbia (and very cool). So while I was scrolling through my RSS feeds I saw that FreeBSD 10.2 is released. As usual I rush things which means I didn't made a backup of my droplet. Kids always do a backup beforehand, if you do things like a kernel update. Not exactly sure why but I heard it helps a lot if you fuck up. And yeah I fuck up a lot. Anyway what happened was I ran

freebsd-update fetch install
freebsd-update -r 10.2
freebsd-update install
reboot

And after the reboot nothing. Cool, at least DigitalOcean has a HTML5 VNC. Of course this doesn't work with Firefox. And it's very buggy. But it's enough to figure out whats happening. And I needed to configure my local keyboard to U.S English to type characters like / (still no idea why). At this point I was able to access my droplet over VNC where I didn't had Internet. I found out that a Interface without a IP address does basically nothing. Long story short you need to configure the Interface yourself. Still not exactly sure why I didn't need to do it after the first setup. Anyway adding the interface configuration to my rc.config restart my networking and routing and how would suspected that my droplet is back online.

What I'm trying to tell you dear reader, do proper backups beforehand.

Phoenix Up And Running

I heard all the cool kids program with this thing called elixir and phoenix. And as we all know I'm trying hard to be a cool kid (not really successful). But this is a topic for an other blog post. So here is a small guide how you get started with phoenix on Fedora.

Install packages

The first step is installing elixir and postgresql which is the default database back end for phoenix. And then there are other packages needed like npm to use all these weird js front end tool which are to some extend integrate in phoenix.

sudo dnf install erlang elixir postgresql-server npm inotify-tools

Prepare psql and enable it

Now we can setup our postgresql server.

sudo postgresql-setup initdb

After the basic setup, we need to edit the pg_hba.conf file which you should find now in /var/lib/pgsql/data/.

So we need to change ident to md5 on the line where the ADDRESS is 127.0.0.1/32 in /var/lib/pgsql/data/pg_hba.conf.

# TYPE    DATABASE        USER            ADDRESS                 METHOD
  host    all             all             127.0.0.1/32            md5

After we change the config file we can enable the service at start up and start it.

sudo systemctl enable postgresql
sudo service postgresql start

Set a password for the postgres user. Please remember the password you set, you need it later.

sudo su - postgres
$ psql
postgres=# \password postgres
postgres=# \q

Phoenix

With all this things in place we can install the elixir package manager and phoenix.

Hint: You should check if there is a newer version than 1.0.1!

mix local.hex
mix archive.install https://github.com/phoenixframework/phoenix/releases/download/v1.0.1/phoenix_new-1.0.1.ez

Create a new project is easy.

mix phoenix.new $APPNAME
cd $APPNAME

Now you need your psql user and the password you set and configure it in config/dev.exs.

Installing all the dependencies and create the database.

mix deps.get
mix ecto.create

Start the server

mix phoenix.server

Happy coding!