M2.NVM disk + PCI-E controller on FreeBSD

Modern laptops are quite expensive and hard to upgrade. While they are really handy to work in multiple places, they are not that efficient for advanced R&D activities like virtualization and massive software development combined (I/O speeds highly affects overall performance and compilation times). I was wondering if M2.NVM disk over PCI-E controller could work with my old desktop workstation giving additional performance benefit over standard onboard SATA attached SSD drive.

Old desktop PC only supports SATA drives. Switching to SATA SSD (electronics NAND Flash based Solid State Drive) in place of conventional HDD (mechanical drive) can boost I/O performance noticeably. We had 3.5″ (desktop) and 2.5″ (laptop) physical disk dimensions available so far. But new M2 SSD drives showed up, founding a new standard, with smaller form factor to be installed in embedded systems and lightweight laptops. M2 defines only a physical dimensions requirements, while disk itself can implement SATA (with average 500MB/s read/write speed) or NVM (with average 3000MB/s read/write speeds or better) interface.

So I have decided to try M2.NVM Samsung SSD 980 1TB drive over ICYBOX IB-PCI224M2-ARGB PCI-E 4.0 controller on my ASUS M5A97 R2.0 (last available BIOS 2603) that only supports PCI-E 2.0. I have several internal and external SSD SATA drives both in 2.5″ and M2 form factor. Having even basic M2.NVM drive over PCI-E controller seems to be more future proof purchase, for the same amount of money, it will be ready for possible motherboard replacement, and in bay benefit in additional performance gain over onboard SATA attached SSD drive. Operating system is Open-Source FreeBSD Unix version 13-STABLE, filesystem is ZFS (testing done with no compression and no encryption).

It turns out that PCI-E 4.0 card can work on older PCI-E 2.0 bus (for sure speed will be degraded in that case). Mainboard BIOS does not see the NVM controlleri in UEFI mode (TODO) so it is not possible to boot out of it without additional SATA drive with the FreeBSD bootloader / kernel first (TODO). FreeBSD can see and utilize both PCI-E Controller and the M2.NVM drive with no problem. Let’s see the data transfer speed results in numbers.

Average in-filesystem StressDisk large file write speed results:

  • Onboard SATA 2x WDEARS RED 2TB ZFS RAID0 STRIPE: 188MB/s.
  • PCI-E ICYBOX M2.NVM Samsung SSD 980 1TB ZFS: 410MB/s.

DiskInfo single drive summary results:

  • PCI-E ICYBOX M2.NVM Samsung SSD 980 1TB ZFS: O:1087557, M:1099090, I:1160432 kbytes/sec
  • Onboard SATA 3.5″ 2TB 5400RPM HDD WD20EFRX (RED):O:146521, M:116847, I:70159 kbytes/sec
  • Onboard SATA 3.5″ 2TB 5400RPM HDD WDEARS (GREEN): O:113811, M:87543, I:49209 kbytes/sec
  • External USB3.1 M2.SATA SSD disk enclosure: O:31503, M:31850, I:31900 kbytes/sec.

As we can see above, from user perspective in out-of-the-box configuration write speeds are 218% faster on NVM SDD over HDD RAID for large files (this may need some filesystem tuning). Weighted average disk access for NVM SSD is 1 115 693 KB/s, WD20EFRX is 111 176 KB/s, WDEARS is 83 521 KB/s. It turns out that WD RED HDD disks are 133% faster than WD GREEN HDD disks, while NVM SSD disks are over 1000% faster than WD HDD RED disks. On the other hand external USB 3.1 M2.SATA SSD disk has average 47 626 KB/s results. One last but crucial test will be added here containing the onboard SATA SSD drive, just to make sure and prove NVM dominance over SATA.

DiskInfo result for single 3.5″ 2TB 5400RPM HDD WDEARS (GREEN Series) drive attached to onboard SATA controller:

