Tag Archives: audio

Tiny Undervalued Hardware Companions

After playing/working with computers for more then 25 years I started to appreciate small but handy valuable stuff – like adapters or handlers or … yeah – all kind of stuff. With many of them I did not even knew they existed until I find out about them – mostly accidentally or after long searching for some problem solution. Today I will share them with You – so maybe they will end up handy also for You.

… and while they make my life easier – they are mostly very cheap too.

The Table of Contents is below.

  • RJ45 Angle Adapters
  • RJ45 Angle Cable Adapters
  • RJ45 Join Adapters
  • SATA to USB-C or USB-A Adapters
  • Angle USB-C and USB-A Adapters
  • USB-A <=> USB-C Adapters
  • Tiny USB WiFi or Bluetooth Dongle
  • USB-C <=> Micro USB Adapter
  • USB-C <=> Laptops/Routers/5.5mmx2.5mm Adapters
  • Creative BT-W2 USB-A Bluetooth Adapter
  • External Microphone for SONY Headphones
  • Headphones Handle
  • Dual USB-C and USB-A Pendrive (SanDisk)
  • Tiny USB-A Hub
  • Quad USB-C / USB-A / Lightning / Micro USB Adapter with MicroSD Card Slot
  • Angle Power Adapters
  • C13/C14 Power Adapters with Additional C1/C2 or C5/C6 Sockets
  • HDMI 3in1 Switch with Remote Control
  • Cable Organizers
  • Mouse Jigger
  • FM Transmitter
  • Summary

The whole article can ‘feel’ like a sponsored entry for the https://aliexpress.com portal – but it is not – its just the most cheap place I was able to find these gems. Feel free to share even cheaper one if You have one.

~

RJ45 Angle Adapters

I mostly use laptops to do various tasks and cables sticking out on the sides perpendicularly does not help. Not many laptops today have the RJ45 LAN socket – but if they do – they are mostly on the side of the laptop.

Thanks to such angle RJ45 adapters it is no longer a problem.

You can find them for about $2 – for example – on https://aliexpress.com page – with the RJ45 ANGLE ADAPTER keywords in their search.

~

RJ45 Angle Cable Adapters

The mentioned earlier RJ45 Angle Adapters are quite bulky – but as an alternative its possible to get a short 40cm cable with smaller plug.

Not sure if its noticeable on the picture below – but I also cut the top ‘cover’ with knife of the plug – so its easier to detach.

There are of course all four angles to choose from.

One may also use the end of that 40cm cable-adapter as a ‘stopper’ to not fall inside the desk hole as shown on the image below.

You can find them for about $2 – for example – on https://aliexpress.com – with the RJ45 ANGLE ADAPTER CABLE keywords in their search.

~

RJ45 Join Adapters

Often I found myself in a situation that the currently available LAN cable was too short to reach and it needed a lot of work to plot another – longer one.

With these simple ‘join’ adapters it is no longer a problem. You would not use them in a serious Data Center with 10+ GE speeds – but for home 1.0-2.5 GE speeds its more then enough.

You can find them for about $1-$2 – for example – on https://aliexpress.com – with the RJ45 JOIN ADAPTER keywords in their search.

~

SATA to USB-C or USB-A Adapters

Multiple times I needed to clone some old disk to new SSD – just to make an old system faster.

I usually boot from some USB drive with FreeBSD and while new SSD is attached with these adapters – I then execute dd(8) command to clone the old HDD disk to new SSD drive … and then just swap them out.

You can find them for about $1-$5 – for example – on https://aliexpress.com – with the SATA USB ADAPTER keywords in their search.

~

Angle USB-C and USB-A Adapters

As we already talked about RJ45 angle adapters … there are also USB-C and USB-A angle adapters.

The do the same good job with cables to not stick out on a side of a laptop.

You can find them for about $1-$3 – for example – on https://aliexpress.com – with the ANGLE USB ADAPTER keywords in their search.

~

USB-A <=> USB-C Adapters

In the progressing and always changing world yesterday the USB-A was king and tomorrow the USB-C will be.

There are multiple cases in which you will need these – from simple USB headphones to USB pendrives and other stuff.

You can find them for about $1-$3 – for example – on https://aliexpress.com – with the USB-C USB-A ADAPTER keywords in their search.

~

Tiny USB WiFi or Bluetooth Dongle

Multiple times I have found myself in a situation where it was very convenient to just add some WiFi or Bluetooth chip over USB port and do the job instead of trying to achieve the same without such chips.

While I usually omit Bluetooth I can not say the same about WiFi … and as FreeBSD lacks a little in that department – using a very tiny chip such as Realtek RTL8188CUS often does the job done.

You can find them for about $1-$3 – for example – on https://aliexpress.com – with the WIFI USB or BLUETOOTH USB keywords in their search.

~

USB-C <=> Micro USB Adapter

In the past – in the USB Micro times – I remember using an adapter to be able to charge – then new and uncommon – USB-C devices.

Fast forward several years and now the situation is the other way around (as expected). The USB-C is the standard and USB Micro devices are less and less common … but there are still here. To not have to keep separate dedicated USB Micro cables I use a small USB-C to USB Micro adapters.

Such adapter takes USB-C as input power and is able to charge USB Micro devices.

You can find them for about $1-$2 – for example – on https://aliexpress.com – with the USB-C USB MICRO ADAPTER keywords in their search.

~

USB-C <=> Laptops/Routers/5.5mmx2.5mm Adapters

When it comes to delivering power to my (and not only) laptops – the new standard seems to be the USB-C connector with ‘requirement’ of 45W or more (it depends).

Not that long ago I discovered that even laptops as old as 13 years – ThinkPad X220/T420s/W520 – can be powered the same – but with simple and very cheap adapter cables – such as these below. From the left there is 5.5mm/2.5mm typical router socket – then more modern ThinkPad X270/T470s (and many more) – then oldschool models from 2011 year – ThinkPads such as X220/T420s/W520 models.

All they need is a USB-C power input.

You need to only meet two requirements – the USB charger that will make enough power for example 20V at 3.25A for 65W that would power ThinkPad X220/T420s or 20V at 6.75A for 135W that would power ThinkPad W520. While the official power supply for ThinkPad W520 is 170W – its perfectly fine to use the 135W power adapter from ThinkPad W510 to power ThinkPad W520 laptop.

This makes organizing cables (and chargers) a lot easier – for example – I would not be able to fit 3 ‘dedicated’ ThinkPad chargers in that white cable organizer behind laptops – but I will fir there two powerful 65W and 85W USB-C chargers perfectly fine.

You can find these power adapters for about $1-$3 – for example – on https://aliexpress.com – with the USB-C ADAPTER LAPTOP ROUTER keywords in their search.

~

Creative BT-W2 USB-A Bluetooth Adapter

When I have to cope with Bluetooth technology – its ‘tolerable’ on Android devices such as phones/tablets and mostly nowhere else. After bad audio (just not working) Bluetooth possibilities on FreeBSD I decided to try the hardware solution instead. The audio related Bluetooth on FreeBSD have failed me too many times – to the point called enough is enough – that also means I do not want to waste any more time trying to figure the way using FreeBSD Bluetooth stack devices anymore – at least for audio related devices.

Not so long ago I got the Sony WH1000XM4 headphones. I am/was a big fan of the Technics RP-F290 cable headphones (Jack or Mini Jack based). They have so much BASS and ‘power’ that I could not ask for more … and their cost is very low – like $24 or less. The only ‘downside’ of the Technics RP-F290 headphones is that they are audio only – they do not have any microphone at all – they are dedicated for music only – and that is OK – they do GREAT in that role.

I have tried some Bluetooth based headphones in the past – and they were SHIT to say the least. Not enough ‘power’ – not enough BASS etc. After reading multiple reviews I decided to give Sony WH1000XM4 headphones a chance … and I was not disappointed. Its the first time after Technics RP-F290 cable headphones that ANY Bluetooth based headphone delivered. I was (and I still am) really satisfied with them.

This is where the USB powered Creative BT-W2 comes handy. Its also relatively cheap as the cost of used unit is less then $20 – at least that is the price I payed for mine in Poland. The Creative BT-W2 allows to connect Bluetooth audio devices everywhere – even on OpenBSD – on the system that cut off Bluetooth stack entirely – and it works well on FreeBSD too. The ‘downside’ of the Sony WH1000XM4 headphones is that they do have microphone – but only in Bluetooth node – they have Mini Jack connector – but for audio only …

This is also only downside of the Creative BT-W2 solution – it transmits only audio – but w/o microphone. Its more then OK for listening music – but if You have to do live conferencing/meetings on FreeBSD as I do – its a dead end.

I have tried to find a solution to this problem – to the point that I wanted to abandon Sony WH1000XM4 headphones entirely and find some Mini Jack (or Jack) based BASS oriented headphones that will also have a working microphone.

On my journey I have found a solution that I did not expected at all – and that was the solution that solved all my problems – and allowed me to enjoy the Sony WH1000XM4 headphones – but more about that in the next ‘subsection’.

~

External Microphone for SONY Headphones

You already know the downsides of the Sony WH1000XM4 headphones that were giving me headaches. Now its time to address them.

After many hours of searching the Internet I have found a very ‘usable’ Mini Jack cable. A cable that came with microphone and a one that perfectly integrated with Sony WH1000XM4 headphones … and FreeBSD as well.

Its available to buy for $22 on amazon.de (and possible other locations) and its called Boom Microphone Cable. Thanks to the knowledge that Sony WH1000XM4 headphones have Mini Jack port with microphone part – the Boom Microphone Cable cable even comes with volume controls and even come with physical kill switch for microphone.

After You attach this Boom Microphone Cable to the Sony WH1000XM4 headphones it looks (and works) like a natural solution.

The only ‘downside’ is generally the downside of the Sony WH1000XM4 headphones – that You CAN NOT disable their silencing while you speak – so using them in ‘passive’ mode with Boom Microphone Cable is preferred to meet all needs.

EDIT: After reading comments to this article I learned that this ‘silencing’ is called Speak to Chat and it can be disabled in the SONY Android app or by holding two fingers on the right earcup until the headphones say “Speak to Chat disabled.” Thank You for that.

