Using iSCSI from Ubuntu 19.04

Samba has taken over most of my sharing but I still occasionally need iSCSI. Connecting to it from Ubuntu is straight enough. First step is of course installing necessary package:

sudo apt-get install open-iscsi

Next step is simply connecting to iSCSI and discovering the drive name within dmesg output:

sudo iscsiadm -m discovery -t sendtargets -p ^^192.168.1.1^^
 192.168.1.1:3260,1 iqn.2007-09.jp.ne.peach.istgt:somedisk0

sudo iscsiadm --mode node --targetname iqn.2007-09.jp.ne.peach.istgt:^^somedisk0^^ \
    --portal ^^192.168.1.1^^:3260 --login

sudo dmesg | grep "Attached SCSI disk" | tail -1
 [ 3203.813577] sd 2:0:0:0: [^^sda^^] Attached SCSI disk

Lastly, just use the normal mounting to access the disk:

sudo mkdir /mnt/scsi
sudo mount /dev/sda2 /mnt/iscsi

.NET Core 3.0

.NET Conf 2019 had one significant news this year - .NET Core 3.0.

The biggest feature for me is self-contained executable. It’s not ideal as actual package is unpacked upon the first execution but it’s definitely a step in the right direction.

Other feature I am excited about is HTTP/2 combined with TLS 1.3. Not only performant but also secure. Frankly, this almost makes me yearn for making my own CMS again. Almost. :)

Finally there is a support for serial port under Linux. Considering how basic serial port support is for any OS, it’s hard to believe it took until 3.0 to finally do it. Speaking of hardware support, there is also a Raspberry Pi GPIO support in a separate repository.

Conference also brought C# 8.0 to light of day. I will probably write more about it later but suffice it to say there are many small but exciting features. I can already see nullable reference types being either really accepted or universally hated. I am more in the former camp but time will tell. :)

You can watch keynote yourself with many more videos to follow.

Installing MPLAB X IDE 5.25 on 64-bit Ubuntu 19.04

While I love seeing companies provide Linux version of their software, it still annoys me when they do it as lazily as possible. For example Microchip not only doesn’t provide repository for their software, making you download and install every version separately, but they also don’t provide up-to-date instructions. Their section describing Ubuntu 14.04 and above simply doesn’t work.

To install MPLAB X on newer Ubuntu one must first explicitly add architecture:

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt install libc6:i386 libx11-6:i386 libxext6:i386 libstdc++6:i386 libexpat1:i386

Only once those are up you can proceed installing MPLAB IDE X itself:

tar -xvf MPLABX-v*-linux-installer.tar
chmod +x MPLABX-v*-linux-installer.sh
sudo ./MPLABX-v*-linux-installer.sh

Of course, installing compiler follows (XC8 in this case):

chmod u+x xc8-v*-full-install-linux-installer.run
sudo ./xc8-v*-full-install-linux-installer.run

And now MPLAB X IDE is installed.


PS: I won’t even go into the need for 32-bit compatibility libraries in 2019…

ZFS Pool for Virtual Machines

Running VirtualBox on ZFS pool intended for general use is not exactly the smoothest experience. Due to it’s disk access pattern, what works for all your data will not work for virtual machine disk access. Yes, you can play with record size and adding SLOG device but you can also go slightly different route. Add disk specifically for VirtualBox.

My testing has found that simple SSD with the following settings does wonders:

zpool create -o autoexpand=on -m /VirtualBox \
    -O compression=off -O recordsize=4K -O atime=off \
    -O utf8only=on -O normalization=formD -O casesensitivity=sensitive \
    VirtualBox /dev/diskid/^^DISK.eli^^

First of all, you don’t want compression. Not because data is not compressible but because compression can lead you to believe you have more space than you actually do. Even when you use fixed disk, you can run out of disk space just because some uncompressible data got written within VM. Due to copy-on-write architecture, you can still get into the trouble but exposure is greatly limited.

Ideally record size should match your expected load. In case of VirtualBox that’s 512 bytes. However, tracking 512 byte records takes so much metadata that 4K records are actually both more space efficient and perform better. Depending on your exact hardware you might find that going to 8K or even higher might hit the sweet spot. Testing is the only way to know for sure but 4K is a reasonable starting point.

All other options are just plumbing - of course you want UTF-8 and no access time tracking.

Now you can run VirtualBox without complicating your main data pool.


PS: This assumes that you have disks enumerated by diskid and fully encrypted.

PPS: I usually just spin up temporary virtual machines for testing and thus I don’t care much about them long term. If you plan to kick something up long-term, do consider mirrored ZFS.

Samba and Sync Writes

Looking up information about ZFS SLOG, I always see the same advice: “SMB uses async writes and thus ZIL provices no benefits.” It’s sane advice as ZIL brings no benefit to asynchronous writes. Sane, but no longer true.

Samba 4.7.0 changed default value for strict sync parameter from no to yes. Practical consequence of this change is that ZIL SLOG will be useful even for CIFS shares and adding it will bring you some benefits.

Should you add ZIL SLOG is still question highly dependent on your actual clients and how your pool is structured. But answer is definitely not a straight “no.”