# diskinfo -tv /dev/ada2
/dev/ada2
        512             # sectorsize
        2000398934016   # mediasize in bytes (1.8T)
        3907029168      # mediasize in sectors
        4096            # stripesize
        0               # stripeoffset
        3876021         # Cylinders according to firmware.
        16              # Heads according to firmware.
        63              # Sectors according to firmware.
        WDC WD20EARS-00MVWB0    # Disk descr.
        XXX             # Disk ident.
        ahcich4         # Attachment
        No              # TRIM/UNMAP support
        Unknown         # Rotation rate in RPM
        Not_Zoned       # Zone Mode

Seek times:
        Full stroke:      250 iter in   7.135585 sec =   28.542 msec
        Half stroke:      250 iter in   5.288793 sec =   21.155 msec
        Quarter stroke:   500 iter in   7.540787 sec =   15.082 msec
        Short forward:    400 iter in   3.036829 sec =    7.592 msec
        Short backward:   400 iter in   2.956946 sec =    7.392 msec
        Seq outer:       2048 iter in   0.254515 sec =    0.124 msec
        Seq inner:       2048 iter in   0.199511 sec =    0.097 msec

Transfer rates:
        outside:       102400 kbytes in   0.899735 sec =   113811 kbytes/sec
        middle:        102400 kbytes in   1.169709 sec =    87543 kbytes/sec
        inside:        102400 kbytes in   2.080911 sec =    49209 kbytes/sec

DiskInfo result for single 3.5″ 2TB 5400RPM HDD WD20EFRX (RED Series) drive attached to onboard SATA controller:

# diskinfo -tv /dev/ada0
/dev/ada0
        512             # sectorsize
        2000398934016   # mediasize in bytes (1.8T)
        3907029168      # mediasize in sectors
        4096            # stripesize
        0               # stripeoffset
        3876021         # Cylinders according to firmware.
        16              # Heads according to firmware.
        63              # Sectors according to firmware.
        WDC WD20EFRX-68EUZN0    # Disk descr.
        XXX             # Disk ident.
        ahcich0         # Attachment
        No              # TRIM/UNMAP support
        5400            # Rotation rate in RPM
        Not_Zoned       # Zone Mode

Seek times:
        Full stroke:      250 iter in   6.653120 sec =   26.612 msec
        Half stroke:      250 iter in   5.172312 sec =   20.689 msec
        Quarter stroke:   500 iter in   7.808667 sec =   15.617 msec
        Short forward:    400 iter in   2.082164 sec =    5.205 msec
        Short backward:   400 iter in   3.350534 sec =    8.376 msec
        Seq outer:       2048 iter in   0.141464 sec =    0.069 msec
        Seq inner:       2048 iter in   0.139262 sec =    0.068 msec

Transfer rates:
        outside:       102400 kbytes in   0.698874 sec =   146521 kbytes/sec
        middle:        102400 kbytes in   0.876360 sec =   116847 kbytes/sec
        inside:        102400 kbytes in   1.459537 sec =    70159 kbytes/sec

DiskInfo result for single M2.NVM Samsung SSD 980 1TB drive attached to ICYBOX IB-PCI224M2-ARGB PCI-E 4.0 controller working on PCI-E 2.0 capable motherboard:

# diskinfo -tv /dev/nvd0
/dev/nvd0
        512             # sectorsize
        1000204886016   # mediasize in bytes (932G)
        1953525168      # mediasize in sectors
        4096            # stripesize
        0               # stripeoffset
        Samsung SSD 980 1TB     # Disk descr.
        XXX             # Disk ident.
        nvme0           # Attachment
        Yes             # TRIM/UNMAP support
        0               # Rotation rate in RPM

Seek times:
        Full stroke:      250 iter in   0.008369 sec =    0.033 msec
        Half stroke:      250 iter in   0.005510 sec =    0.022 msec
        Quarter stroke:   500 iter in   0.014519 sec =    0.029 msec
        Short forward:    400 iter in   0.010368 sec =    0.026 msec
        Short backward:   400 iter in   0.020456 sec =    0.051 msec
        Seq outer:       2048 iter in   0.032788 sec =    0.016 msec
        Seq inner:       2048 iter in   0.032863 sec =    0.016 msec