~

Headphones Handle

I got used to the fact that I just put my headphones on the desk … but I wanted something more useful – after some searching it was obvious to me that I needed just some headphones handle that I could attach somewhere.

After another several hours of browsing I have found a ‘part’ that would fit perfectly – a $4-5 part from https://aliexpress.com that I could find with the HEADPHONES HOLDER keywords in their search.

Here is how it works on my desk.

… and its 360 degrees adjustable as well.

Above the headphones handle You can see the ‘hero’ of the AMD Based FreeBSD Desktop article.

~

Dual USB-C and USB-A Pendrive (SanDisk)

With all my ‘bad’ experiences with PTP connections for Android based devices (and other places) I really liked the SanDisk Ultra Dual Drive.

Its really handy for many transfers … and its more fast then slow as well.

~

Tiny USB-A Hub

When You need to connect several USB-A devices the USB ports count often come short fast – this is where this tiny USB-A hub comes handy.

With its dirt cheap $1-2 price (at https://aliexpress.com with USB HUB keywords) its a ‘steal’ … and it is a 3 port hub – there is another USB-A port at the end of it – the one that is not visible.

~

Quad USB-C / USB-A / Lightning / Micro USB Adapter with MicroSD Card Slot

… as we are talking various USB-A or USB-C solutions I could not mention this quad port adapter with MicroSD card slot.

I do not even remember how many times I have used it to copy/backup contents of my phone(s) and/or tablet(s).

Nowadays I believe I use the Dual USB-C / USB-A Pendrive more … but not always.

For $8-9 on its not a bad solution to have.

Batteries … I mean SD card – not included ๐Ÿ™‚

~

Angle Power Adapters

I have often found that the angle with which the power cord sticks out of a PC is definitely not ideal – this is where angle power adapters come handy.

Here is how it looks (being used) on my PC.

They are available for about $1-2 on https://aliexpress.com with ANGLE C13 CABLE keywords on the search box.

C13/C14 Power Adapters with Additional C1/C2 or C5/C6 Sockets

After You have spent some time to lay down the C13/C14 power cables just to power your PC its really annoying to do the same for another set of C1/C2 or C5/C6 cables/sockets … but not anymore.

Now with single cable adapter You are able to power more then one computer – depending on the needs with additional connectors.

They are available for $1-2 on https://aliexpress.com with DUAL C13 CABLE keywords on the search box.

~

HDMI 3in1 Switch with Remote Control

I happen to have a 2010 FullHD 50 Inch TV that has ONLY ONE port of HDMI kind … and it was pretty annoying to say the least … up to the time I added a HDMI switch/hub to it.

The HDMI switch along with its remote below.

For the record – I have used the UGreen 3in1 HDMI Switch with 4K @ 30Hz Capability and Remote and I was able to get one for $16.

~

Cable Organizers

To not have a mess in the cables its useful to have them organized in some way.

I use multiple solutions for that.

Lets start with simple organizers.

… and a larger/taller one for more capacity/possibilities.

They are available for $3-9 on https://aliexpress.com with CABLE ORGANIZER keywords on the search box.

I also use some IKEA containers …

… and smaller boxes in which I keep the tiny things.

I do not even remember after what product these boxes are … and that does not even matter I think.

~

Mouse Jigger

While there are many software settings or solutions to prevent screen from locking up – there is one bulletproof solution what just always works – a hardware USB mouse jigger.

I use a very simple one with 3 modes – but its more then enough for me needs.

Feel free to check other offers with USB MOUSE JIGGER at https://aliexpress.com search box.

~

FM Transmitter

Last but not least – the car FM transmitter.

My daily ‘real’ driver (I mean on the real road outside) is the 2006 Dodge Magnum car. I really love it for the simplicity and calm that it provides during the ride – but on the audio side it only has an old FM/AM radio and a CD slot … and not MP3 support in that one.

This is where the FM transmitter such as mine Blow comes really handy.

It supports two modes. One is being a Bluetooth slave of your phone – it just plays on the car speakers anything you are currently playing on your phone – it also has microphone builtin – so You can also use it as a ‘loud’ phone talking device.

I use it in a more simple mode – I just attach a tiny Lexar S47 32GB pendrive to it – and play a random song of it.

Besides these features it also has additional USB-A port available to attach a cable to it and charge some device.

I was able to get one a new one for about $19.

~

Summary

The mentioned devices above are probably not the only ones that make my life easier – but definitely the most crucial ones.

Feel free to share your ‘helper’ hardware in the comments.

Regards.

EOF

FreeBSD Desktop – Part 29 – Configuration – Audio Improvements

I recently added some improvements to my audio configs and settings on FreeBSD desktop.


freebsd-audio

Each of these ideas is nothing special or groundbreaking – but they all improve usability of daily FreeBSD desktop experience.

The Table of Contents for this article contains.

  • Default Audio Output
  • PulseAudio Output Change
  • Openbox Generated Sound Menu
  • Automatic Audio Output Change
  • Direct Deadbeef Audio Controls
  • Reset mixer(1) Settings
  • Sound for USB Device Attach/Detach
  • Default Audio Output
  • Summary

One of the usual things on a FreeBSD desktop is that user needs to – after attaching USB headphones – manually switch to them with sysctl(8) as root and then restart all audio apps so they will be able to use new audio output.

// LIST SOUND DEVICES

desktop # cat /dev/sndstat
Installed devices:
pcm0: <Conexant CX20590 (Analog 2.0+HP/2.0)> (play/rec) default
No devices installed from userspace



// AFTER ATTACHING USB HEADPHONES NEW pcm1 DEVICE APPEARS

desktop # cat /dev/sndstat
Installed devices:
pcm0: <Conexant CX20590 (Analog 2.0+HP/2.0)> (play/rec)
pcm1: <USB audio> (play/rec) default
No devices installed from userspace



// SWITCH TO NEW pcm1 DEVICE WITH sysctl(8) COMMAND

desktop # sysctl hw.snd.default_unit=1

… and after you are done listening the audio on USB audio device – then You need to do the opposite – switch back the hw.snd.default_unit to 0 sound device and also restart the audio apps again.

PulseAudio Output Change

On of the things that is indirectly forced on FreeBSD desktop users is PulseAudio. Not that long from now Firefox default audio output was switched from native FreeBSD OSS to PulseAudio for example. More and more apps are switched to it … but there at least is ONE advantage in that situation. When using PulseAudio You can switch its output on the fly as many times as You want without the need to kill or restart the applications playing audio.

Here is how it looks from the command line perspective.

// LIST PulseAudio OUTPUTS

desktop % pactl list sinks | grep 'Name: '
        Name: oss_output.dsp0
        Name: oss_output.dsp1

desktop % pactl get-default-sink
oss_output.dsp0



// SET dsp1 (ITS pcm1 ON FREEBSD DEVICES) AS DEFAULT AUDIO OUTPUT

desktop % pactl set-default-sink oss_output.dsp1

desktop % pactl get-default-sink
oss_output.dsp1



// SWITCH BACK TO dsp0 AUDIO OUTPUT

desktop % pactl set-default-sink oss_output.dsp0

desktop % pactl get-default-sink
oss_output.dsp0

But You can also use GUI pavucontrol(1) command to change PulseAudio output.

Here is the Playback tab opened.

pavucontrol-list

… and here is how You can switch current output audio device on the fly.

pavucontrol-select

Openbox Generated Sound Menu

I used it since quite long time – but I updated it with news links – for example to PulseAudio graphical interface.

The part that goes into the Openbox menu configurations is shown below.

<menu id="sound" label="sound" execute="__openbox_freebsd_sound.sh" icon="/home/vermaden/.config/openbox/icons/speaker.png" />

It looks like that on my system.

openbox-sound-menu

If You use Openbox then you may download it from this – __openbox_freebsd_sound.sh – place.

Automatic Audio Output Change

It is possible – with the use of FreeBSD devd(8) daemon – to make FreeBSD automatically switch to new audio source after its attach. I wrote the audio-source-switch.sh script for that purpose.

Here is the needed devd(8) configuration to make it work.

desktop # pkg install -y x11/zenity

desktop % cat /usr/local/etc/devd/audio_source.conf
                                                                                                                                                         
# USB/HEADPHONES/attach
attach 100 {
  device-name "pcm[0-9]+";
  action "su -l vermaden -c 'env DISPLAY=:0 /home/vermaden/scripts/audio-source-switch.sh attach 1> /dev/null 2> /dev/null &' &";
};

# USB/HEADPHONES/detach
detach 100 {
  device-name "pcm[0-9]+";
  action "su -l vermaden -c 'env DISPLAY=:0 /home/vermaden/scripts/audio-source-switch.sh detach 1> /dev/null 2> /dev/null &' &";
};

Remember to restart the devd(8) daemon everytime You dump a new config in the /usr/local/etc/devd directory.

Keep in mind that x11/zenity is needed for it to display information properly.

Now – after this change – when You plug in new USB audio output – You will see this zenity(1) dialog window.

new-audio-nothing-playing-attach

But that is only if You DO NOT play any audio currently.

If – for example – You currently use Deadbeef audio player to play music – You will see this zenity(1) dialog instead.

new-audio-output-attach

It will ask You if You want to kill that Deadbeef PID – so if You start it again – You will be able to use new audio output – but You may NOT want to kill it – hence the question.

You may also recompile Deadbeef with PulseAudio output support. Here is how the Deadbeef options in Preferences looks like after recompilation with PulseAudio support.

deadbeed-pulseaudio-output

If You already have another USB audio output attached and decided to detach it – and nothing is playing the audio – my zenity(1) script will dialog this dialog.

new-audio-nothing-playing-detach

… and if something is using the FreeBSD audio/sound subsystem – then this one.

tint2-deadbeef-buttons

Direct Deadbeef Audio Controls

I really like the mouse I use daily – the Logitech M720 – as much as I really like to use the additional buttons to increase/decrease the volume – I would really wish it would have ANOTHER two additional buttons for the next and previous song on the Deadbeef player.

Because of that I decided to add a dedicated set of buttons on my Tint2 bar on top – that would allow me to change the current Deadbeef song to the next one … or previous one … or pause it.

new-audio-output-detach

The Tint2 config was updates with this content.

desktop % grep player ~/.tint2rc
  launcher_item_app      = /home/vermaden/.apps/player-prev.desktop
  launcher_item_app      = /home/vermaden/.apps/player-stop.desktop
  launcher_item_app      = /home/vermaden/.apps/player-pause.desktop
  launcher_item_app      = /home/vermaden/.apps/player-play.desktop
  launcher_item_app      = /home/vermaden/.apps/player-next.desktop

… and the Deadbeef buttons configs looks as follows.

desktop % cat ~/.apps/player-next.desktop
[Desktop Entry]
Type=Application
Name=Deadbeef
Exec=deadbeef --next
Icon=/home/vermaden/.icons/vermaden/player-next.png

desktop % cat ~/.apps/player-pause.desktop
[Desktop Entry]
Type=Application
Name=Deadbeef
Exec=deadbeef --toggle-pause
Icon=/home/vermaden/.icons/vermaden/player-pause.png

desktop % cat ~/.apps/player-play.desktop
[Desktop Entry]
Type=Application
Name=Deadbeef
Exec=deadbeef --play
Icon=/home/vermaden/.icons/vermaden/player-play.png

desktop % cat ~/.apps/player-prev.desktop
[Desktop Entry]
Type=Application
Name=Deadbeef
Exec=deadbeef --prev
Icon=/home/vermaden/.icons/vermaden/player-prev.png

desktop % cat ~/.apps/player-stop.desktop
[Desktop Entry]
Type=Application
Name=Deadbeef
Exec=deadbeef --stop
Icon=/home/vermaden/.icons/vermaden/player-stop.png

Reset mixer(1) Settings

One of the things that annoyed me was the mixer settings when I tried to join some call/teleconference. It seemed like a random pointless fuckup. Not anymore. With small and simple mix.sh script it all gets to normal and everything works out of the box.

Here is how the mix.sh script looks like.

desktop % cat ~/scripts/mix.sh
mixer vol.volume=0.6
mixer mic.volume=0.85
mixer rec.volume=0.85
mixer pcm.volume=1.0
mixer speaker.volume=0.0
mixer monitor.volume=0.0
mixer

… and how it works.

desktop % mix.sh 
pcm0:mixer:  on hdaa0  (play/rec) (default)
    vol       = 0.60:0.60     pbk
    pcm       = 1.00:1.00     pbk
    speaker   = 0.00:0.00     pbk
    mic       = 0.85:0.85     rec src
    rec       = 0.85:0.85     pbk
    monitor   = 0.00:0.00     rec

Sound for USB Device Attach/Detach

Most desktop oriented operating systems do play some type of sound for device attach/detach so the user would get a feedback that the system is aware of his actions – like – well – attaching or detaching a USB device ๐Ÿ™‚

By default FreeBSD does not do anything like that – but its not hard to add such an action to the FreeBSD devd(8) daemon.

With the following devd(8) config FreeBSD will now play a dedicated sound on each USB device attach or detach event.

In the beginning I did not knew which sound to pick from – but after some thoughts I decided to pick some Worms Armageddon sounds – from the 007 sound theme.

worms-logo

The devd(8) config looks like that one below.

desktop # pkg install -y audio/mpg123

desktop % cat /usr/local/etc/devd/USB.conf

# USB/attach
notify 10 {
  match "system" "USB";
  match "type"   "ATTACH";
  action "su -l vermaden -c 'env DISPLAY=:0 /usr/local/bin/mpg123 /usr/local/etc/devd/USB.attach.mp3' &";
};

# USB/detach
notify 10 {
  match "system" "USB";
  match "type"   "DETACH";
  action "su -l vermaden -c 'env DISPLAY=:0 /usr/local/bin/mpg123 /usr/local/etc/devd/USB.detach.mp3' &";
};

I also assume that You will have audio/mpg123 installed to play these sounds.

Because WordPress is very limited – it will not allow me to upload plain MP3 files – but we will overcome that limitation. For the record – it is not a technical limitation – its just a limitation of the FREE PLAN that I am using on the WordPress page.

bear-grylls

Here are the commands You need to execute to fetch these two MP3 files.

desktop ~ # fetch \
              -o /usr/local/etc/devd/usb.detach.mp3.zip
              https://vermaden.wordpress.com/wp-content/uploads/2024/01/usb.detach.mp3_.docx
/usr/local/etc/devd/usb.detach.mp3.zip                9588  B   40 MBps    00s

desktop ~ # fetch \
              -o /usr/local/etc/devd/usb.attach.mp3.zip \
              https://vermaden.wordpress.com/wp-content/uploads/2024/01/usb.attach.mp3_.docx
/usr/local/etc/devd/usb.attach.mp3.zip                  11 kB   41 MBps    00s

desktop ~ # cd /usr/local/etc/devd

desktop /usr/local/etc/devd # unzip usb.detach.mp3.zip
Archive:  usb.detach.mp3.zip
 extracting: USB.detach.mp3  

desktop /usr/local/etc/devd # unzip usb.attach.mp3.zip
Archive:  usb.attach.mp3.zip
 extracting: USB.attach.mp3  

Now as You have the needed MP3 files – restart the devd(8) daemon.

Now everytime You will attach or detach USB device You will hear appropriate Worms Armageddon sound.

Summary

I think that I can say that nothing prevents You from running FreeBSD desktop daily. If the FreeBSD is the desktop You want – and You are still running macOS or Windows instead – You are just lazy as fuck ๐Ÿ™‚

UPDATE 1 – Other FreeBSD Audio Improvements

As usual I got a lot additional good stuff from the comments from many places.

Below I would try to summarize them.

Firefox

For the Firefox browser its possible to check the media/audio devices with about:support#media URL.

UPDATE1-firefox-media

GTK-Mixer

To have a GUI for the various volume settings You can use GTK-Mixer and its available in the FreeBSD package as audio/gtk-mixer name.

desktop # pkg install audio/gtk-mixer

desktop % gtk-mixer

Here is how it looks like.

UPDATE1-gtk-mixer

FreeBSD Audio Stack Improvements

Seems that Christos Margiolis is already working on some Audio Stack Improvements on FreeBSD thanks to FreeBSD Foundation.

This is his message:

The past (and first) week working on the audio stack, sponsored by the FreeBSD Foundation, I:

- Set up my development environment; a VM image running -CURRENT in bhyve with PCI-passthru
  enabled to do all of the driver (kernel generallly) development in the VM.

- Wrote a small series of patches for vmrun.sh:
  https://reviews.freebsd.org/D43269
  https://reviews.freebsd.org/D43270

- Modified the snd_uaudio(4) driver to provide information about the sound card
  (manufacturer, model and attached driver), as opposed to the current generic "USB Audio"
  string, so /dev/sndstat and programs like mixer(8) can output more useful information
  about USB audio devices.
  https://reviews.freebsd.org/D43347

- Submitted a patch to update (and unify) the description format for all sound devices,
  since some of them haven't been touched for years.
  https://reviews.freebsd.org/D43349

- Implemented device_set_descf() , a printf-like version of device_set_desc().
  https://reviews.freebsd.org/D43370

- Was preparing a few more smaller patches.

- Started looking into possible solutions to
  https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194727
  also mentioned in the first paragraph of the BUGS section of the snd_uaudio(4) man page.

Christos

Check the the links from the message above – a lot of great FreeBSD Audio Stack changes are coming.

PulseAudio

Someone also notified my that instead of writing a script for PulseAudio to automatically switch to just connected device on could load the module-switch-on-port-available or module-switch-on-connect module.

Check the details in the pacmd list-modules command.

desktop % pacmd list-modules | grep -B 1 -A 7 module-switch 
    index: 4
        name: 
        argument: 
        used: -1
        load once: yes
        properties:
                module.author = "David Henningsson"
                module.description = "Switches ports and profiles when devices are plugged/unplugged"
                module.version = "16.1"

EOF

FreeBSD Home Audio Studio

Another guest post by @NeoMoevius from Twitter.

Same as earlier with the Native Urban Terror on FreeBSD article.

This time it will be about setting up Home Audio Studio on a FreeBSD 13.1 system.

w701-ardour

The idea is to use software like:

  • Jackaudio/jack
  • Qtractoraudio/qtractor
  • Ardouraudio/ardour
  • MuSE Sequenceraudio/muse-sequencer

The first step is to setup Jack on FreeBSD – make sure to setup the realtime mode – this is very important.

Add mac_priority to /etc/rc.conf file and load the mac_priority kernel module.

# echo 'kld_list="${kld_list} mac_priority"' >> /etc/rc.conf

# kldload mac_priority

Then add yourself to realtime group.

# pw groupmod realtime -m yourself

# grep realtime /etc/group         
realtime:*:47:yourself

You will need to install audio/jack package.

% pkg which -o $( which jackd )
/usr/local/bin/jackd was installed by package audio/jack

The /etc/rc.conf part to run Jack is below.

# grep jack /etc/rc.conf
  jackd_enable="YES"
  jackd_user="username"
  jackd_rtprio="YES"
  jackd_args="-r -d oss -r44100 -p1024 -n2 -w16 -i4 -o8 -C /dev/dsp0 -P /dev/dsp0"

The Qtractor will also require audio/alsa-seq-server to work. The good part is that it (the audio/alsa-seq-server package) comes with rc(8) script to start it so you may enable it with service(8) or sysrc(8) commands.

% /usr/local/etc/rc.d/alsa_seq_server rcvar
# alsa_seq_server
#
alsa_seq_server_enable="NO"
#   (default: "")

# service alsa_seq_server enable
alsa_seq_server enabled in /etc/rc.conf

# sysrc alsa_seq_server_enable=YES
alsa_seq_server_enable: YES -> YES

Now all of the above DAW software (or other music programs) should be working properly.

EOF

Split Audio Files into Parts

I recently got in the need of splitting quite large amount of audio files into smaller equal parts. The first thought that came to my mind was – probably thousand or more people had similar problem in the past so its already solved – so I went directly to the web search engine.

The found solutions seem not that great or work partially only … or not work like I expected them to work. After looking at one of the possible solutions in a bash(1) script I started to modify it … but it turned out that writing my own solution was faster and easier … and simpler.

Today I will share with you my solution to automatically split audio files into small equal parts.

Existing Solutions

In my search for existing solutions I indeed found some tools that will allow me to achieve what I need. I will not try to talk them one after another.

mp3splt

The first one I found was the audio/mp3splt port (and package) available on FreeBSD. So I installed it with typical pkg(8) command as shown below.

# pkg install mp3splt

It installed properly … but returned Segmentation Fault instead of actually working. I even submitted a PR for that in the FreeBSD Bugzilla – 264866 – but no update till now.

Thus I removed that package and went to search for something that works.

Brasero

Someone on some forum suggested using CD/DVD burning software – Brasero – because one of its features is audio splitting – so I installed the sysutils/brasero package now.

# pkg install brasero

It turns out that it really works. Some screenshots below.

brasero.1

brasero.2

… but that did not satisfied my because I wanted an automated/unattended solution instead of ‘clicking’ each file separately to split them. I also did not liked the fact that I needed to specify time in seconds.

mp3split

Do not confuse with mentioned earlier mp3splt command. The mp3split is a unattended one created in a bash(1) script – https://diegosanchezp.github.io/blog/mp3split/ – available and described here. One of its downsides (for me) was that it needed additional external ‘list’ file with times and titles for the parts.

I did not wanted to write this each time so I generated a long enough list file that will cover any possible file no matter the length with the following loop.

% seq 0 10 10000 \
    | while read MIN
      do
        seq 0 10 50 \
          | while read SEC
            do
              echo ${MIN}:${SEC}
            done
      done > list.txt

% head list.txt
0:0
0:10
0:20
0:30
0:40
0:50
10:0
10:10
10:20
10:30

I needed to split these audio files every 10 minutes. I redirected that output into the list.txt file. I then fetched and made executable the mentioned mp3split script.

% fetch https://raw.githubusercontent.com/diegosanchezp/mp3split/master/mp3split.sh

% chmod +x mp3split.sh

% ./mp3split.sh --help
zsh: ./mp3split.sh: bad interpreter: /bin/bash: no such file or directory

% head -1 ./mp3split.sh
#!/bin/bash

So now we will have to remove linuxisms from the script. Lets hope its only the interpreter part.

% head -1 ./mp3split.sh
#! /usr/bin/env bash

% ./mp3split.sh --help
./mp3split.sh: illegal option -- -
Invalid option: -
Usage:
  mp3split [OPTIONS] inputaudio tracklist
Options:
  -s: do a simulation without writing anything to disk
  -h: print this help
  -e extension: set output extension, if extension is equal to "" keep extension of input file
  The script will output all the splitted files in the
  current/working directory.


Better. Lets try to use it.

% ./mp3split.sh LARGE-AUDIO-FILE.mp3 list.txt

=== Begin to create mp3 split files ===
0:0.mp3: Protocol not found
Processed 0:0 to 0:10; 0:0.mp3
0:10.mp3: Protocol not found
Processed 0:10 to 0:20; 0:10.mp3
0:20.mp3: Protocol not found
Processed 0:20 to 0:30; 0:20.mp3
0:30.mp3: Protocol not found
Processed 0:30 to 0:40; 0:30.mp3
0:40.mp3: Protocol not found
Processed 0:40 to 0:50; 0:40.mp3
0:50.mp3: Protocol not found
Processed 0:50 to 10:0; 0:50.mp3
10:0.mp3: Protocol not found
Processed 10:0 to 10:10; 10:0.mp3
10:10.mp3: Protocol not found
Processed 10:10 to 10:20; 10:10.mp3
10:20.mp3: Protocol not found
Processed 10:20 to 10:30; 10:20.mp3
10:30.mp3: Protocol not found
Processed 10:30 to 10:40; 10:30.mp3
10:40.mp3: Protocol not found
Processed 10:40 to 10:50; 10:40.mp3
10:50.mp3: Protocol not found
Processed 10:50 to 20:0; 10:50.mp3
20:0.mp3: Protocol not found
Processed 20:0 to 20:10; 20:0.mp3
20:10.mp3: Protocol not found
Processed 20:10 to 20:20; 20:10.mp3
20:20.mp3: Protocol not found
Processed 20:20 to 20:30; 20:20.mp3
^C

Some strange error message Protocol not found … after small investigation it turns out that two characters fix for the ffmpeg(1) command will do. The diff(1) is available below.

% diff -u mp3split.sh mp3split.sh.FIXED.sh
--- mp3split.sh 2022-06-25 22:34:25.499718000 +0200
+++ mp3split.sh.FIXED.sh        2022-06-25 22:37:45.580845000 +0200
@@ -25,7 +25,7 @@
   outfile="$tracktitle.$ext"

   # Begin splitting files with ffmpeg
-  [ ! "$simulate" = true ] && ffmpeg -nostdin -y -loglevel error -i "$inputaudio" -ss "$start" -to "$end" -acodec copy "$outfile"
+  [ ! "$simulate" = true ] && ffmpeg -nostdin -y -loglevel error -i "$inputaudio" -ss "$start" -to "$end" -acodec copy ./"$outfile"

   echo "Processed $start to $end; $outfile"
 }

