I currently have the itch to play around with installing a new OS on my laptop. Probably to get away from actually doing work! So I've been thinking about gentoo, haiku, arch, and freebsd. All of them seem fun, I've tried arch before and I know what I'd get. Arch was my main distro for quite some time during university. I am keen on compiling and editing source code this time around. I think it would be good to actively use my system and compile code so that's why I'm leaning towards the more barebones OSes.
Haiku looks to be fun but could be a pain to get it up and running. The documentation however isn't substantial though I could have missed it.
The freebsd handbook looks to be an amazing resource and has confirmed it that I will at least try using it. The handbook is extensive.
My plan now is to read a chapter and make some notes and write out my thoughts about what I think and then to actually go through the process describe in the chapter and then finally come back and detail if there were any issues or if I learned something that was different from what I expected.
I hope that this adventure is an enjoyable one!
Funnily enough the opening introduction highlights how great the TCP stack is on freebsd which I'm confused about. What about it is great and what about linux's TCP stack makes it not that great. I knew webservers and many servers use freebsd but I didn't know it was because of the TCP stack.
The other thing I learned was how the ports systems work. You can compile code by cding into the correct directory and doing make install. This is a crazy way to do package management and I really click with it. It seems like such a good idea. I'm really interested in trying that.
The other thing about freebsd that entices me is that it is proper unix. It'd be cool to see the differences between unix and linux.
Ultimately I always have the trump card of sshing into my server to do dev work or using my pc to browse so I don't feel too stuck using my laptop as a testbed!
Reading the handbook explained what the various iso types were which was nice and it has a specific download option for usbs.
Well shiiit. I looked at the filesizes and had rounded it off to 6-10 gigs. This was after all what I had downloaded for centos when I was setting up my server. It made sense. Then I clicked the full usb image and got ready for a 10 gig download and saw that it was only 1 gig. That blew me away.
Especially since on the previous page it had mentioned that the ports collection is 500mb. That means that freebsd itself is 500mb. That's ridiculously small. I'm in awe that it can be so small.
Reading the handbook reminds me of how I read so much before installing arch.
For this I think I will go with ZFS and encrypted by default.
There is alot of hardening options, I'm curious how different this is from linux. Everything seems to be an option in freebsd. Does linux have this stuff and it gets defaulted or is this specific to bsd.
The uid stuff probably exists but I've never thought about it before. As a general user, I can see so much happening on my work server that maybe I shouldn't.
For at least one option it appears its not part of linux. Randomization of pids seems like a pretty good idea. Very interesting to see this. I'm going to go max security. I'm curious to see how much I butt up against and it'll be neat to see the differences from linux.
I'll report back once I've gone through the installation but I think I have a decent idea of how to go about things.
Let's begin!
Here I didn't follow the handbook and simply used balenaEtcher which I had used previously.
As always, reusing a usb is a pain, the usb ends up being unrecognizable by windows and I needed to use DiskGenius to delete the partitions and then reformat via windows. This seemed to have created the boot usb now.
The first step was to get my Asus X541N to actually boot off usb. Wait, the first step is to actually get it to boot to bios. Which was harder than it should have been. Usuaully the intial screen tells you what F key to press to trigger bios but for some reason my Asus didn't. I tried every F key. Didn't work. I finally googled it and found out that you need to hold F2 before the machine even starts and you keep holding it until it gets to the bios screen.
Now we can change the boot order and get started.
Wait! No we can't, secure boot didn't let me. Now we need to go back into the bios and disable secure boot.
Alright! Now we can boot off the usb.
Booting looks to be good, however now before I can start the installation the system gets stuck in an infinite loop thanks to having an sd card reader. Luckily someone already dealt with this and they had been recommended to edit their /boot/loader.conf file.
They unfortunately weren't very clear with the instructions so I wasn't sure how to edit the file. I figured it was similar to linux so there was probably a way to edit the boot file directly without having to take the usb out. I also don't think that would work as my windows machine didn't see the usb after I had put freebsd on it.
Option 3 on the boot screen is Escape to loader prompt. Here is where I needed to be, unfortunately it wasn't a proper shell environment. It had some commands so doing ls showed that there was indeed a /boot/loader.conf file. However there was not editor.
I tried to echo out to a file but that didn't work. None of the usual editors worked, vi, emacs, nano or ed. I tried using absolute paths as ed did exist in the bin directory. No dice.
I browsed the help and kept trying anything that remotely sounded helpful. I found the show command which seemed to be exactly what I was looking for. It had variables formatted the way the forum poster had specfied his fix in. The help also showed that I could use the set command to set the variable! Perfect.
set hw.sdhci.enable_msi=0
This command worked in that it update the variables shown via the show command but the looping problem still existed.
set hint.sdhci_pci.0.disabled=1
This command however worked! I then ran the boot command and the installation started up!
This was relatively straightforward. I enabled encryption, ZFS, as much hardening as I thought was reasonable. These were all things I never thought about or disabled on purpose to keep my life easier but now would be a good time to try it all. I did set easy passwords so I don't accidently forget and brick the system.
The only downside in the whole process was that it failed to use my wifi. I won't say it was expected but it was a bit of a surprise. Linux had gotten really good with wifi and I thought freebsd might be similar. Oh well, I'm sure there is a hacky solution to it.
Once I finished up the installation wizard, I rebooted the machine and voila! Now after the intial asus loading screen, it asks for a password. This makes sense as my hard drive is now encrypted. That is pretty cool. After typing in the correct password, I got to the usual login screen and I logged in without any more issues.
Well I did run into the problem with the sd card again, but that was easily dealt with. Once inside the OS proper, I editted /boot/device.hints so that it doesn't keep happening
/boot/device.hints
...
hint.p4tcc.0.disabled="1"
hint.sdhci_pci.0.disabled="1"
This stopped the sdcard looping problem once and for all.
Currently I'm sitting at the terminal on my new freebsd laptop!
I did do ps aux to see what the processes look like hidden and that was neat, would probably be a good thing to do on any multiuser system. Maybe. I also tried to see the randomization of pids but it seems like the pids only increase though they jump by more than my centos one so maybe it is random but not entirely.
The boot to password is really quick. Unusually so.
I had orginally done wifi first but couldn't get it working so I circled back to ethernet and got that going.
This was largely plug and play.
I had to only add iconfig_re0="DHCP" to my /etc/rc.conf and reboot.
Ultimately I decided to order another USB dongle to get the wifi working after giving up. I got the TP-Link W725N which I checked the chipset of before buying! This one uses RTL8188EU and I checked the man page for rtwn and it indeed did support it. I ordered the usb and it arrived the next day.
This time as soon as I plugged it in the kernel loaded the rtwn module!
# sysctl net.wlan.devices
net.wlan.devices: rtwn0
This shows the usb stick was picked up and is available now.
# ifconfig wlan0 create wlandev rtwn0
This will create a wireless interface that we can use connected to our wirelessdevice.
# ifconfig
wlan0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether d0:37:45:f4:85:27
inet6 fe80::d237:45ff:fef4:8527%wlan0 prefixlen 64 tentative scopeid 0x3
groups: wlan
ssid "" channel 10 (2457 MHz 11g ht/20)
regdomain FCC country US authmode OPEN privacy OFF txpower 30 bmiss 7
scanvalid 60 protmode CTS ht20 ampdulimit 8k ampdudensity 16 shortgi
-stbc -ldpc -uapsd wme
parent interface: rtwn0
media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
status: no carrier
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
We should now be able to see our wireless interface!
# ifconfig wlan0 up scan
SSID/MESH ID BSSID CHAN RATE S:N INT CAPS
HP-Print-3F-Officejet Pro 8600 9c:b6:54:5b:d3:3f 1 54M -83:-95 100 EPS RSN WME
Assistants 40:c7:29:ec:ba:36 1 54M -83:-95 100 EP RSN BSSLOAD HTCAP WPS WME
Spider Jerusalem 74:ac:b9:b7:fc:d8 1 54M -84:-95 100 EPS BSSLOAD HTCAP WME ATH RSN
Spider Jerusalem 74:ac:b9:b7:f4:16 1 54M -78:-95 100 EPS BSSLOAD HTCAP WME ATH RSN
The WIfe 76:ac:b9:b7:fc:d8 1 54M -84:-95 100 ES BSSLOAD HTCAP WME ATH
The WIfe 76:ac:b9:b7:f4:16 1 54M -78:-95 100 ES BSSLOAD HTCAP WME ATH
Now we can scan the available networks and voila! We have a working wireless interface!
# ifconfig wlan0 channel 1
Our interface shows that it is looking at channel 10 whereas the networks are all on channel 1. We need to update our interface to use channel 1 now.
Now we just need to connect to a network!
/etc/wpa_supplicant.conf
network={
ssid="Spider Jerusalem"
psk="password"
}
This will be the network we want to connect to and the password for it.
# wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf
Successfully initialized wpa_supplicant
ioctl[SIOCS80211, op=20, val=0, arg_len=7]: Invalid argument
ioctl[SIOCS80211, op=20, val=0, arg_len=7]: Invalid argument
wlan0: Trying to associate with 74:ac:b9:b7:f4:16 (SSID='Spider Jerusalem' freq=2412 MHz)
Failed to add supported operating classes IE
wlan0: Associated with 74:ac:b9:b7:f4:16
wlan0: WPA: Key negotiation completed with 74:ac:b9:b7:f4:16 [PTK=CCMP GTK=CCMP]
wlan0: CTRL-EVENT-CONNECTED - Connection to 74:ac:b9:b7:f4:16 completed [id=0 id_str=]
Here we use our wpa_supplicant configuration to connect to the network manually. Once connected, now we need to request an IP address.
While we keep the connection going in one session, let's switch to another one to request an IP address from the dhcp server.
# dhclient wlan0
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 4
DHCPOFFER from 192.168.7.1
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPACK from 192.168.7.1
bound to 192.168.7.66 -- renewal in 43200 seconds.
Voila! We have connected to a network and we are golden!
Let's make this happen on boot up!
/etc/rc.conf
...
zfs_enable="YES"
wlans_rtwn0="wlan0"
ifconfig_wlan0="channel 1 ssid 'Spider Jerusalem' WPA DHCP"
This tells the interface to start on Channel 1, using the SSID specified, using WPA and DHCP.
Now we can reboot and we should see our wireless interface coming up and dhclient being used to get an IP address!
!! After many days of trying to get wifi working, we finally got it working!
=============================================================================
Various things I tried during the installation
Loaded kernel modules
Got a USB Wifi stick
Recompiled kernel
bhyve PCI Passthrough
Another USB stick
Like always wireless was the final problem of the installation!
Unfortunately freebsd wasn't picking up my wifi card and I couldn't figure out how to get it to even find it. The recommendation on a variety of forums seems to be to use a dongle that works with freebsd so I went that route with it disappointingly.
It did surprise me how small dongles have gotten. I got the Edimax EW-7611ULB off amazon. I'll report back once I try it out.
Author is an idiot. One of the comments under the product said that this works with freebsd. But the amazon page bundles a variety of products together where you select one of them. The comments are shared, so really that commenter was probably talking specifically about the EW-7811UN.
Cool side note, one of the comments on reddit references /u/jcs confirming that the Edimax dongle works with openbsd. I knew of jcs from another forum lobsters where he is the founder and now I see that he is also an OpenBSD dev. What a small world!
Alright! The usb wifi dongle came in the next day. Amazon prime delivery is mindblowing but also quite terrifying. The rabid consumerist shit I've done is going to haunt me. We are certainly mortgaging something for consumption.
Anyway...
The handbook has a large section much later about wireless cards but I think I'll need to read it. Maybe if I had the usb plugged in during installation it would have been automatic but now it appears that I'll need to mess around with config files to get it working.
I had hoped that plugging it in would cause it to be read but no dice.
I read the wireless netowrking portion of the hand book and made same notes.
The first step is to update the loader.conf file so the kernel loads the driver.
/boot/loader.conf
if_rtwn_usb_load="YES"
This translates to interface urtwn should be loaded.
/boot/loader.conf
wlan_wep_load="YES"
wlan_ccmp_load="YES"
wlan_tkip_load="YES"
This tells the kernel to also load the modules for the various password options that wifi can use.
Once this is done, reboot. Now we can list our wlan devices and we should see some output.
# sysctl net.wlan.devices
Unfortunately this does did not work.
# pciconfig -lv
This commands lists out all the PCI cards. I saw my wifi card here...
# usbconfig list
Use this command to list the various usb devices.
# kldstat
List out all the kernel modules that are currently loaded.
# kldload
Load a kernel module
# kldunload
Unload a kernel moduleUnfortunately the Edimax 7611ULB doesn't working with freebsd.
I added WITHOUT_BLUETOOTH=yes to /etc/src.conf and recompiled my kernel. After a few hours I stopped having bluetooth support which I had hoped would help. It didn't. I had done this because I knew my wifi stick was a bluetooth wifi combo, I thought maybe freebsd was only seeing it as a bluetooth device. It did show a blue light when I plugged in the usb.
I tried to unload ng_bluetooth from the kernel but it wouldn't let me as it was compiled with it. I found in a mailing list the method to remove bluetooth support and then the handbook showed me how to recompile and install the new kernel. Quite a bit of fun. It took me about 3-4 hours of compiling to get it done but ultimately it worked.
I no longer had bluetooth support and the blue light on the usb dongle was gone. Freebsd still saw the usb but it definitely wasn't treating it as a bluetooth device anymore. However wifi still wasn't showing up which means that whatever chip the wifi was, it wasn't supported.
Afterwards I restored my old kernel with bluetooth support back.
https://www.freebsd.org/doc/handbook/kernelconfig-building.html
https://lists.freebsd.org/pipermail/freebsd-questions/2013-February/249433.html
Now wifi doesn't work through the onboard card nor does it worth through the dongle. So now we will need to get wifi working through pci passthrough. What this means that we will install a guest OS on our FreeBSD installlation that can read the wifi pci card. We will patch the guest and our host, freebsd together so that freebsd can use the wifi through the guest OS.
This is pretty hacky but also beautiful!
Let's get started!
The first thing we'll do is get the host installed.
The handbook has a chapter but it isn't very clear but luckily there were a few forum and blogs posts that we can stitch together. I'm going to try to paint a cohesive picture but I don't fully understand all the steps myself.
We first need to load some modules into kernel so that we can use bhyve.
/boot/loader.conf
vmm_load="YES"
nmdm_load="YES"
if_bridge_load="YES"
if_tap_load="YES"
vmm is the bhyve virtual machine monitor and is the kernel module that allows the bhyve virtual machines to access the host machine's pci cards. This also means that freebsd cannot use the pci cards that are being used by the bhyve virtual machine.
nmdm is a kernel module that allows for devices to get created as they are needed. I think the virtual machine will need to create a /dev entry and it is done via this module for the virtual machine's hard drive.
The next 2 options create networking interfaces. The tap I believe is for the virtual machine and the bridge is what connects the virtual machine's networking interface to the host networking interface.
Now we need to start create our networking interfaces when the machine starts up.
/etc/rc.conf
cloned_interfaces="bridge0 tap0"
ifconfig_bridge0="addm re0 addm tap0"
This will set up our bridge and tap interfaces. This also sets up our bridge as now it can see all traffic that goes through re0 and tap0. The bridge has now connected the virtual machine's network card and our own.
/etc/sysctl.conf
net.link.tap.up_on_open="1"
This will bring out tap interface open everytime we start up our virtual machine.
Now we need to reboot our machine and we can get started on installing our guest OS!
Before we can start we need to install grub-bhyve so that we can set up the boot loader options for our guest OSes.
# pkg install grub2-bhyve
Next we need to create a directory for our vm projects.
# mkdir /root/vm
# mkdir /root/vm/debian
Now we have a folder for any guest OSes we may want to run. In this case we will be installing debian on our machine.
Download the debian net install disk and move it to the debian folder under /root/vm. We'll be using the internet via the ethernet cable but we can also download the debian xfce cd or even the debian dvd.
/root/vm/debian
# truncate -s 16G debian.img
This will set up file called debian.img that is 16gigs big. This is what will be our virtual machine's hard drive.
/root/vm/debian/debian.map
(hd0) ./debian.img
(cd0) ./debian-10.6.0-amd64-netinst.iso
This is our memory map. This says that our hard drive is the debian.img file we created and cd0 is the iso file that we downloaded. Now when we start up our virtual machine, it will use this information during the boot up process.
# ls /root/vm/debian
debian-10.6.0-amd64-netinst.iso
debian.img
debian.map
We should now have our debian install disk, our hard drive and our memory map.
We can now start our installation.
/root/vm/debian/setup.sh
#!/usr/local/bin/bash
grub-bhyve -m ubuntu.map -r cd0 -M 2048M ubuntu
bhyve \
-H \
-P \
-A \
-c 2 \
-m 2048M \
-l com1,stdio \
-s 0:0,hostbridge \
-s 1:0,lpc \
-s 2:0,virtio-net,tap0 \
-s 3,ahci-cd,/root/vm/ubuntu/ubuntu-20.04.1-desktop-amd64.iso \
-s 4,virtio-blk,./ubuntu.img \
-s 7,passthru,2/0/0 \
ubuntu
We specify the path to our install disk and we give it our hard drive.
Now our installation should have begun and we can go ahead and install debian.
Once the installation is done, the guest OS will reboot. This will cause us to get back to the host OS, in this case our freebsd installation.
Let's shutdown the virtual machine.
# bhyvectl --destroy --vm=debian
Now that we have our debian guess working let's set up our pci pass through and get out wifi working.
# pciconf -lv
...
none3@pci0:2:0:0: class=0x028000 card=0x172311ad chip=0xb72310ec rev=0x00 hdr=0x00
vendor = 'Realtek Semiconductor Co., Ltd.'
device = 'RTL8723BE PCIe Wireless Network Adapter'
class = network
...
This shows us our wireless card and the important part is the pci id. We will be using this to specify which card we want bhyve to pass to the guest OS.
# devctl set driver -f pci0:2:0:0 ppt
# pciconf -lv
ppt0@pci0:2:0:0: class=0x028000 card=0x172311ad chip=0xb72310ec rev=0x00 hdr=0x00
bhyve exposes a mount mount for the pci card called ppt and here we run the command to associate our pci card to ppt.
/root/vm/debian/start_debian.sh
#!/usr/local/bin/bash
grub-bhyve -m debian.map \
-r hd0,msdos1 \
-M 2048M \
-S \
debian
bhyve -w \
-A \
-H \
-P \
-S \
-s 0:0,hostbridge \
-s 1:0,lpc \
-s 2:0,virtio-net,tap0 \
-s 3:0,virtio-blk,./debian.img \
-s 7,passthru,2/0/0 \
-l com1,stdio \
-c 2 \
-m 2048M \
debian
Now we've added -S to both of our bhyve commands. This tells bhyve to wire the memory of the host and the guest together. This way the host and guest will share the same memory space. This is what will allow for the pass through using the wifi card.
In the bhyve virtual machine command, we add one more item to out machine via the -s option. We give it the bus id of our PCI card but with slashes instead of colons.
Now we've configured everything on our host system. Let's configure out guest!
/root/vm/debian
./start_debiah.sh
I needed to enable non free sources for debian to install the firmaware-realtek package.
# apt-get install firmware-realtek
# ip a
...
3: wlp0s7: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether 3c:a0:67:53:86:cb brd ff:ff:ff:ff:ff:ff
...
Now the wifi card is getting picked up!
Now we need to install iw and wireless-tools.
# apt-install iw wireless-tools
This will let us manage the wifi a little bit easier.
$ su - root
# shutdown -h now
We need to switch into our root user and run our shutdown command to exit debian. This only shuts down our virtual machine's OS, we still have a virtual machine going. Let's shut that down as well.
This chapter I don't imagine will have too many issues. I already know my way around the linux filesystem so I imagine most of it will just be the usual fare.
I usually do shutdown -h now to shutdown on linux, on freebsd this was triggering a reboot prompt. I found that I needed to use the -p option, shutdown -p now to get it turn off power as well as halting.
Something interesting is the ability to switch to the various consoles directly. On freebsd you can use alt+function key to switch to a different tty. I'm curious what happens if someone else is already on that terminal. With how secure freebsd is I imagine you can't do that but that would be fun!
Logging into a different tty shows the login in the system tty.
User management seems to be straightforward.
pw groupmod wheel -m nivethan
This commands adds me to the wheel group so I can get the su ability.
Permissions are straightforward though I just grokked why rwx is 421. Each one is a bit! It's obvious now and makes the math a bit easier to work out now (pun intended).
FreeBSD also has file flags which I don't really understand but you can make it so even root is disabled from removing or changing files.
chflags sunlink file
chflags nosunlink file
You can see the sunlink when doing ls -lo.
The flag is saying stop unlink maybe.
The handbook also explains the setuid, setgid and stick bits which is helpful though I'm not sure if I'll ever use them. The set bits seems to affect how the process runs and who owns it. Setuid allows you to run a script using the file's owner rather than the user who actually started it.
Setgid is the same way, it allows a process to start based on who the group is on the file rather than who started.
Stick bit is slightly different, this bit allows files to only be deleted by the user that owns them. Once again, this I may never use.
I ran some tests and confirmed that setuid and setgid on bash scripts does indeed not work. !
This seems to follow the way linux does things so nothing new here. The cool thing is how much smaller /etc and /bin are compared to centos. Freebsd doesn't come with too much.
The other thing to note here is /usr/ports is where the packages are.
Very cool directory structure inside /usr/ports. You can see everything you can may to want to install. I checked fish, vim and rust as they are the three things I use and I plan to do dev work with. All 3 look to be well supported and should be straightforward to get going.
One really interesting thing to note in this chapter was that you can use the kill command to send other messages besides SIGKILL. Sending SIGHUP lets a process know to re-read it's configuration. So instead of rebooting a server you can sighup which is pretty neat. However this seems to be dependent on the process but it is a very cool ability.
A copy of the boot messages can be found in /var/run/dmesg.boot. I used dmesg to find out the issue with the sd card and the wifi card not getting picked up.
This should be an interesting chapter and something I can compare the usual way of using apt and yum to install things and see how freebsd handles it.
After reading through the chapter, it looks like ports and packages are very similar to how arch does package management. I'm going to take a stab at installing fish via the pkg utility and install vim from source. I will then install rust using pkg utility.
I chose to do vim from source as I'll need it to have python3interp which I had to manually create in centos already so I have some passing familiarity with compiling vim.
This should be fun!
So first thing, pkg doesn't come installed by default! I had read it but obviously didn't grok it till I got to the point where it said it needed to pull pkg.
# /usr/sbin/pkg
This will setup pkg.
# pkg install fish
> chsh
Use the chsh utility to change the shell to fish.Voila! I now have my favourite shell environment and life just got perceptiably better.
I first installed python37 as I wanted to make sure that I could get youcompleteme set up and working for rust.
# pkg install python37
> cd /ports/vim
> make install clean
I'm an idiot. My laptop is taking forever to compile vim.
Why does vim need openssl...what have I done. At this point I think I might be compiling the kernel. programmable completions of bash zsh??
I'm pretty sure I compiled the all the ninja clans now.
Laptop lost power and died mid compile.
I used pkg to install vim now.
Vim is pretty hefty at 500mb almost. Which was the entire freebsd OS.
Vim installed relatively painlessly.
Now I want to load my vimrc. Git was missing so installed that but now git is throwing a ssl error.
Date was a problem it was thinking I was in last year. Which would have been better honestly but we're 2020 and we need live with that!
# date 2011281553
Once I got the date sorted I quickly brought over my vim configuration and away we go!
Follow the instructions to install youcompleteme but before make sure python is installed.
Relatively straightforward. You make need to run the install script a second time, I had to for reasons unclear to me.
# pkg install rust
This was straighforward and rust got installed pretty quickly.
At this point I have my fish shell and vim set up the way I like and I have rust working!
I installed cargo-watch and it took forever to compile. Hopefully this isn't indicative of future compiliations time...
This chapter cleared up the X windowing system. I never actually cared to look into it. I just new X gives me a GUI and it worked out of the box. Freebsd however doesn't install x automatically so that was nice.
The X Server is the program that draws everything on the screen. The X client is the program asking to be drawn. This expains quite a bit now, really all of the applications we use are clients asking to be draw on our computer. X Server makes me think of some large powerful server running somewhere but really its the PC itself.
The other thing in the handbook was the focus policy and how it is up the window manager to decide what it is. You can have focus shift via click or focus could shift via where the mouse is. This is interesting because windows seems to do both. If you hover over a window not in focus, it has ability to scroll but not take input. If you click, then focus shifts. This is a combination of the two policies.
Unfortunately the handbook lays out the steps for Gnome, KDE and Xfce so I'm going to muddle through installing my own set of graphical interfaces to create my own desktop environment.
For now I think my goal is to get dwm, dmenu, and dillo and urxvt as that is good enough for me to start using the laptop as a daily driver.
I chose dwm and dillo because I want to keep the system as light as possible and I want to edit the files and compile them. Dwm requires compilation to make any configuration changes and dillo I would like to screw around with and see what the web looks like from something so bare.
I'm also planning taking a stab at re-writing these utilities in rust and see where that takes me.
# pkg install xorg
Now run X -configure as root to generate a new configuration.
/root/xorg.conf.new
...
Section "Device"
Identifier "Card0"
Driver "scfb"
BusID "PCI:0:2:0"
EndSection
....
Update the Device section with the driver.
Copy this file to /usr/local/etc/X11/xorg.conf.d/my-xorg.conf
> startx
Voila! We are now using twm and have a gui display.
With that one command we have our GUI environment ready to go! We just need a window manager now.
Unfortunately my trackpad didn't work but the usb mouse worked right off the bat.
I had tried a variety of things similar to the wifi. I had assumed that my mouse was a regular touchpad using psm and so I tried the synaptics and elantech instructions in the handbook and forums.
Finally when I read through dmesg properly I noticed that I never actually saw my mouse in the list. I found that this was because newer laptops now do touchpads through I2C. This finally pointed me in the right direction!
To get the touchpad working, we're going to need to build the drivers manually.
# git clone https://github.com/wulf7/iichid
# cd iichid
# make
# make install
Now that we have built and installed our drivers, we need to load them.
kldload ig4
kldload iicbus
kldload iichid
This will load our drivers in. We will need to also add this to our /boot/loader.conf file so we don't have to manually load them everytime we restart.
/boot/loader.conf
ig4_load="YES"
iicbus_load="YES"
iichid_load="YES"
Now we need to update out X configuration.
/usr/local/etc/X11/xorg.conf.d/my-xorg.conf
Section "InputDevice"
Identifier "Mouse0"
Driver "libinput"
Option "Device" "/dev/input/event1"
Option "AutoServerLayout" "true"
EndSection
You can find the device by checking libinput.
# libinput list-devices
...
Device: System mouse
Kernel: /dev/input/event1
...
The Kernel field is the device we need to match in our X configuration.
With that we are done! Now if we do startx, we will have our mouse working through the touchpad!
Now that we have X working. Haphazardly but alright!
Time to get on with the show. We are going to install dwm from source and dmenu from the freebsd packages.
# git clone https://git.suckless.org/dwm
We need to make two changes to the config.mk which will configure the make command.
./dwm/config.mk
CFLAGS = -I/usr/local/include -I/usr/local/include/freetype2 -std=c99...
LDFLAGS = -L/usr/local/lib ${LIBS}
This will give put some of the referenced librarys in the path while we are compilng dwm.
# make
# make install
With that we have our dwm window manager ready to go!
# pkg install dmenu
# pkg install dillo
# pkg install rxvt-unicode
Here we install our launcher dmenu, our browser dillo and our terminal emulator urxvt.
Finally we can start dwm when we do startx by creating a xinitrc file.
~/.xinitrc
exec dwm
We should see our newly compiled window manager!
Alt P should trigger dmenu and we can test the browser and terminal we just installed.
We are now fully set up!
After doing a second install I got everything I wanted working. I have the utilities I wanted, I have wifi working, and I have the touchpad working! I am pretty happy with the way it turned out and I'm happy that I got annoyed with leaving it half done and finished it up.