Transfer rates:
        outside:       102400 kbytes in   0.094156 sec =  1087557 kbytes/sec
        middle:        102400 kbytes in   0.093168 sec =  1099090 kbytes/sec
        inside:        102400 kbytes in   0.088243 sec =  1160432 kbytes/sec

DiskInfo resuls for USB 3.1 M2.SATA SSD disk enclosure:

 # diskinfo -tv /dev/da0
/dev/da0
        512             # sectorsize
        256060514304    # mediasize in bytes (238G)
        500118192       # mediasize in sectors
        4096            # stripesize
        0               # stripeoffset
        31130           # Cylinders according to firmware.
        255             # Heads according to firmware.
        63              # Sectors according to firmware.
        USB3.1          # Disk descr.
        XXX             # Disk ident.
        umass-sim0      # Attachment
        No              # TRIM/UNMAP support
        Unknown         # Rotation rate in RPM
        Not_Zoned       # Zone Mode

Seek times:
        Full stroke:      250 iter in   0.096377 sec =    0.386 msec
        Half stroke:      250 iter in   0.099408 sec =    0.398 msec
        Quarter stroke:   500 iter in   0.216023 sec =    0.432 msec
        Short forward:    400 iter in   0.190744 sec =    0.477 msec
        Short backward:   400 iter in   0.203053 sec =    0.508 msec
        Seq outer:       2048 iter in   0.769551 sec =    0.376 msec
        Seq inner:       2048 iter in   0.769675 sec =    0.376 msec

Transfer rates:
        outside:       102400 kbytes in   3.250481 sec =    31503 kbytes/sec
        middle:        102400 kbytes in   3.215029 sec =    31850 kbytes/sec
        inside:        102400 kbytes in   3.210055 sec =    31900 kbytes/sec

FreeBSD single user remount / rw

If you are using UFS you can remount the root while in single mode with

mount -u w /

If you are using ZFS you can remount the root while in single mode with

zfs set readonly=off zroot

Note: With ZFS there is no need to turn back readonly=on as this will keep read-only flag while in userland mode :-)

BSD Chromium Audio/Mic

If you encounter a problem with microphone in Chromium on FreeBSD (and other *BSD), this is because it uses sndio audio backend and probably default microphone is not the one you want to use. In my case /dev/dsp0 is the HDMI input/output thus no audio input. There is no need to start system wide sndiod. You can use environment variables in ~/.profile to control audio input/output for the local spawning sndio client:

  • export AUDIODEVICE="rsnd/4" sets default input/output device to /dev/dsp4.
  • export AUDIORECDEVICE="rsnd/3" sets default input device to /dev/dsp3.
  • export AUDIOPLAYDEVICE="rsnd/2" sets default output device to /dev/dsp2.

You can simply set AUDIODEVICE="rsnd/4" to switch default input and output device, and/or AUDIORECDEVICE="rsnd/3" to change default microphone source. If you want to have choice to switch between several devices on the fly you will need to use sndiod and provide set of devices with -f flag. See sndio [1] and sndiod [2] man pages for more information.
[1] https://man.openbsd.org/sndio.
[2] https://man.openbsd.org/sndiod

FreeBSD + Zephyr RTOS + ESP32

FreeBSD can natively emulate Linux ELF binaries. You can now bootstrap Linux espressif xtensa toolchain for ESP32 on FreeBSD under The Zephyr Project with west espressif install :-)
https://github.com/espressif/esp-idf/pull/7226#event-5064755416

Why Linux Sux?

Imagine you have a disk full of your precious data that you want to mount to a new Ubuntu Linux system and add user to match the existing home directory.

# adduser user
Adding user `user' ...
Adding new group `user' (1000) ...
Adding new user `user' (1000) with group `user' ...
Creating home directory `/home/user' ...
Stopped: Couldn't create home directory `/home/user': File exists.

Removing directory `/home/user' ...
Removing user `user' ...
Removing group `user' ...
groupdel: group 'user' does not exist
adduser: `groupdel user' returned error code 6. Exiting.

Now you can say your all precious data goodbye. No questions asked. Core Linux utility adduser just found your existing data and erased them without even asking. The years is 2021 (30 years since Linux was created).