Now lets try to use the fixed version.

% ./mp3split.sh.FIXED.sh LARGE-AUDIO-FILE.mp3 list.txt

=== Begin to create mp3 split files ===
Processed 0:0 to 0:10; 0:0.mp3
Processed 0:10 to 0:20; 0:10.mp3
Processed 0:20 to 0:30; 0:20.mp3
Processed 0:30 to 0:40; 0:30.mp3
Processed 0:40 to 0:50; 0:40.mp3
Processed 0:50 to 10:0; 0:50.mp3
Processed 10:0 to 10:10; 10:0.mp3
Processed 10:10 to 10:20; 10:10.mp3
Processed 10:20 to 10:30; 10:20.mp3
Processed 10:30 to 10:40; 10:30.mp3
Processed 10:40 to 10:50; 10:40.mp3
Processed 10:50 to 20:0; 10:50.mp3
Processed 20:0 to 20:10; 20:0.mp3
Processed 20:10 to 20:20; 20:10.mp3
Processed 20:20 to 20:30; 20:20.mp3
Processed 20:30 to 20:40; 20:30.mp3
Processed 20:40 to 20:50; 20:40.mp3
Processed 20:50 to 30:0; 20:50.mp3
Processed 30:0 to 30:10; 30:0.mp3
Processed 30:10 to 30:20; 30:10.mp3
Processed 30:20 to 30:30; 30:20.mp3
Processed 30:30 to 30:40; 30:30.mp3
Processed 30:40 to 30:50; 30:40.mp3
Processed 30:50 to 40:0; 30:50.mp3
Processed 40:0 to 40:10; 40:0.mp3
Processed 40:10 to 40:20; 40:10.mp3
Processed 40:20 to 40:30; 40:20.mp3
Processed 40:30 to 40:40; 40:30.mp3
Processed 40:40 to 40:50; 40:40.mp3
Processed 40:50 to 50:0; 40:50.mp3
Processed 50:0 to 50:10; 50:0.mp3
Processed 50:10 to 50:20; 50:10.mp3
Processed 50:20 to 50:30; 50:20.mp3
Processed 50:30 to 50:40; 50:30.mp3
Processed 50:40 to 50:50; 50:40.mp3
Invalid duration specification for to: 60:0
Processed 50:50 to 60:0; 50:50.mp3
Invalid duration specification for ss: 60:0
Processed 60:0 to 60:10; 60:0.mp3
Invalid duration specification for ss: 60:10
Processed 60:10 to 60:20; 60:10.mp3
Invalid duration specification for ss: 60:20
Processed 60:20 to 60:30; 60:20.mp3
Invalid duration specification for ss: 60:30
Processed 60:30 to 60:40; 60:30.mp3
Invalid duration specification for ss: 60:40
Processed 60:40 to 60:50; 60:40.mp3
Invalid duration specification for ss: 60:50
Processed 60:50 to 70:0; 60:50.mp3
Invalid duration specification for ss: 70:0
Processed 70:0 to 70:10; 70:0.mp3
Invalid duration specification for ss: 70:10
Processed 70:10 to 70:20; 70:10.mp3
^C