This is why for over 15 years I am only working with BSD Operating Systems [1] [2] [3] [4]. Its Open-Source with long-term maintenance and self-compatibility in mind.  BSD license is even more liberal than GPL for your products [5]. You should try BSD too :-)

[1] https://www.freebsd.org/
[2] https://www.openbsd.org/
[3] https://netbsd.org/
[4] https://www.dragonflybsd.org/
[5] https://en.wikipedia.org/wiki/List_of_products_based_on_FreeBSD

Synaptics TouchPad on Panasonic CF-MX4

This wulf7 [1] is a really nice guy that helped me run full featured Synaptics TouchPad with FreeBSD on Panasonic Toughbook CF-MX4 [2][3]. Now it works for moused and libinput with all multitouch gestures like two or three finger scroll, scale, etc! The problem was in detection mechanism as device is connected over multiplexer with both PS/2 and SMBus but multitouch works only over SMBus. Although fix requires change and rebuild of FreeBSD Kernel I hope it gets quickly to the upstream [4]. I had a chance to exercise building whole FreeBSD distribution into the USB memstick image, so I could test driver fix on a target computer without even touching its hard drive contents :-)

/* psm has a special support for GenMouse + SynTouchpad combination */
if (active_ports_count >= 2) {
    for (port = 0; port < KBDC_AUX_MUX_NUM_PORTS; port++) {

That 2 above had to be changed into 1 in /usr/src/sys/dev/atkbdc/psm.c. Nice? That’s what I call a one-bit-fix :-)

In addition, when you work with Synaptics Touchpad in Xorg and you want to use its all features like tap-to-click, natural (swapped) two finger scroll, two and three finger gestures, don’t use moused,xmodmap, or xinput as this will produce inconsistent behavior in applications based on different toolkits (i.e. GTK will scroll up while Qt will scroll down etc), instead use the new way of input based on libinput and modify MatchIsTouchpad section of /usr/local/share/X11/xorg.conf.d/40-libinput.conf like:

Section "InputClass"
        Identifier "libinput touchpad catchall"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event5"
        Option "NaturalScrolling" "on"
        Option "Tapping" "on"
        Option "ClickMethod" "clickfinger"
        Driver "libinput"
EndSection

[1] https://github.com/wulf7/iichid
[2] https://github.com/wulf7/iichid/issues/51
[3] https://github.com/wulf7/iichid/issues/53
[4] https://reviews.freebsd.org/D28502

LimeSuite on FreeBSD

I have ported LimeSuite [1] to FreeBSD [2]. You can now work with LimeSDR [3] / LimeSDR-Mini [4] and others on my favourite OS. Please visit MyriadRF [5] for various radio inspirations. Have fun! :-)

[1] https://github.com/myriadrf/LimeSuite
[2] https://www.freebsd.org/
[3] https://limemicro.com/products/boards/limesdr/
[4] https://limemicro.com/products/boards/limesdr-mini/
[5] https://myriadrf.org/

Mounting external ZFS volume

If you need to perform a data recovery from an external ZFS [zfs] volume you may find those hinds helpful:

  1. Attach encrypted partition where ZFS pool resides with:
    geli attach /dev/your_device_partition
  2. Import ZFS pool at given mountpoint (/mnt/zfs):
    zpool import -af -R /mnt/zfs
  3. Modify mount point location for a given dataset that may have mountpoint set to none what marks it as no mount (note this mountpoint will append to parent mount point location):
    zfs set mountpoint=ROOT zroot/ROOT/default
  4. Mount and mount all pool datasets:
    zfs mount -a
    zfs umount -a
  5. Mount/umount given dataset:
    zfs mount zroot/ROOT/default
  6. You can verify if your ZFS pool is active with:
    zpool status
  7. You can see what ZFS datasets are available with mount points with:
    zfs list

[zfs] https://www.freebsd.org/doc/handbook/zfs.html

ZFS on SSD CAM/CRC errors

If you encounter lots of CAM/CRC errors when using encrypted ZFS on some SSD drives on FreeBSD, that is caused by TRIM. You need to disable it in boot loader prompt or add below line to /boot/loader.conf:

vfs.zfs.trim.enabled=0

Added GOBI2000 support to FreeBSD U3G

I have added support for Panasonic ToughBook CF-F9 U3G GOBI2000 to FreeBSD U3G kernel module [1]. I have added firmware for Panasonic CF-F9 and HP EliteBook 2740p along with gobi_loader updates [2] that are required for 3G modems to work.

At first U3G module will create /dev/cuaU0 interface for QDL firmware load, then after successful firmware load device will reload itself to a modem mode and U3G module will provide additional /dev/cuaU0.* nodes for operations (/dev/cuaU0.2 is the AT command intarface).

In order for this modem to work on FreeBSD you also need to tune some configutation files:

  • /etc/devd.conf:
    attach 100 {
     match "vendor" "0x04da";  #adjust your device VID
     match "product" "0x250e"; #adjust your device PID
     action "/usr/local/sbin/gobi_loader -2000 /dev/cuaU0 /boot/firmware/gobi/";
    };
    
  • /etc/ppp/ppp.conf:
    default:
     set log Phase Chat LCP IPCP CCP tun command
     ident user-ppp VERSION
     set device /dev/cuaU0.2
     set phone *99\#
     set redial 5 10
     set speed 115200
     set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \
               \"\" AT AT-OK-AT ATH OK ATZ OK ATE1Q0 OK \
               AT+CFUN=1 OK-AT-OK \
               AT+CPIN? READY-AT+CPIN=\"YOUR_PIN_HERE\"-OK \
               AT+CGDCONT=1,\\\"ip\\\",\\\"internet\\\" OK \
               \\dATDT\\T TIMEOUT 40 CONNECT"
     set timeout 20
     enable dns
     set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.255 0.0.0.0
     add default HISADDR
    

You now should be able to use your 3G modem connection with ppp -ddial, after you add your local user to the dialer group with pw groupmod dialer -m your_user_name. Remember to have U3G compiled in. Enjoy the Internets! :-)

[1] https://github.com/freebsd/freebsd/pull/115
[2] https://github.com/cederom/gobi_loader

Docker and Travis are Linux only solutions

If you wonder to use Docker [1] or Travis CI [2] for build test or more advanced automation, note that these are Linux [3] only solutions and will not work with other operating systems such as FreeBSD [4]. You may want to take a look at old good Jenkins [5] for wider application possibilities :-)

[1] https://www.docker.com/
[2] https://travis-ci.org/
[3] https://www.linux.com/
[4] https://www.freebsd.org/
[5] https://jenkins.io/

FreeBSD PXE Network Install

Sometimes you need to perform a network installation (i.e. when no USB or DVD drive is allowed to boot, but you can boot PXE). In case of FreeBSD you can use DNSMASQ to serve the DHCP that will assign the initial client address and configuration along with PXE boot image served over tFTP. At this point you will have bootloader running, so you can serve filesystem over NFS to obtain working environment and/or the installer..

  • Create a directory that will hold the target filesystem over network. In my case that was
    /usr/local/tftp/FreeBSD
  • Put OS/Installer files inside above directory
    cd /usr/local/tftp/FreeBSD
    wget http://(..)/file.iso
    7z x file.iso
  • Edit /etc/exports to export the filesystem over NFS
    /usr/local/tftp/FreeBSD -ro -alldirs -network 192.168.0.0
  • Install the dnsmasq
    pkg install dnsmasq
  • Setup the /usr/local/etc/dnsmasq.conf
    enable-tftp
    tftp-root=/usr/local/tftp/FreeBSD
    
    dhcp-range=192.168.0.50,192.168.0.60,255.255.255.0,1h
    dhcp-boot=boot/pxeboot
    dhcp-option=option:router,
    dhcp-option=option:root-path,/usr/local/tftp/FreeBSD
    
  • Restart services
    service nfsd onerestart
    service dnsmasq onerestart
  • In case you get bootloader running but troubles with NFS make sure that mountd is running. Also you can see who is using the NFS shares with
    showmount -a