Great … so after the file ended it will still try EVERY goddamn position from the list.txt file. It was also not able to reach the final ‘ending’ part without ‘visiting’ each time from the list.txt file. Enough is enough. I tried.

Custom Script Solution

After trying to modify the mp3split script even more I came to the conclusion that it will take less time to write my own solution from scratch … and this is exactly what I did. I wrote the audio-split.sh in POSIX /bin/sh interpreter for portability. After an hour later 50 lines of code did exactly what I needed – not counting the __usage() function for help information.

code.fixed

Here is the __usage() contents by the way.

help

The idea/needs were:

  • split large file automatically/unattended into equal parts
  • create new dir in which these parts are created
  • new dir must have same name as specified file (without extension)
  • each part will get a ' - xxx' suffix (like ' - 001' for first part) with original extension

… and they were met.

Here is the output of running audio-split.sh command.

% ffmpeg -i LARGE-AUDIO-FILE.mp3 2>&1 | grep Duration
  Duration: 00:44:55.99, start: 0.025057, bitrate: 171 kb/s

% audio-split.sh 10 LARGE-AUDIO-FILE.mp3
LARGE-AUDIO-FILE/LARGE-AUDIO-FILE - 001.mp3
LARGE-AUDIO-FILE/LARGE-AUDIO-FILE - 002.mp3
LARGE-AUDIO-FILE/LARGE-AUDIO-FILE - 003.mp3
LARGE-AUDIO-FILE/LARGE-AUDIO-FILE - 004.mp3
LARGE-AUDIO-FILE/LARGE-AUDIO-FILE - 005.mp3

% du -sm LARGE-AUDIO-FILE.mp3
56      LARGE-AUDIO-FILE.mp3

% du -smc LARGE-AUDIO-FILE/*
13      LARGE-AUDIO-FILE/LARGE-AUDIO-FILE - 001.mp3
13      LARGE-AUDIO-FILE/LARGE-AUDIO-FILE - 002.mp3
13      LARGE-AUDIO-FILE/LARGE-AUDIO-FILE - 003.mp3
13      LARGE-AUDIO-FILE/LARGE-AUDIO-FILE - 004.mp3
7       LARGE-AUDIO-FILE/LARGE-AUDIO-FILE - 005.mp3
56      total

The total size is the same (or similar in larger files). After listening to the parts I came to the conclusion that it works properly. The audio file is about 45 minutes long and the script created 4 10 minutes long files and 1 that is less then 5 minutes. Not sure if you also have such needs but if yes then you may now use another solution – audio-split.sh – for it ๐Ÿ™‚

EOF

Quare FreeBSD?

I really wanted to make this article short … but I failed miserably. At least I tried to organize it well so one may get back to it after ‘some’ reading because its not a short lecture. I wanted to title it Why FreeBSD? but when you type that into your favorite duck.com search engine there are so many similar articles. I wanted it to have distinguished and unique name so I used Latin word for ‘why‘ which is ‘quare‘.

logo-freebsd

What FreeBSD can offer you that other operating systems does not? From all of the operating systems I used I find FreeBSD to suck the least. This post is not here to convince you to use or try FreeBSD – this you will have to do by yourself. This article will show you why FreeBSD is valuable or better alternative to other operating systems and is definitely not dying.

This is the Table of Contents for this article.

  • Base System
  • ZFS Boot Environments
  • Rescue
  • Audio
  • Jails
  • Bhyve
  • FreeBSD Ports Infrastructure
  • Updating/Building from Source
  • Storage
  • Init System
  • Linux Binary Compatibility
  • Simplicity
  • Evolution Instead Rewriting
  • Documentation
  • Community
  • Closing Thoughts
  • External Discussions

Base System

When you install a Linux system its just a bunch of RPM or DEB packages. For example of you install CentOS 7.8 Minimal variant you end up with several hundred RPM packages installed. After a week or month many of these packages will get updates sometimes making this CentOS system unusable or even unbootable (recent GRUB Boothole problem for example). On the contrary FreeBSD comes with a Base System concept. This means that when you install FreeBSD you install a minimal system as a whole. No packages or subsystems to be separately updated. Just whole Base System. That means that /boot /bin /sbin /usr /etc /lib /libexec /rescue directories are untouchable by any packages. When you decide to install packages (or build them using FreeBSD Ports) they will all fall into the /usr/local prefix. That means /usr/local/etc for configuration. The /usr/local/bin and /usr/local/sbin directories for binaries. The /usr/local/lib and /usr/local/libexec for libraries and so on. The FreeBSD Base System kernel modules are kept in the same dir along with the kernel in the /boot/kernel directory. To make things tidy all kernel modules that are provided by packages go into the /boot/modules dir. Everything has its place and its separated.

That is separation between Base System binaries (at /bin /sbin /usr/bin /usr/sbin dirs) and Third Party Packages maintained by pkg(8) and are located at /usr/local/bin and /usr/local/sbin dirs. We all know differences between bin (user) and sbin (root) binaries but in FreeBSD there is also another more UFS related separation. When there was only UFS filesystem in the FreeBSD world the /bin and /sbin binaries were available at boot after the root (/) filesystem was mounted and yet before /usrย  filesystem was mounted – this is historical (and still useful in the UFS setups) distinction dating to old UNIX days. In ZFS setups it does not matter as all files are on ZFS pool anyway.

Illustration of the Base System / dir and optional for third party applications /usr/local dir.

base-system-dirs

The FreeBSD Base System separation also helps with another thing – if any package gets the ‘great’ idea to install new compiler named cc and override the default system compiler … or to add libraries/includes in such a way that makes it super hard to get back into a working system. If some random FreeBSD package would add libc.so to /usr/local/lib dir then you are covered and not prevented from running programs as usual because FreeBSD system binaries are linked to stuff in /usr/lib dir. This is why there is PATH variable on UNIX systems (and FreeBSD as well) to set which directories should be searched for binaries first. On FreeBSD by default its set search Base System binaries dirs first and then Third Party Packages later.

You can update (or not) the Base System separately from the installed packages with freebsd-update(8) command when using RELEASE or by recompiling with make buildworld and make installworld commands when using STABLE/CURRENT systems. When it comes to packages you can update them using the pkg(8) tool or portmaster when building from FreeBSD Ports tree under /usr/ports dir. That means that any packages updates will not touch your FreeBSD Base System at all. For example when you mess up (and I have done that in the beginning of my FreeBSD journey) the compiled ports and packages and you want to start over the only thing you have to do is remove /usr/local and /boot/modules and /var/db/pkg directories. That’s it. You are just reverted to your Base System and can start over. This is just not possible when using Linux system. Even with Gentoo that many concepts are based on FreeBSD ideas does not have Base System feature. This Base System also have additional feature. Because its separated from packages version no one stops you from running oldshool FreeBSD 9.0 from 2012 and install there latest Firefox 80 or LibreOffice 7.0. You can not install latest Firefox on Ubuntu from 2012 …

One may be ‘afraid’ that such Base System independent from installed packages would take more space but nothing far more from the truth. The fresh installed FreeBSD 12.1 system uses less then 1 GB of disk space and takes less then 75 MB of RAM with sshd(8) running. For the comparison fresh CentOS 7.8 install with ‘Minimal’ set chosen takes 1.1 GB of disk space and uses more then 100 MB RAM with sshd(8) running. Such CentOS system is really naked and really needs more packages to be usable while FreeBSD with its Base System is far more capable and powerful and comes along with builtin latest version of LLVM/CLANG compiler suite for example.

More on the Base System topic:

ZFS Boot Environments

I have talked about this many times and probably one time too less because Linux world still ignores this bless. Having ZFS Boot Environments its such a game changer that once you realize how powerful it is you will never want to use a system that does not support it. The idea is that you can snapshot a running system at any moment of time and then reboot into that moment (or snapshot) if something happened. Its perfect solution for upgrade or changes to the system. The FreeBSD systems are already well ‘protected’ from problems arising after updating the packages but ZFS Boot Environments takes this to a whole new level.

groundhog

Like in the movie Groundhog Day (1993) with ZFS Boot Environments you will have limitless chances to get your shit together. Even the Base System updates and changes are protected by it. You can even transport that Boot Environment by using zfs send and zfs recv commands to other system … or propagate it on many systems. You can create Jails containers from it … or install new version of FreeBSD in the new Boot Environment and reboot into it while still having your older ‘production’ system untouched.

More on the ZFS Boot Environments topic:

Rescue

When you really mess up to the point that even Base System concept or ZFS Boot Environments feature did not stopped you from killing your FreeBSD installation then there is one more level of rescue … the Rescue subsystem.

rescue

You have about 150 statically linked binaries available at your disposal for the rescue mission of that FreeBSD installation. You probably think now that if its so many binaries then it probably takes a lot of space … nothing far more from the truth. Its actually one static binary with hardlinks … and it takes whooping 11 MB of disk space.

FreeBSD # ls -lh /rescue | head -5
total 1118446
-r-xr-xr-x  146 root  wheel    11M 2020.02.19 21:10 [
-r-xr-xr-x  146 root  wheel    11M 2020.02.19 21:10 bectl
-r-xr-xr-x  146 root  wheel    11M 2020.02.19 21:10 bsdlabel
-r-xr-xr-x  146 root  wheel    11M 2020.02.19 21:10 bunzip2

They Rescue subsystem even contains such binaries as bectl(8) for ZFS Boot Environments management or zfs(8) and zpool(8) commands for the ZFS filesystem. Here is complete list of these binaries.

FreeBSD # ls /rescue
[           dd               fsck_ffs      init       mdmfs          ping      rtsol        unlink
bectl       devfs            fsck_msdosfs  ipf        mkdir          ping6     savecore     unlzma
bsdlabel    df               fsck_ufs      iscsictl   mknod          pkill     sed          unxz
bunzip2     dhclient         fsdb          iscsid     more           poweroff  setfacl      unzstd
bzcat       dhclient-script  fsirand       kenv       mount          ps        sh           vi
bzip2       disklabel        gbde          kill       mount_cd9660   pwd       shutdown     whoami
camcontrol  dmesg            geom          kldconfig  mount_msdosfs  rcorder   sleep        xz
cat         dump             getfacl       kldload    mount_nfs      rdump     spppcontrol  xzcat
ccdconfig   dumpfs           glabel        kldstat    mount_nullfs   realpath  stty         zcat
chflags     dumpon           gpart         kldunload  mount_udf      reboot    swapon       zdb
chgrp       echo             groups        ldconfig   mount_unionfs  red       sync         zfs
chio        ed               gunzip        less       mt             rescue    sysctl       zpool
chmod       ex               gzcat         link       mv             restore   tail         zstd
chown       expr             gzip          ln         nc             rm        tar          zstdcat
chroot      fastboot         halt          ls         newfs          rmdir     tcsh         zstdmt
clri        fasthalt         head          lzcat      newfs_msdos    route     tee          
cp          fdisk            hostname      lzma       nextboot       routed    test         
csh         fsck             id            md5        nos-tun        rrestore  tunefs       
date        fsck_4.2bsd      ifconfig      mdconfig   pgrep          rtquery   umount   

More on the Rescue topic:

Audio

Not many people expect from FreeBSD to shine in that department but it shines a lot here and not from yesterday but from decades. Remember when Linux got rid of the old OSS subsystem with one channel and came up with ‘great’ idea to write ALSA? I remember because I used Linux back then. Disaster is very polite word to describe Linux audio stack back then … and then PulseAudio came and whole Linux audio system got much worse. Back then because of that one OSS channel and many ALSA channels meant that ONLY ONE application with OSS backend could do the sound (for example WINE). But if another application would want to ‘make’ sound using OSS and you already have WINE started then it will be soundless because that one and only OSS channel was already taken. And remember that ALSA was so bad back then that KDE or GNOME made their own sound daemons mixing audio in userspace that were incompatible with each other. That means if you used KDE and GNOME apps back then you could have sound from GNOME apps but not from KDE apps or vice versa. One big fucking audio hell on Linux.

audio

Lets get back to FreeBSD audio then. What FreeBSD offered? A whooping 256 OSS channels mixed live in kernel for low latency. Everything audio related just worked out of the box – and still works today. You could have WINE or KDE/GNOME sound backends attached to their OSS channels and also ALSA apps getting their sound device without a problem. Even when you plugged a 5.1 surround system into FreeBSD it worked out of the box without any configuration and applications were able to use it immediately. That FreeBSD audio supremacy remains today as PulseAudio sound mixing in userspace while generally working incorporates large latency on Linux compared to in kernel FreeBSD mixing with low latency.

Comrade meka suggested that FreeBSD is also the only OS which has virtual_oss that allows mixing/resampling/compressing in user space and allows one to have Bluetooth headphones and USB microphone represented as single sound card.

More on the Audio topic:

Jails

The FreeBSD Jails are one of the oldest OS Level Virtualization implementations dating back to 1999. Even the Solaris Zones/Containers came five years later in 2004.

containers

After Docker was introduced in Linux the term OS Level Virtualization became less used to the Containers term and now the FreeBSD Jails along with Solaris Zones/Containers are named 1st generation containers. But that naming nomenclature change does not make FreeBSD Jails less powerful. They are also really brain dead simple to use. You just need a directory – for example /jail/nextcloud – where you will extract the FreeBSD Base System for desired release version – for example base.txz from 12.1-RELEASE and create the Jail config in the /etc/jail.conf file as shown below.

FreeBSD # mkdir -p /jail/nextcloud
FreeBSD # fetch -o - http://ftp.freebsd.org/pub/FreeBSD/releases/amd64/12.1-RELEASE/base.txz | tar --unlink -xpJf - -C /jail/nextcloud
FreeBSD # cat /etc/jail.conf
nextcloud {
  host.hostname = nextcloud.local;
  ip4.addr = 10.0.0.100;
  path = /jail/nextcloud;
}

Now you can start you Jail right away.

FreeBSD # service jail onestart nextcloud
Starting jails: nextcloud.

Voila! Your FreeBSD Jail is already running.

FreeBSD # jls
   JID  IP Address      Hostname                      Path
     1  10.0.0.100      nextcloud.local               /jail/nextcloud

You can of course have a trimmed down version of FreeBSD Base System in the Jail if that is needed. The ZFS filesystem also helps here greatly because with zfs clone only your ‘base’ Jail will take space and only the changes you make to Jails created from it. Thanks to other FreeBSD subsystem – the Linux Binary Compatibility – you can also create a Linux Jail – for example running Devuan or Ubuntu Jail.

The FreeBSD Jails are also very lightweight. You can boot and use about 1000 FreeBSD Jails on a single FreeBSD system with 4 GB RAM.

They are also very easy to debug and troubleshoot comparing even to plain Docker – not to even mention Kubernetes which requires whole team of highly skilled people to maintain.

The FreeBSD Jails may be configured/managed only by the Base System utilities such as jls(8)/jexec(8) but you can also select from many third party Jail management frameworks. From all available ones I would choose BastilleBSD because of their modern approach and many ready to use templates for all needed use cases.

If you want to check all the Jails features feel free to check the FreeBSD Jails Containers article.

More on the Jails topic:

Bhyve

FreeBSD – same as Linux or any other respected operating system – comes with its own written virtualization hypervisor. On the FreeBSD land this native solution is called Bhyve (and spelled bee hive).

bhyve-logo

In the terms of features its similar to KVM/XEN/VMware/VirtualBox.

The only thing that its lacking is the Live Migration feature. Its in the works as the Save/Resume feature is in the testing and will be merged soon.

Besides that – its performance is on par or similar to the mentioned competition. In the end – they all use the same AMD/Intel CPU features that allow virtualization on x86 land.

If You want to check Bhyve hypervisor in all its glory – feel free to check the FreeBSD Bhyve Virtualization article.

Alternatively FreeBSD also supports XEN (as dom0) and VirtualBox hypervisors if Bhyve does not suit your needs.

More on the Bhyve topic:

FreeBSD Ports Infrastructure

This is one of another examples why FreeBSD rocks that much. When you install Ubuntu or CentOS in some version there is chance that you will end up with not latest versions of packages but with versions that were quite up-to-date when this distribution version was released. Its especially visible in the CentOS world (and its upstream enterprise source system from Red Hat) where packages are quite up-to-date when .0 (dot zero) release is published but are VERY outdated when .8 or .9 incarnation of that release is available. Not to even mention that Firefox for example is released every month …

packages

As I said before when describing the FreeBSD Base System the FreeBSD Ports (and packages built from it available through pkg(8) command) are independent. That means that third party software from FreeBSD Ports is almost always up-to-date (or very close to it). You can even check it on the repology.org site for the details. Below you will find a ‘snapshot’ of the repology.org stats from time of writing this article. The ‘online’ table is very long so I copy/pasted just the systems relevant to the article.

repology

One of the other advantages of FreeBSD Ports is that it offers really MASSIVE amount of software counting 40354 ports when writing this article and still rising. Amount of ready to be installed packages are little smaller with more then 32000 available.

I once migrated for a while to OpenSolaris in 2009 on my Dell Latitude D630 laptop because I really liked all the Solaris features (including ZFS and ZFS Boot Environments that were not available on FreeBSD back then) and the OpenSolaris GNOME based desktop was pretty nice back then even with Time Slider feature for ZFS snapshots in the Nautilus file manager. I got working WiFi connection, sound was working, generally everything on my laptop was supported and working with OpenSolaris … but there was no software. Of course ‘large’ projects like GIMP or OpenOffice was available even in the default pkg(8) repository but not much else. There was less then 4000 packages back then on OpenSolaris while about 25000 packages on FreeBSD if I recall correctly.

You can also easily browse available FreeBSD Ports (and its options) on the web by using the https://freshports.org/ page.

ports-later

The count of FreeBSD Ports is one thing, the features is another. No matter which Linux distribution you are using you will find a software that was compiled and shipped without that needed flag that you desperately need. If you find such software on FreeBSD it ‘hurts’ only for a moment because you can VERY EASILY recompile that software with needed options and replace that ‘default’ package with yours. For example the FreeBSD project is afraid to provide packages of Lame because of existing MP3 patents, so multimedia/ffmpeg package is built without MP3 support (with --disable-libmp3lame flag). That is why I have my own audio/lame and multimedia/ffmpeg packages built with my configure options and that is very easy to achieve. You need to go to the /usr/ports/multimedia/ffmpeg dir type make config and select [x] LAME at the ncurses dialog. Your chosen options will be saved as plain /var/db/ports/multimedia_ffmpeg/options file. If you remove that file (or type make rmconfig) then these custom options will reset to defaults. Then you type make build deinstall install clean and your port with new options is ready and installed as package. Nothing more is needed. You can even lock that package from the pkg(8) upgrades with pkg lock -y ffmpeg command so it will not be modified later but its better to rebuild such packages everytime you do a pkg upgrade procedure because of libraries versions bump and changes. While its very easy and fast to create a script with these commands to make it more automated you can also use other parts of the FreeBSD Ports infrastructure – enter Poudriere (or Synth) – more on that in the next part.

You also do not have to configure each port that way (which could be PITA for large amount of ports) but you may specify your needed (OPTIONS_SET) or unwanted (OPTIONS_UNSET) parameters only once globally using the /etc/make.conf file. You can also specify which default versions of software you want to use, for example Apache 2.2 instead of 2.4 and PHP 7.0 instead of 7.2. You can find all default versions in the /usr/ports/Mk/bsd.default-versions.mk file. Once you setup these options you can build/rebuild or update your packages from FreeBSD Ports by portmaster(8) tool. Like on Gentoo Linux with USE flags. But this is the original. Gentoo took all/most of its ideas from FreeBSD system and its Ports infrastructure.

The Poudriere is a build framework that uses FreeBSD Ports and FreeBSD Jails to build requested packages in clean reproducible way. You can create whole new binary package repository for pkg(8) command to use with it. I mentioned Synth because while Poudriere is often used to produce whole package repository the Synth is usually used just to rebuild several packages that does not fit your needs.

There is one important things about FreeBSD Ports that is often misunderstood by newcomers. What is the difference between the Ports and packages that are fetched and installed by pkg(8) tool? Its quite simple. A package is just a build and installed port. Nothing more or less. When you use the binary packages using pkg(8) command you are using packages that someone (the FreeBSD project in that case) built for you from the FreeBSD Ports in some point in time. While FreeBSD strives to maintain as up-to-date built packages as possible its the nature of FreeBSD Ports that they are always more up-to-date then the built packages. That is why you may build and install a new version of needed packages by yourself using FreeBSD Ports. One may think of such usage when it comes to security holes. When some locally executed commands (like file(1) for example) has a security hole then its not critical for you to update it as fast as possible because that security hole can be harmless for you, but when new version of Firefox fixes very important security hole then its better to update from FreeBSD Ports version faster because waiting 2 days for the package to be built (along with other packages) can be too long.

More on the FreeBSD Ports topic:

Updating/Building from Source

While the FreeBSD Ports infrastructure is for third party software the FreeBSD Base System (or its parts) also can be easily and convenient build from source. The FreeBSD kernel config is also very small and simple. While Linux kernel config contains thousands of options – 4432 for example in the default CentOS 8.2 install the FreeBSD GENERIC config has about 20 times options less – only 260 options. But that does not saturate the topic. You can start with MINIMAL FreeBSD kernel config which has only 75 options specified.

Linux # grep -c '^CONFIG' /boot/config-$( uname -r )
4432

FreeBSD # grep -c -E '^(device|options)' /usr/src/sys/amd64/conf/GENERIC
260

FreeBSD # grep -c -E '^(device|options)' /usr/src/sys/amd64/conf/MINIMAL
75

… and its not only about smaller amount of options. Can you tell my how many steps (and which ones are required) to rebuild CentOS or Ubuntu for example without Bluetooth support?

code

On the contrary its very simple (and fast) on the FreeBSD side. While /etc/make.conf file is used to enable/disable Ports options the /etc/src.conf file is used to enable/disable FreeBSD Base System options while building it from source. To build FreeBSD without Bluetooth support just add WITHOUT_BLUETOOTH=yes to the /etc/src.conf file and type these to build it:

FreeBSD # beadm create safe
FreeBSD # cd /usr/src
FreeBSD # make buildworld kernel
FreeBSD # reboot
FreeBSD # cd /usr/src
FreeBSD # etcupdate -p      # // IN THE PAST: mergemaster -p
FreeBSD # make installworld
FreeBSD # etcupdate -B      # // IN THE PAST: mergemaster -iU
FreeBSD # reboot

Voila! You now have FreeBSD without Bluetooth support … and if any of the steps failed or because of your lack of experience/expertise your FreeBSD system does not boot or is broken you can use tools from /rescue to try to fix it (or at least figure out what is broken) and when you do not want to cope with this jest select safe ZFS Boot Environment at the FreeBSD loader(8) to boot to the system before you started building modified version of FreeBSD. Yes, You are bulletproof here. While having 294 WITHOUT_X options and 125 WITH_X options you can really tune FreeBSD Base System to your needs.

FreeBSD # zgrep -c WITHOUT_ /usr/share/man/man5/src.conf.5.gz
294

FreeBSD # zgrep -c WITH_ /usr/share/man/man5/src.conf.5.gz
125

The big downside of updating FreeBSD by source is that you can not use the freebsd-update tools to do it … but nothing stops you from creating your own FreeBSD Update Server so you will be able to use freebsd-update by adding updates using a CURRENT or STABLE system instead of RELEASE. That process is described in the Build Your Own FreeBSD Update Server article of official FreeBSD documentation.

More on the FreeBSD Source Updates/Builds topic:

Storage

Storage is one of the parts where FreeBSD really shines. Lots of people adore FreeBSD for well integrated ZFS filesystem and its really true. ZFS in FreeBSD has always been first class citizen. Lately OpenZFS 2.0 has been also integrated from the upstream joint FreeBSD and Linux repository. More and more FreeBSD features and solutions are using ZFS features.

openzfs

Most of these people that like integrated ZFS in FreeBSD do not know about the FreeBSD GEOM modular disk transformation framework which provides various storage related features and utilities like software RAID0/RAID1/RAID10/RAID3/RAID5 configurations or transparent encryption of underlying devices with GELI/GDBE (like LUKS on Linux). It also allows transparent filesystem journaling for ANY filesystem with GJOURNAL (yes also for FAT32 or exFAT) or allows one to export block devices over network with GEOM GATE devices (like NFS for block devices).

storage

FreeBSD also has its own FUSE implementation which allows all these FUSE based filesystems to work natively on FreeBSD. While lots of Linux folks know DRBD probably very few of them knew that FreeBSD comes with its own DRBD like solution called HAST – which does exactly the same thing. While ZFS has a lot features and possibilities FreeBSD still maintains and develops fast and small memory footprint UFS filesystem which today is used either with Soft Updates (SU) or Journaled Soft Updates (SUJ) depending on the use case. For example 10 TB data on UFS filesystem with Journaled Soft Updates (SUJ) takes about 1 minute under fsck(8). These storage solutions are available from FreeBSD Base System alone. The FreeBSD Ports offers much more with distributed filesystems solutions such as CEPH, LeoFS, LizardFS or Minio for Amazon S3 compatible storage.

More on the Storage topic:

Init System

FreeBSD offers really simple yet very powerful init system. It has system wide config under /etc/rc.conf file when you can enable/disable needed services with service_enable=YES and service_enable=NO stanzas. You do not even need to launch vi(1) to add them – just type sysrc service_enable=YES and they are added to the /etc/rc.conf file. There are also default values and services that are enabled and you will find them – along with many comments – in the /etc/defaults/rc.conf file. Each FreeBSD service file has PROVIDE/REQUIRE stanzas which are then used to automatically order the services to start. Services that can be run in parallel are started in parallel to save time. For example its pointless to start sshd(8) daemon without network. To start or stop the service you need to type service sshd start or service sshd stop command. But when a service is not enabled in the /etc/rc.conf file then you need to used add onestart and onestop instead. The Base System separation remains here as FreeBSD Base System services are located at /etc/rc.d directory and third party applications from ports/packages are kept under /usr/local prefix which means /usr/local/etc/rc.d dir.

When using systemd(1) you never know how the services gonna start because it will be different each time. Zero determinism. On FreeBSD you know exactly which services will start when because they are always ordered in the same state according to the PROVIDE/REQUIRE stanzas. FreeBSD also offers tools that will tell you the exact order – rcorder(8) – which can be used for all services, Base System services or third party services separately. There is also service -r command that will show you what was the order at the boot time.

FreeBSD # rcorder /etc/rc.d/* | head
/etc/rc.d/growfs
/etc/rc.d/sysctl
/etc/rc.d/hostid
/etc/rc.d/zvol
/etc/rc.d/dumpon
/etc/rc.d/ddb
/etc/rc.d/geli
/etc/rc.d/gbde
/etc/rc.d/ccd
/etc/rc.d/swap

FreeBSD # rcorder /usr/local/etc/rc.d/* | tail
/usr/local/etc/rc.d/hald
/usr/local/etc/rc.d/git_daemon
/usr/local/etc/rc.d/fscd
/usr/local/etc/rc.d/cupsd
/usr/local/etc/rc.d/cups_browsed
/usr/local/etc/rc.d/clamav-clamd
/usr/local/etc/rc.d/clamav-milter
/usr/local/etc/rc.d/clamav-freshclam
/usr/local/etc/rc.d/avahi-dnsconfd
/usr/local/etc/rc.d/aria2

FreeBSD # rcorder /etc/rc.d/* /usr/local/etc/rc.d/* 2> | grep -C 3 sshd
/etc/rc.d/ubthidhci
/etc/rc.d/syscons
/etc/rc.d/swaplate
/etc/rc.d/sshd
/etc/rc.d/cron
/etc/rc.d/jail
/etc/rc.d/localpkg

Adding new service to FreeBSD is also very easy as template for new service is very small and simple.

#!/bin/sh

. /etc/rc.subr

name=dummy
rcvar=dummy_enable

start_cmd="${name}_start"
stop_cmd=":"

load_rc_config $name
: ${dummy_enable:=no}
: ${dummy_msg="Nothing started."}

dummy_start()
{
	echo "$dummy_msg"
}

run_rc_command "$1"

If its not simple enough for you there is dedicated FreeBSD article about writing them – Practical rc.d Scripting in BSD – available here.

More on the Init System topic:

Linux Binary Compatibility

While Linux can not be FreeBSD – the FreeBSD can be Linux – and its not some slow emulation – its implementation of Linux system calls. There was time when enterprises used to work with Linux only applications (not available on FreeBSD by then) using the Linux Binary Compatibility on FreeBSD because it was faster then running them natively on Linux – FreeBSD Used to Generate Spectacular Special Effects – an official FreeBSD Press Release about FreeBSD being used to generate spacial effects to the one of the best movies of all time – The Matrix (1999).

matrix

Today the LINUX_COMPAT is also natively fast and allows one to run Linux applications – even Linux games in X11 with hardware acceleration for graphics. Think of it as WINE but for Linux applications. It lives under /compat/linux directory. It even implements Linux /proc virtual filesystem which can be mounted at the /compat/linux/proc dir but its not mandatory. For any software that does not come with source code and works on Linux the Linux Binary Compatibility saves the day. For example the f.lux project. Before I got to know Redshift I used f.lux Linux binary using LINUX_COMPAT to suppress blue spectrum light from my FreeBSD screen. The Linux Binary Compatibility subsystem can also be used to run Linux bases FreeBSD Jails – with Devuan for example.

More on the Linux Binary Compatibility topic:

Simplicity

FreeBSD is simple but not coarse/ornery. For example as Linux the FreeBSD system also supports the /proc virtual filesystem but on FreeBSD its optional and not used by default while Linux could not live without it. But while Linux has mandatory /proc it also has another virtual filesystem residing under /sys … but why Linux people need two different virtual filesystems with similar purposes? Why they could not create everything under /proc as it already existed. That is big enigma for my sanity.

But /sys is not the end of that madness. Its just a beginning.

What about these?

  • securityfs
  • devpts
  • cgroup
  • pstore
  • bpf
  • configfs
  • selinuxfs
  • systemd-1
  • mqueue
  • debugfs
  • hugetlbfs

Take a look at the FreeBSD mount(8) output after the default install on ZFS.

FreeBSD # mount
zroot/ROOT/12.1 on / (zfs, local, noatime, nfsv4acls)
devfs on /dev (devfs, local, multilabel)
zroot/tmp on /tmp (zfs, local, noatime, nosuid, nfsv4acls)
zroot/var/mail on /var/mail (zfs, local, nfsv4acls)
zroot/usr/home on /usr/home (zfs, local, noatime, nfsv4acls)
zroot/var/crash on /var/crash (zfs, local, noatime, noexec, nosuid, nfsv4acls)
zroot/var/log on /var/log (zfs, local, noatime, noexec, nosuid, nfsv4acls)
zroot/var/audit on /var/audit (zfs, local, noatime, noexec, nosuid, nfsv4acls)
zroot/var/tmp on /var/tmp (zfs, local, noatime, nosuid, nfsv4acls)
zroot/usr/src on /usr/src (zfs, local, noatime, nfsv4acls)
zroot/usr/ports on /usr/ports (zfs, local, noatime, nosuid, nfsv4acls)

Several ZFS datasets and one virtual devfs filesystem for /dev directory. With install on UFS it would be similar with several UFS partitions mounted instead of ZFS datasets.

Take a look at the CentOS 8.2 installation with just one physical root (/) XFS filesystem.

[root@centos8 ~]# mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=919388k,nr_inodes=229847,mode=755)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,seclabel,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime,seclabel)
bpf on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime,mode=700)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,cpuset)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,memory)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,blkio)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,hugetlb)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,net_cls,net_prio)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,cpu,cpuacct)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,freezer)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,perf_event)
cgroup on /sys/fs/cgroup/rdma type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,rdma)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,pids)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,seclabel,devices)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/sda1 on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=34,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=17309)
mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel)
debugfs on /sys/kernel/debug type debugfs (rw,relatime,seclabel)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel,pagesize=2M)
tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=187088k,mode=700)

Fuck me. Its even really hard to just find any REAL filesystem there … fortunately we can ask for only XFS filesystems to display.

[root@centos7 ~]# mount -t xfs
/dev/sda1 on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)

Lets get on the networking now. Lets assume that you want to make standard enterprise networking setup on a physical server with two interfaces aggregated together into highly available interface bond0 (lagg0 on FreeBSD) and then you want to put VLAN tag and IP address on that VLAN. The CentOS 7.x/8.x installer (Anaconda) will welcome you with this mess.

[root@centos7 ~]# ls -1 /etc/sysconfig/network-scripts/ifcfg-*
ifcfg-Bond_connection_1
ifcfg-eno49
ifcfg-eno49-1
ifcfg-eno50
ifcfg-eno50-1
ifcfg-VLAN_connection_1

[root@centos7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-Bond_connection_1
DEVICE=bond0
BONDING_OPTS="miimon=1 updelay=0 downdelay=0 mode=active-backup"
TYPE=Bond
BONDING_MASTER=yes
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_PRIVACY=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME="Bond connection 1"
UUID=ca85417f-8852-43bf-96ee-5bd3f0f83648
ONBOOT=yes

[root@centos7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eno49
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eno49
UUID=2f60f50b-38ad-492a-b90a-ba736acf6792
DEVICE=eno49
ONBOOT=no

[root@centos7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eno49-1
HWADDR=xx:xx:xx:xx:xx:xx
TYPE=Ethernet
NAME=eno49
UUID=342b8494-126d-4f3a-b749-694c8c922aa1
DEVICE=eno49
ONBOOT=yes
MASTER=bond0
SLAVE=yes

[root@centos7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eno50
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eno50
UUID=4fd36e24-1c6d-4a65-a316-7a14e9a92965
DEVICE=eno50
ONBOOT=no

[root@centos7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eno50-1
HWADDR=xx:xx:xx:xx:xx:xx
TYPE=Ethernet
NAME=eno50
UUID=a429b697-73c2-404d-9379-472cb3c35e06
DEVICE=eno50
ONBOOT=yes
MASTER=bond0
SLAVE=yes

[root@centos7 ~]# cat/etc/sysconfig/network-scripts/ifcfg-VLAN_connection_1
VLAN=yes
TYPE=Vlan
PHYSDEV=ca85417f-8852-43bf-96ee-5bd3f0f83648
VLAN_ID=601
REORDER_HDR=yes
GVRP=no
MVRP=no
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
IPADDR=10.20.30.40
PREFIX=24
GATEWAY=10.20.30.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_PRIVACY=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME="VLAN connection 1"
UUID=90f7a9bb-1443-4adf-a3eb-86a03b23ecfb
ONBOOT=yes

For the record – I have chosen ‘STATIC’ IPv4 address but installer made these interfaces to use DHCP and that STATIC address. That could be a bug but lets get to the point.

After manual fixing with vi(1) (and hour later) this is how it supposed to look.

[root@centos7 ~]# cat /etc/sysconfig/network
GATEWAY=10.20.30.1
NOZEROCONF=yes

[root@centos7 ~]# ls -1 /etc/sysconfig/network-scripts/ifcfg-*
ifcfg-bond0
ifcfg-bond0.601
ifcfg-eno49
ifcfg-eno50

[root@centos7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BONDING_OPTS="miimon=1 updelay=0 downdelay=0 mode=active-backup"
TYPE=Bond
BONDING_MASTER=yes
BOOTPROTO=none
IPV4_FAILURE_FATAL=no
IPV6INIT=no
ONBOOT=yes

[root@centos7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0.601
VLAN=yes
TYPE=Vlan
VLAN_ID=601
DEVICE=bond0.601
REORDER_HDR=yes
GVRP=no
MVRP=no
BOOTPROTO=none
IPADDR=10.20.30.40
PREFIX=24
IPV4_FAILURE_FATAL=no
IPV6INIT=no
ONBOOT=yes

[root@centos7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eno49
BOOTPROTO=none
IPV4_FAILURE_FATAL=no
IPV6INIT=no
TYPE=Ethernet
NAME=eno49
DEVICE=eno49
ONBOOT=yes
MASTER=bond0
SLAVE=yes

[root@centos7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eno50
BOOTPROTO=none
IPV4_FAILURE_FATAL=no
IPV6INIT=no
TYPE=Ethernet
NAME=eno50
DEVICE=eno50
ONBOOT=yes
MASTER=bond0
SLAVE=yes

Better … but still takes A LOT OF SPACE and several files to cover that quite simple setup. Not to mention its level of complication and making that very error prone way. The same configuration on FreeBSD would take just 7 lines within single /etc/rc.conf file as shown below.

FreeBSD # cat /etc/rc.conf
ifconfig_fxp0="up"
ifconfig_fxp1="up"
cloned_interfaces="lagg0"
ifconfig_lagg0="laggproto failover laggport fxp0 laggport fxp1"
vlans_lagg0="601"
ifconfig_lagg0_601="inet 10.20.30.40/24"
defaultrouter="10.20.30.1"

But that are not all the complications. In the past you could restart the network configuration on RHEL/CentOS/Rocky/… with simple service network restart command … not anymore. Now it will not work and you need to type two commands. They are nmcli networking off followed by nmcli networking on command … and to make sure that the second one will be executed and you will not loose the networking connection before executing it You need to type them one after another inside screen(1) or tmux(1) terminal multiplexer. Convenient as fuck ๐Ÿ™‚

What about the boot process? FreeBSD boots from root on ZFS partition with just small 512 KB not mountable partition. No separate /boot device is needed. On the other side Linux always needs that separate /boot partition filled with GRUB modules. No matter if its ZFS or LVM. That is why implementation of ZFS Boot Environments is quite complicated on Linux because even if you have root on ZFS on a Linux system there is still unprotected /boot filesystem that can not be snapshoted with ZFS and has to be protected in old classic way which kill the idea of ZFS Boot Environments or Linux.

FreeBSD is really simple and well thought operating system. But also a very underestimated one.

Evolution Instead Rewriting

How many Linux tools or subsystems are abandoned or superseded by new ones? Why the ifconfig(8) command was not updated with new options and instead a new ip(8) command was introduced? Same with netstat(8) being replaced by ss(8). Same with arp(8)/iwconfig/route(8) and many more. What about whole init system? The Linux world has been taken over by systemd(1) whenever you like it or not. Even distributions that have grown their mature init systems like Ubuntu with its Upstart has moved to systemd(1) altogether. The distributions that do not use it are very few and considered a niche today.

evolution

In the FreeBSD land on the contrary such things happen only if there is no other way to implement new things. Its the last thing wanted in the FreeBSD. FreeBSD evolves and is developed with stability and backward compatibility in mind. Userland tools are grown and updated with new options instead of rewriting them over and over again. Not to mention how many new bugs are introduced by changing one tool to another.

More on the Evolution Instead Rewriting topic:

Documentation

Having system that can do almost anything but not knowing how to do that makes that system pretty useless (or at least pretty PITA to use). FreeBSD offers second to none documentation that is actively maintained and updated. Along with its legendary FreeBSD Handbook and FreeBSD FAQ the FreeBSD project also offers official FreeBSD Articles about various FreeBSD topics. The Man Pages are also very detailed and contain many examples. There is also FreeBSD Wiki page for work in progress documentation and ideas related to FreeBSD development and if you have any problems or questions related to FreeBSD there are official FreeBSD Forums and oldschool Mailing Lists available.

documentation

These were only the official project knowledge sources but there are also lots of FreeBSD books. You may also check my dedicated FreeBSD Books article for more in depth look about available FreeBSD books. Here are the best and up-to-date ones.

  • Absolute FreeBSD – Complete Guide to FreeBSD – 3nd Edition (2019)
  • Beginning Modern Unix (2018)
  • Book of PF – 3rd Edition (2015)
  • Design and Implementation of FreeBSD 11 Operating System – 2nd Edition (2015)
  • FreeBSD Device Drivers (2012)
  • FreeBSD Mastery – ZFS (2015)
  • FreeBSD Mastery – Advanced ZFS (2016)
  • FreeBSD Mastery – Storage Essentials (2014)
  • FreeBSD Mastery – Specialty Filesystems (2015)
  • FreeBSD Mastery – Jails (2019)

There are also two magazines that are dedicated to BSD and FreeBSD systems. Both are free and cover lots of interesting topics regarding FreeBSD.

With all this knowledge and support its really hard not to achieve what you need/want with FreeBSD system.

Community

Last but not least and I would say its even more important then good documentation (which FreeBSD has awesome). People that use FreeBSD do that consciously and are often experienced not only in FreeBSD land but also in topics related to other UNIX systems. Often they took long road of first using the Linux systems before finally setting on the FreeBSD land or they still do Linux administration for a living while resting using far more reasonable and sensible FreeBSD solution. I always find FreeBSD Community helpful and friendly. Always willingly helpful – especially towards newcomers. Even when you try to ‘force’ FreeBSD people to ‘fight’ in unjust/doubtful discussion they will reply with dignity and technical arguments instead of yelling at you.

The FreeBSD project even made several articles and Handbook chapters especially for Linux newcomers – or sometimes called systemd(1) refugees.

Closing Thoughts

I tried really hard to not make it a Linux rant but some may feel it that way – if so please remember that this was not my intention. FreeBSD like Linux and like any other operating system has its ups and downs. Hope that I showed you most interesting FreeBSD parts. I may add new sections here without a warning in the future ๐Ÿ™‚

External Discussions

Discussions and comments from ‘external’ sources are available here:

EOF