PXE Boot always use initial DHCP/tFTP to fetch configuration and bootloader, so the first stage is similar and should work with other Operating Systems and Bootloaders as well, the rest is up to bootloader itself..

FreeBSD Synaptics Trackpad/Touchpad

Use advanced features of your Synaptics Trackpad on a laptop running FreeBSD [1] with:

  • set in /boot/loader.conf:
    hw.psm.synaptics_support="1"
  • set in /etc/rc.conf:
    moused_enable="YES"
  • set in /etc/X11/xorg.conf:
    Section "InputDevice"
        Identifier      "Mouse0"
        Driver          "mouse"
        Option          "Protocol"      "auto"
        Option          "Device"        "/dev/sysmouse"
        Option          "ZAxisMapping"  "4 5 6 7"
    EndSection

If you want to have “MacBook” like two-finger scrolling along with other parameters you can set in /etc/sysctl.conf:

hw.psm.synaptics.min_pressure=16
hw.psm.synaptics.max_pressure=220
hw.psm.synaptics.max_width=10

hw.psm.synaptics.vscroll_hor_area=1300
hw.psm.synaptics.vscroll_ver_area=-600
hw.psm.synaptics.vscroll_min_delta=50
hw.psm.synaptics.vscroll_div_min=100
hw.psm.synaptics.vscroll_div_max=150

hw.psm.synaptics.weight_current=3
hw.psm.synaptics.weight_previous=6
hw.psm.synaptics.weight_previous_na=20
hw.psm.synaptics.weight_len_squared=2000

hw.psm.synaptics.div_min=9
hw.psm.synaptics.div_max=17
hw.psm.synaptics.div_max_na=30
hw.psm.synaptics.div_len=100

hw.psm.synaptics.margin_top=200
hw.psm.synaptics.margin_right=200
hw.psm.synaptics.margin_bottom=200
hw.psm.synaptics.margin_left=200

hw.psm.synaptics.window_min=4
hw.psm.synaptics.window_max=10
hw.psm.synaptics.multiplicator=10000

[1] https://wiki.freebsd.org/SynapticsTouchpad

FreeBSD NTFS FUSE FSTAB

If you want to use NTFS volumes on FreeBSD [1], you need to use FUSE infrastructure andNTFS-3G [2] port. Syntax of fstab is a bit differen in this case:

/dev/ntfs_partition /mnt/ntfs_mounpoint fuse rw,locale=pl_PL.UTF8,mountprog=/usr/local/bin/ntfs-3g 0 0

Also remember to put fuse_load=”YES” in /boot/loader.conf and install the sysutils/fusefs-ntfs port. Do not use hibernated volumes.

[1] https://www.freebsd.org
[2] https://www.freshports.org/sysutils/fusefs-ntfs

FreeBSD on a Hybrid Graphics Laptop

If you happen to get a nice laptop with a powerful graphics card, such as polish HYPERBOOK SL502VR [1], it is highly probable that you will use UEFI boot mode. In that case you need to use SCFB [2] driver instead of VESA. Use the xf86-video-scfb package to get Xorg running.

Hybrid Graphics at first used MUX device that did a LCD connect to a selected video card on boot. Nowadays both cards use common Video Framebuffer [3] to draw over a screen. The simple video card (Intel in my case) is always active, while the more powerful and power consuming video card is started on-demand (nVidia in my case). This however requires a dedicated DMA BUF implementation, which is not yet available on FreeBSD, so none of the cards can see any monitor connected, resulting in “No Screens Found Error” from Xorg.

I have already reported a bug/feature request to nVidia. Also developers of FreeBSD are working on the Hybrid Graphics implementation.

[1] http://sklep.hyperbook.pl/hyperbook-sl502-vr-p651rp6g-gtx-1060-p-25965.html
[2] https://wiki.freebsd.org/Graphics/SCFB
[3] https://en.wikipedia.org/wiki/Framebuffer

FreeBSD Port devel/protobuf3

Created a FreeBSD Port for Google Protobuf version 3.1.0 :-)

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214957

FreeBSD DHCP Client options

My request for base DHCP Client options parsing was partially implemented.

HackRF(One) on FreeBSD

My port of HackRF has been committed. Enjoy your HackRF One SDR on FreeBSD OS! =)

RAID HDD and UEFI BIOS

If you want to build your own disk array, let’s say RAID, on your computer to increase disk space and efficiency, you should know about few important things in general:

  • You can consider MBR and x86 obsolete. New way is GPT, UEFI, AMD64.
  • Large RAID arrays (over 2TB) will not work with older hardware and OS (except FreeBSD) due to architecture limitations.
  • To use large RAID volumes you must use GPT partition scheme. MBR will not do the job.
  • Some systems can use GPT only with UEFI BIOS (i.e. Windows works with GPT only via UEFI). You may be forced to buy new motherboard.
  • UEFI and GPT is totally different way of bootstrap so you can forget what you know about BIOS and MBR here.
  • Hard Drives have hidden corruption-fix mechanisms in firmware that will make your RAID array fail to operate. For RAID choose dedicated drives such as WD RED (not Green, not Black, not Blue).

In order to use GPT and UEFI I have replaced my nice ASUS M4A88TD-V EVO/USB3 motherboard with M5A97 R2.0 only because M4 series did not support UEFI. New BIOS is totally different, but I am not really sure if replacing the hardware was mandatory..

Summing up, if you want to use large RAID volumes make sure first that you can use GPT and UEFI BIOS is present on your AMD64 hardware. If not, still you can use the FreeBSD as it knows how to bypass some limitations. Also remember to use dedicated HDD for RAID operations.

FreeBSD sFTP SSHD chroot nologin

There are situations when you have a nice server out there, and you want/need someone to upload important files, but you only want to give them a minimal access to the system. You can use SSHD with sFTP and /sbin/nologin shell for that in chroot environment (dedicated limited userspace). Note that SCP in fact requires a working shell, so you need to use sFTP in this case..

Create a new user account with existing ftp group and /sbin/nologin shell:

# adduser

Alternatively you can modify an existing account to share:

# pw groupmod ftp -m username
# pw usermod username -s /sbin/nologin

You need to set correct permissions to the user home directory and public directory inside for upload:

# chown root:wheel /home/username
# mkdir /home/username/public
# chown username:ftp /home/username/public

Now modify the SSHD server configuration file /etc/ssh/sshd_config and append:

Match Group ftp
        ChrootDirectory         /home/%u
        ForceCommand            internal-sftp
        AllowTcpForwarding      no
        PermitTunnel            no
        X11Forwarding           no

Remember to restart the SSHD in order to apply new configuration:

# service sshd restart

Once the account is not necessary anymore remember to remove it:

# pw userdel username

FreeBSD + PPP + GSM/3G/LTE Modem

If you want to use GSM/3G/LTE modem on your FreeBSD box you need to use PPP and following configuration:

default:
 set log Phase Chat LCP IPCP CCP tun command
 ident user-ppp VERSION 
 set device /dev/cuaU0
 set phone *99\#
 set redial 5 10
 set speed 115200
 set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \
           \"\" ATH OK ATZ OK AT OK-AT-OK ATE1Q0 OK \
           AT+CFUN=1 OK-AT-OK \
           AT+CPIN? READY-AT+CPIN=\"1234\"-OK \
           AT+CGDCONT=1,\"ip\",\"internet\" OK \
           \\dATDT\\T TIMEOUT 40 CONNECT"
 set timeout 10
 enable dns
 set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.255 0.0.0.0
 add default HISADDR

Heimdall on FreeBSD

Heimdall is an Open-Source utility to work with Android devices manufactured by Samsung. It allows to flash firmware components into memory via FastBoot/ODIN+USB. I have created a patch to build this nice tool on FreeBSD OS (QT gui works as well, to build it you need qt-{gui,qmake,uic,moc,rcc,…} packages installed). When patch is included into the project sources and release is done, I will prepare a FreeBSD port for this nice utility which is only missing a memory dump and live boot to be totally perfect :-)

Read More

OpenOCD on FreeBSD

My port of OpenOCD has just been committed. Enjoy Open On-Chip-Debugger on FreeBSD! =)