Some Bits: Nelson's log

14 posts in August 2024

Moving $HOME from one WSL to another with local rsync

I’m installing a new WSL system, essentially a Linux VM. I want to move my 13GB of home directory files over. WSL doesn’t provide any easy way to do this. You can export and import a whole virtual disk. You can tar up your home directory and copy it just like you would any other Linux box. And you can use WSL’s various strange mounts (including 9P) but those will be slow and screw up persmissions.

The way I settled on was running an rsync daemon from the command line.

The client send command in the source WSL instance is the easy part. The only strange thing here is “localhost” as the destination. WSL’s networking magic means that two separate Linux instances apparently share “localhost”. They probably share it with the Windows host, too. (The ::xfer in the destination looks magic too; see below for the server config file that defines it.)

rsync -az --info=progress2 --port=12345 ~ nelson@localhost::xfer

The server side to receive things is trickier. Launching the server is easy enough. I just ran this as root, was running into problems with changing group ownership as a normal user

rsync --daemon --config=rsyncd.conf --no-detach --address=localhost --port=12345

All the real work here is in rsyncd.conf. Here it is:

pid file = /tmp/rsyncd.pid
lock file = /tmp/rsync.lock
log file = /tmp/rsync.log

[xfer]
path = /home/nelson/xfer
comment = xfer
read only = false
list = true
uid = nelson
gid = nelson
auth users = nelson
secrets file = /home/nelson/secrets.txt

I didn’t check this too closely, an AI generated it for me. It seems to work. It’s possible all my files got chowned and chgrped to nelson but in this case (my home directory) that’s ok.

The one gotcha is secrets.txt. The contents are simple, I just made it nelson:p for the insecure plaintext password “p” (you have to have some password). But that file has to be only readable by the user running rsync. Otherwise auth won’t work but the error message won’t tell you why.

telegraf ping in unprivileged LXC containers

Quick hint for solution for pinging in native mode from telegraf in an LXC container:

setcap cap_net_raw+ep /usr/bin/telegraf

I use telegraf to run pings for monitoring networks. You can run it in a tiny Alpine LXC container in Proxmox. But there’s a permissions issue with unprivileged containers that results in status code 2 being logged to Influx and errors like these for native pings and exec pings:

Aug 18 22:32:00 influxdb telegraf[865]: 2024-08-18T22:32:00Z E! [inputs.ping] ping failed: permission changes required, enable CAP_NET_RAW capabilities (refer to the ping plugin's README.md for more info)

Aug 18 22:38:00 influxdb telegraf[896]: 2024-08-18T22:38:00Z E! [inputs.ping] Error in plugin: host "192.168.68.1": exit status 2 - /usr/bin/ping: socktype: SOCK_RAW
Aug 18 22:38:00 influxdb telegraf[896]: /usr/bin/ping: socket: Operation not permitted
Aug 18 22:38:00 influxdb telegraf[896]: /usr/bin/ping: => missing cap_net_raw+p capability or setuid?

What great error messages, whoever wrote that deserves a peer bonus. It’s almost enough to solve the problem! Turns out LXC containers are locked down and by default can’t manipulate raw packets. But ping needs to be able to do that. The solution is to give the binary doing the pinging the raw network capability:

setcap /usr/bin/telegraf cap_net_raw=ep

You can verify it took with getcap /usr/bin/telegraf. If you need exec pings you can make it work with setcap /usr/bin/ping cap_net_raw=ep

Here’s the weird thing. Root inside the container isn’t trusted. So why can root inside the container elevate the privileges of an executable in the container? Why does the hypervisor allow that?

The other weird thing: /usr/bin/ping in the container does not have this capability set in my Debian installs. But ping works anyway, you can ping from the container in a shell as root. However if telegraf tries to ping using that same binary, it doesn’t work.

I suspect the issue is telegraf is not running as root inside the container, it has its own user. Indeed, sudo -u telegraf ping 8.8.8.8 gives an error (unless you set the capability). I still don’t understand why root inside the container is trusted though. I must not understand what “untrusted ” really means in LXC.

Another USB failure (OWC enclosure)

Ugh, right after writing a big blog post about how I’d made a reliable USB storage array, it failed. I was making a backup with Restic from the RAID array to another USB disk and both disks in the RAID failed. The simple kernel reset didn’t work either. So ZFS suspended the pool and everything broke. A reboot took 10 minutes but it’s all back and I don’t think I lost any data. But ugh, now I don’t trust this hardware.

The problems start when a read command from UAS fails on drive sdc. 30 seconds later the kernel resets the device, at the same time there’s a read error from the other drive sdb. It’s at this point everything breaks. The reset doesn’t work and so the devices are both taken offline. That causes I/O errors that ZFS notices and it suspends the pool immediately.

Just after the pool is suspended both disks come back online with new device names (sdd and sde). But ZFS doesn’t just magically assume these are OK. 122 seconds later the kernel notices some tasks have been blocked and complain.

I don’t see any errors in journalctl in the VM guest that’s using this ZFS pool. Unfortunately the kernel logs didn’t persist after a reboot so I can’t check there. It looked like the backup process was still gamely trying to run, it wasn’t even in Device Wait, but I’m not sure.

I think I might have been able to recover from the command line with zpool clear or the like. But I figured rebooting Proxmox would be simpler. That took 10 minutes after I pressed the button on the Web GUI. There’s about 6 minutes of shutdown in the logs as it’s timing out on various things that are unhappy their disk went away. Then there’s an unexplained 4 minute gap from the last log line written during shutdown to a new log line for the kernel coming up again. Afterwards the reboot went smoothly, stuff was working again in 15 seconds or so.

Very frustrated. Particularly that in this case the kernel reset didn’t work: with previous USB errors things mostly recovered. It’s like the whole USB enclosure just failed. Which is actually quite a plausible explanation.

Update Sep 7: three weeks later I haven’t seen another error from these disks. Mostly just light use but I’ve taken two full backups, one with rsync and one with restic (the thing that triggered the error before). I’m running restic with a single CPU thread and read concurrency 1, so it doesn’t hit the disk as hard.

I don’t know what conclusion to draw from this. We’re going to keep using the disks in the USB setup for now. But if I ever set up another serious ZFS array I won’t use USB for it. Common wisdom it’s a bad idea and I’ve now had enough problems I respect it.

USB drives for Linux servers

A summary of what I’ve learned using USB drives to make a little NAS server with Linux.

The serious guides will tell you “don’t use USB for storage”. They’re probably right: USB adds an extra layer, the SATA/USB interface. And those chipsets seem pretty flaky, the last thing you want in a storage system. With most of the hardware I tested the Linux kernel would throw errors every 30 minutes or so and reset the device.

OTOH it mostly seems to work and not corrupt data. I finally found an enclosure that hasn’t thrown an error (yet).

Update: lol, not an hour after publishing this I got a failure from the enclosure I thought was good. A Restic backup (which is read intensive) triggered the failure. It didn’t even reset correctly, so the disks went offline and ZFS suspended the pool. ARGH!

If you have a SATA or Thunderbolt interface by all means use that instead. Related: Host Bus Adapters. But if USB is all you got, here’s some notes.

Drive types

I’m focusing here on spinning 3.5″ drives, Western Digital Red Plus. These drives are the best inexpensive option for storage that’s cheap and big. Sequential throughput is pretty good on these, at least 100MBytes/s. SSDs are great but are 3-4x the price for the size. 2.5″ spinning drives are also nice but max out at 5TB. Also they use SMR media which has weird performance and reliability issues. 3.5″ drives still come in CMR.

Enclosures

The enclosure takes a 3.5″ SATA disk and gives you an interface: USB, also maybe eSATA or Thunderbolt. Small enclosures are simple and take a single disk. Bigger enclosures allow you to plug in many drives with a single USB cable. They often include a hardware RAID chipset you probably won’t use (JBOD is preferred for ZFS). If you put it in JBOD mode Linux will see multiple separate hard rives on a single USB interface.

Enclosures provide power via a separate transformer (do not rely on bus power for 3.5″ drives.). I’ve heard that the quality of the power supply varies significantly and matters a lot: a power blip screws things up. I don’t know more about it. One nice thing about 2.5″ drives is they can be bus powered, simplifying things. If you don’t need big fast storage consider 2.5″.

Many enclosures don’t provide power again if there’s a power outage. They have a stupid pushbutton you have to physically press to turn it back on. Look instead of enclosures with rocker switches that come on automatically.

Enclosures also provide cooling. Cheap ones are just aluminum boxes with passive radiating. That seems OK for one disk but not many, I saw temperatures up to 55°C with two disks in a Yottamaster. The OWC enclosure I’m using has a small fan that makes a huge difference, max temperature like 36°C.

The big problem is finding a reliable enclosure. I spent a lot of time stress testing enclosures and found the older USB 3.0 ones from Yottamaster and SABRENT had kernel errors. A newer 3.1 enclosure from OWC seems more reliable, it is my preference now.

USB versions

USB 3.0 provides 5Gbps or 625MByte/s, much faster than a spinning disk. So any 3.0 interface is fine for a single disk in terms of throughput.

USB 3.1 and 3.2 can provide 10Gbps or 20Gbps. That shouldn’t matter for a single disk or really even two in an enclosure. OTOH I saw some evidence that two 5Gbps separate enclosures was twice as fast as a single 5Gbps enclosure with two disks, not sure what that means. I didn’t test with 10Gbps or 20Gbps links.

However, there’s a theory that newer chipsets are more reliable, that some of the bugs in older systems have been worked out. So I’m going to avoid USB 3.0 enclosures and favor those that offer USB 3.2, or at least 3.1. Even better is eSATA, Thunderbolt, or USB4. If you have an interface on your computer for those you should use them instead of USB.

Cables

USB cables matter! It’s very easy to use a crummy cable and only get 480Mbits/s instead of 5000. The quick advice is “look for a blue connector”. Use lsusb -t to verify the speed you’re getting. Be particularly wary of C-to-A cables, a lot of them are really for charging and are slow for data.

UAS vs usbstorage

usbstorage is the old Linux kernel module for USB disks. My older 2.5″ drives are using it. It seems fine.

uas is the new Linux kernel module for newer USB disks. UASP is basically SCSI and should perform better. Linux will use this module automatically if the drive supports it.

usbfs turns up on Proxmox if you pass through a USB device to a guest. I have no idea what it does, nothing seems mounted with it.

SMART

USB devices are supposed to support SMART but it’s kind of tricky. I need to do more research on this.

My old usbstorage drives work out of the box with SMART. With my newer UAS devices smartctl complains /dev/sdc: Unknown USB bridge with some enclosures. The quick hack is to run smartctl -d sat, which will probably work. There’s a more elaborate thing where you teach the SMART software about your drive type but I haven’t tried it.

Performance

Long story short how is USB performance? Pretty good, I think for sequential reads and writes I can get close to the spinning disk speeds. 100-150Mbytes/s, at least. Random access is slower of course and I saw some confusing results that depended on buffering. The final RAID mirror setup I have can do about 20MBytes/s read, 14MBytes/s write with an aggressively random access pattern. I don’t know whether USB is adding significant overhead or not.

FIO stress test of NAS options

This blog post is a very long record of my testing of a disk array. I’m building a cheap NAS with 2 USB disks (8GB, 5400RPM) in a ZFS mirror configuration plugged in to an N100 MiniPC with 5Gbit USB links. I’m trying several enclosures: a Yottamaster dual bay, two SABRENT single bays, and an OWC dual bay. My main goal here is to find a reliable enclosure. (Spoiler: it’s the OWC.)

I’m running everything on Proxmox. Most of my tests are with Proxmox managing a ZFS pool and creating a virtual disk it passes in to an OpenMediaVault VM (aka OMV). Then I CIFS/SMB mount the disk back on the Proxmox host for further testing. I also did a bit of testing with TrueNAS in a VM where Proxmox just passes the USB disks in as devices for TrueNAS to manage a pool on.

Conclusions

  • Two of three USB enclosures generate kernel errors. Under heavy load there will be a command failure followed by a USB reset about every 30 minutes. In all cases the system recovers and it looks like no data is lost.
  • The OWC enclosure generates no kernel errors. It is also the lowest temperatures.
  • Throughput is wildly variable, sometimes transfers stall. I assume it’s buffering.
  • Network filesystems buffer even if you set various modes telling them not to.
  • TrueNAS seems to have better throughput than OMV. I didn’t test carefully.
  • TrueNAS is unusable with the Yottamaster enclosure, too many errors. It sort of worked with the SABRENT. Didn’t try the OWC.
  • The Yottamaster enclosure is unsuitable. Doesn’t turn itself on after a power outage, also not adequate cooling.
  • The SABRENT enclosures are OK. I don’t love having two power supplies. There were a few more errors in my testing but maybe that was just bad luck.

Decisions

  • I’m going with the OWC enclosure.
  • I’m going to stick with Proxmox ZFS and OMV for the NAS. There’s evidence TrueNAS performs better but I’m nervous about its complexity. Also feeling burned after the bad first experience with the Yottamaster enclosure although that’s probably the USB device’s fault.

The test job

I’ve been enjoying learning fio, the disk throughput tool, mostly because it has very good docs. Which means not only can I read them but the AIs can too. Phind gets it wrong sometimes though so I’m mostly hand-crafting my own fio setups now.

I cooked up a job file (see below) which I’m using as a small stress test as I try different USB hardware and ZFS / virtualization / network file system configurations. My main goal here is to run it for a long time to see if the disks fail in some way, also to measure temperature. I’m less worried about the actual throughput although it’s interesting.

The job file defines a job against a 1GB file. Random reads and writes of blocks from 4k to 1M. Up to 16 in parallel (io_depth), direct I/O enabled. (Note direct=1 means O_DIRECT which doesn’t actually work over a network file system. Oops.) I’m running two jobs in parallel for 15 minutes.

In general I’m seeing throughput of about 28MB/s both read and write, maybe 130 IOPS. That’s whether native on the ZFS machine, through VM disk, or through SMB to the VM disk. (Presumably seek time is dominating.) Not very fast but this is a random access test on a spinning disk. (Sequential gets up to 250 MB/s).

Weirdly I’m seeing more like 100MB/s with an SMB network mount. I’ve chalked this up to me not understanding caching in network file systems. Details below.

Here’s my results from several hours of testing. fio was run on Proxmox natively (which owns the ZFS pool), then on a OpenMediaVault VM (OMV) which gets a virtual disk from Proxmox, then from the Proxmox host itself that has SMB mounted the share from OMV. I also did a few tests with a different configuration: TrueNAS managing the two USB disks directly as USB devices and exporting over SMB.

Measurements

Tests with various enclosures, then some extra scenarios with the OWC enclosure.

OWC results

The hardware is a Mercury Elite Pro Dual, USB 3.1 at 5GBit, UAS. This device can do RAID bit I have it in JBOD mode, “IND”. PITA to get the disks installed, the mechanical design is not great, but it seem sturdy and has a little fan. It also advertises USB 3.1 (5Gbit) and there’s a theory that newer USB revisions imply newer, better chipsets.

Smartctl requires -d sat to work.

Max temperature: 34°C, the fan really helps. The disks are pretty noisy, the enclosure does nothing to dampen the sound.

No errors from the kernel! Haven’t seen a single UAS error after several hours of testing, unlike the other enclosures.

Throughput

  1. Proxmox ZFS native run 1: 21.0MiB/s read, 13.0 write, 97 IOPS.
  2. Proxmox ZFS native run 2: 21.4 read, 13.6 write.
  3. OMV: read 24.9 write 13.6, 109 IOPS
  4. SMB client of OMV run 1: read 122 MiB/s, write 66.5 MiB/s, 552 IOPS.
  5. SMB client of OMV run 2: read 133 MiB/s, write 72 MiB/s

The ZFS native test seems pretty slow at 21/13, it’s the slowest of the three enclosures I tried. Although that’s not that much slower than the Yottamaster dual enclosure test at 28/18. hdparm -t (a simple sequential test of a single drive) shows 210MB/s, so it’s not totally broken.

Yottamaster results

Yottamaster PS200U3. One dual disk USB enclosure at 5Gbit USB 3.0, UAS.

smartctl works out of the box on Proxmox, needed -d sat in TrueNAS.

Max temperature: 52°C. Noisy too.

Kernel errors: while testing over about 90 minutes I got one driver reset of a read command.

Throughput

  • Proxmox ZFS native: read 28MiB/s, write 18MiB/s, 131 IOPS.
  • OMV run 1: read 27MiB/s, write 15MiB/s, 122 IOPS. (Had a reset!)
  • OMV run 2: read 28MiB/s, write 16MiB/s, 127 IOPS.
  • SMB client of OMV run 1: read 98MiB/s, write 53MiB/s, 443 IOPS.
  • SMB client of OMV run 2: read 104MiB/s, write 55.7MiB/s, 470 IOPS.

SABRENT results

Two single disk SABRENT EC-KSL3 USB enclosures at 5Gbit USB 3.0. UAS. I’ve been using a third one of these for a week+ with good luck.

smartctl requires -d sat in Proxmox

Temperatures: 41. Quietest of the three.

More errors, but throughput looks good. While testing got an ugly UAS reset in the VM fio run. From the first error it took 54 seconds before a reset came through. OTOH it didn’t seem to affect throughput. Only one disk got reset, don’t know what ZFS does about that. A second reset during the SMB mount test, again not hurting throughput. Weird.

I also got a new kind of error I’ve not seen before, maybe related to erasing blocks? This error doesn’t end up in the SMART log.

[Mon Aug 12 01:28:06 2024] sd 1:0:0:0: [sdd] tag#0 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=0s
[Mon Aug 12 01:28:06 2024] sd 1:0:0:0: [sdd] tag#0 Sense Key : Illegal Request [current]
[Mon Aug 12 01:28:06 2024] sd 1:0:0:0: [sdd] tag#0 Add. Sense: Invalid command operation code
[Mon Aug 12 01:28:06 2024] sd 1:0:0:0: [sdd] tag#0 CDB: Write same(16) 93 08 00 00 00 00 00 02 fe 90 00 00 09 70 00 00
[Mon Aug 12 01:28:06 2024] critical target error, dev sdd, sector 196240 op 0x3:(DISCARD) flags 0x800 phys_seg 1 prio class 0

All in all 3 kernel errors compared to just 1 with the Yottamaster for the same amount of testing. Feels bad man. The fio verify didn’t find any problems though. I ran a ZFS scrub and it didn’t find any problems.

Throughput

  • Proxmox ZFS native: read 58, write 37, 266 IOPS.
  • OMV run 1: read 60.3 write 33.5 , 270 IOPS. (Had a reset!)
  • OMV run 2: read 59.8 write 33.7 , 275 IOPS (No reset).
  • SMB client of OMV run 1: read 128 MiB/s, write 68.4 MiB/s, 578 IOPS.
  • SMB client of OMV run 2: read 145 MiB/s, write 75 MiB/s, 658 IOPS.
  • SMB client of OMV run 3: read 133 write 68. (Reset)

Note the Proxmox and OMV throughput is better, maybe 2x what I got with the dual bay enclosures. Is that as simple as it being because I’m using two USB ports and two 5Gbit connections? (The max throughput I’ve seen is about 200MB/s or 1.6Gbit, well under a single 5Gb wire, so it’s not as simple as max bandwidth.) OTOH I’ve gotten more errors and more variety of errors. But all the data seems to be correctly being read and written.

TrueNAS tests

In addition to testing enclosures I did a couple of tests with TrueNAS managing the ZFS pool using USB devices passed in from Proxmox. This failed catastrophically with the Yottamaster enclosure, far too many errors. These tests are with the SABRENT. I didn’t try the OWC with TrueNAS.

The main thing I was wondering was what sort of errors I’d see, if any. I saw only one error with three 15 minute runs on TrueNAS, about halfway through a VM test. Write(16) commands failed and it reset about 30 seconds later and seemed to carry on fine.

Throughput

  1. TrueNAS VM run 1: 122MiB/s read, 64 write, 550 IOPS
  2. TrueNAS VM run 2: 137 read, 72 write
  3. SMB client of TrueNAS VM: 138MiB/s read, 76 write, 630 IOPS

I’m less worried about throughput comparisons to OMV, I care most about stability. But compared to the Proxmox ZFS + OMV solution it seems both faster and with less jitter. That is not surprising but should be confirmed more.

SMB and buffering tests

I tried to understand more what was going on with the SMB clients being faster than local writes. It’s definitely related to O_DIRECT and other synchronous writes not being enabled on network filesystems. Most of my tests were with direct=1 in FIO but that doesn’t really mean anything on an SMB mount. Forcing sync writes slows the network tests way down.

I ran some 1 minute tests of different configs on the VM writing to its virtual disk. The FIO test set was 1GB which might fit in caches or might not. I noticed the second time I ran the same test it was much faster, which suggests warming up the caches is a big factor in a 1 minute test.

  1. direct=1, end_fsync=1 (like most tests): 15MiB/s read, 16 MiB/s write.
  2. direct=0, buffered=1, end_fsync=1: 15MiB/s read, 15 MiB/s write.
  3. fio defaults (buffered and no fsync, I think): 13MiB/s read, 13MiB write.
  4. sync=1, fsync=1: 3.2MiB/s read, 3.7MiB/s write.

I can’t make much sense of these local results: even with full buffering I can’t get to the 100MiB/s the disk is capable of. Maybe it’s a virtualization issue, or the client workload being on the disk. The VM has 4GB of RAM allocated which I think should be enough to cache a 1GB working set.

I also re-ran these tests on the SMB host. I ran the first one twice and took the second result.

  1. direct=1, end_fsync=1 (like most tests): 102MiB/s read, 64 MiB/s write.
  2. direct=0, buffered=1, end_fsync=1: 110MiB/s read, 72.9 MiB/s write.
  3. fio defaults (buffered and no fsync, I think): 160 read, 118 write.
  4. sync=1, fsync=1: 3.0 read, 3.3 write.

These results suggest that the network filesystems are caching even in most IO modes that say don’t. That’s fair, it’s a real world result for a network client. Forcing sync and fsync does slow it down as expected.

To be honest, I don’t really understand all of what’s going on here, I don’t know FIO or network filesystems well enough to fully sort this out. Given my main goal was stability testing, eh, I’m OK with my ignorance for now.

Application testing

I did a bunch of real world testing, writing via SMB to the OMV VM with the OWS enclosure.

  1. Linux rsync of a music library: 21MB/s.
  2. Linux dd writing 16GB from /dev/urandom: 70MB/s
  3. dd reading 16GB of random: 182MB/s
  4. dd writing 16GB from /dev/zero: 188MB/s
  5. dd reading 16GB of zeros: 718MB/s
  6. WSL (drvfs) reading 16GB of random: 42MB/s
  7. WSL (drvfs) writing 1GB of random: 39MB/s
  8. Windows explorer reading or writing 1GB of random: 112MB/s

The FIO job file

[stress]
name=stress
description=Nelson small stress test

runtime=900
numjobs=2
time_based=1

rw=randrw
verify=crc32c

bsrange=4k-1M
size=1G

ioengine=libaio
iodepth=16
direct=1
end_fsync=1

Example output (from an OMV VM run)

This run had a kernel reset in the first minute or two.

stress: (g=0): rw=randrw, bs=(R) 4096B-1024KiB, (W) 4096B-1024KiB, (T) 4096B-1024KiB, ioengine=libaio, iodepth=16
...
fio-3.33
Starting 2 processes
Jobs: 2 (f=2): [f(2)][100.0%][eta 00m:00s]
stress: (groupid=0, jobs=1): err= 0: pid=128236: Sun Aug 11 21:42:17 2024
  Description  : [Nelson small stress test]
  read: IOPS=42, BW=13.9MiB/s (14.6MB/s)(12.3GiB/904825msec)
    slat (usec): min=2, max=8473, avg=26.58, stdev=52.04
    clat (usec): min=30, max=8023.4k, avg=158853.13, stdev=208421.15
     lat (usec): min=42, max=8023.4k, avg=158879.70, stdev=208425.03
    clat percentiles (usec):
     |  1.00th=[     66],  5.00th=[    137], 10.00th=[    245],
     | 20.00th=[    742], 30.00th=[   1565], 40.00th=[   3621],
     | 50.00th=[  79168], 60.00th=[ 143655], 70.00th=[ 206570],
     | 80.00th=[ 316670], 90.00th=[ 480248], 95.00th=[ 583009],
     | 99.00th=[ 742392], 99.50th=[ 801113], 99.90th=[ 926942],
     | 99.95th=[1027605], 99.99th=[3439330]
   bw (  KiB/s): min=   24, max=258184, per=47.42%, avg=13000.64, stdev=16851.88, samples=985
   iops        : min=    0, max=  564, avg=38.20, stdev=39.37, samples=985
  write: IOPS=23, BW=8021KiB/s (8213kB/s)(6549MiB/836125msec); 0 zone resets
    slat (usec): min=7, max=3420.8k, avg=343.27, stdev=24216.95
    clat (usec): min=6, max=30381k, avg=292247.93, stdev=1846279.09
     lat (usec): min=58, max=30381k, avg=292591.21, stdev=1846416.62
    clat percentiles (usec):
     |  1.00th=[      70],  5.00th=[     101], 10.00th=[     131],
     | 20.00th=[     192], 30.00th=[     293], 40.00th=[     979],
     | 50.00th=[    5669], 60.00th=[   13173], 70.00th=[   72877],
     | 80.00th=[  183501], 90.00th=[  367002], 95.00th=[  526386],
     | 99.00th=[ 8791262], 99.50th=[17112761], 99.90th=[17112761],
     | 99.95th=[17112761], 99.99th=[17112761]
   bw (  KiB/s): min=    8, max=299704, per=87.37%, avg=13650.88, stdev=19572.55, samples=977
   iops        : min=    0, max=  646, avg=40.49, stdev=45.01, samples=977
  lat (usec)   : 10=0.01%, 50=0.22%, 100=3.47%, 250=12.13%, 500=8.42%
  lat (usec)   : 750=2.49%, 1000=2.13%
  lat (msec)   : 2=7.58%, 4=6.57%, 10=4.21%, 20=4.34%, 50=3.45%
  lat (msec)   : 100=4.07%, 250=19.25%, 500=13.82%, 750=6.52%, 1000=0.65%
  lat (msec)   : 2000=0.08%, >=2000=0.61%
  cpu          : usr=0.51%, sys=0.23%, ctx=44359, majf=0, minf=60
  IO depths    : 1=0.1%, 2=0.1%, 4=0.2%, 8=0.3%, 16=99.4%, 32=0.0%, >=64=0.0%
     submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.1%, 32=0.0%, 64=0.0%, >=64=0.0%
     issued rwts: total=38221,19954,0,0 short=0,0,0,0 dropped=0,0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=16
stress: (groupid=0, jobs=1): err= 0: pid=128237: Sun Aug 11 21:42:17 2024
  Description  : [Nelson small stress test]
  read: IOPS=36, BW=12.9MiB/s (13.5MB/s)(11.4GiB/904823msec)
    slat (usec): min=2, max=37758, avg=29.45, stdev=218.32
    clat (usec): min=3, max=5053.6k, avg=184087.63, stdev=201615.07
     lat (usec): min=41, max=5053.7k, avg=184117.07, stdev=201618.12
    clat percentiles (usec):
     |  1.00th=[     65],  5.00th=[    135], 10.00th=[    219],
     | 20.00th=[    490], 30.00th=[   1680], 40.00th=[  58983],
     | 50.00th=[ 137364], 60.00th=[ 187696], 70.00th=[ 256902],
     | 80.00th=[ 362808], 90.00th=[ 484443], 95.00th=[ 583009],
     | 99.00th=[ 725615], 99.50th=[ 775947], 99.90th=[ 926942],
     | 99.95th=[1002439], 99.99th=[1635779]
   bw (  KiB/s): min=   24, max=303480, per=48.60%, avg=13324.66, stdev=15923.38, samples=900
   iops        : min=    0, max=  636, avg=36.52, stdev=34.91, samples=900
  write: IOPS=21, BW=7829KiB/s (8017kB/s)(6208MiB/812003msec); 0 zone resets
    slat (usec): min=8, max=23051, avg=172.05, stdev=269.40
    clat (usec): min=4, max=26223k, avg=345496.71, stdev=1929292.62
     lat (usec): min=56, max=26223k, avg=345668.76, stdev=1929294.26
    clat percentiles (usec):
     |  1.00th=[      68],  5.00th=[     101], 10.00th=[     130],
     | 20.00th=[     192], 30.00th=[     269], 40.00th=[     400],
     | 50.00th=[    2409], 60.00th=[   11469], 70.00th=[   33162],
     | 80.00th=[  214959], 90.00th=[  438305], 95.00th=[  591397],
     | 99.00th=[ 9328133], 99.50th=[17112761], 99.90th=[17112761],
     | 99.95th=[17112761], 99.99th=[17112761]
   bw (  KiB/s): min=   16, max=360360, per=91.60%, avg=14312.77, stdev=19145.59, samples=884
   iops        : min=    0, max=  756, avg=39.49, stdev=41.87, samples=884
  lat (usec)   : 4=0.01%, 10=0.01%, 50=0.24%, 100=3.43%, 250=13.62%
  lat (usec)   : 500=11.35%, 750=3.48%, 1000=1.55%
  lat (msec)   : 2=3.97%, 4=2.64%, 10=2.95%, 20=4.05%, 50=3.18%
  lat (msec)   : 100=3.23%, 250=19.75%, 500=17.91%, 750=7.21%, 1000=0.56%
  lat (msec)   : 2000=0.06%, >=2000=0.80%
  cpu          : usr=0.62%, sys=0.19%, ctx=42436, majf=0, minf=58
  IO depths    : 1=0.1%, 2=0.1%, 4=0.2%, 8=0.4%, 16=99.3%, 32=0.0%, >=64=0.0%
     submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.1%, 32=0.0%, 64=0.0%, >=64=0.0%
     issued rwts: total=33008,17566,0,0 short=0,0,0,0 dropped=0,0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=16

Run status group 0 (all jobs):
   READ: bw=26.8MiB/s (28.1MB/s), 12.9MiB/s-13.9MiB/s (13.5MB/s-14.6MB/s), io=23.7GiB (25.4GB), run=904823-904825msec
  WRITE: bw=15.3MiB/s (16.0MB/s), 7829KiB/s-8021KiB/s (8017kB/s-8213kB/s), io=12.5GiB (13.4GB), run=812003-836125msec

Disk stats (read/write):
  sdb: ios=71241/37679, merge=0/79, ticks=12088873/12617701, in_queue=25410356, util=98.74%

Example output (fast OMV SMB)

stress: (g=0): rw=randrw, bs=(R) 4096B-1024KiB, (W) 4096B-1024KiB, (T) 4096B-1024KiB, ioengine=libaio, iodepth=16
...
fio-3.33
Starting 2 processes
Jobs: 2 (f=2): [F(2)][100.0%][eta 00m:00s]
stress: (groupid=0, jobs=1): err= 0: pid=2695937: Sun Aug 11 22:35:44 2024
  Description  : [Nelson small stress test]
  read: IOPS=145, BW=47.6MiB/s (49.9MB/s)(42.5GiB/913477msec)
    slat (usec): min=2, max=26353, avg=58.40, stdev=206.57
    clat (usec): min=104, max=2047.9k, avg=12816.66, stdev=61461.93
     lat (usec): min=117, max=2047.9k, avg=12875.05, stdev=61461.19
    clat percentiles (usec):
     |  1.00th=[    996],  5.00th=[   2147], 10.00th=[   2769],
     | 20.00th=[   3621], 30.00th=[   4424], 40.00th=[   5407],
     | 50.00th=[   6521], 60.00th=[   7701], 70.00th=[   9110],
     | 80.00th=[  10814], 90.00th=[  13698], 95.00th=[  17171],
     | 99.00th=[ 120062], 99.50th=[ 446694], 99.90th=[ 960496],
     | 99.95th=[1166017], 99.99th=[1484784]
   bw (  KiB/s): min=   33, max=571776, per=100.00%, avg=105476.19, stdev=139877.54, samples=369
   iops        : min=    0, max= 1773, avg=299.33, stdev=402.43, samples=369
  write: IOPS=78, BW=25.4MiB/s (26.7MB/s)(21.9GiB/882111msec); 0 zone resets
    slat (usec): min=8, max=19996, avg=422.84, stdev=490.09
    clat (usec): min=120, max=4478.9k, avg=20844.50, stdev=104407.14
     lat (usec): min=145, max=4479.4k, avg=21267.34, stdev=104398.63
    clat percentiles (usec):
     |  1.00th=[    570],  5.00th=[   2376], 10.00th=[   2966],
     | 20.00th=[   3884], 30.00th=[   4817], 40.00th=[   5997],
     | 50.00th=[   7177], 60.00th=[   8717], 70.00th=[  10552],
     | 80.00th=[  13435], 90.00th=[  22938], 95.00th=[  55837],
     | 99.00th=[ 270533], 99.50th=[ 505414], 99.90th=[1535116],
     | 99.95th=[1954546], 99.99th=[4076864]
   bw (  KiB/s): min=  116, max=588064, per=100.00%, avg=111529.76, stdev=145498.82, samples=361
   iops        : min=    0, max= 1835, avg=319.26, stdev=420.92, samples=361
  lat (usec)   : 250=0.15%, 500=0.39%, 750=0.33%, 1000=0.28%
  lat (msec)   : 2=2.62%, 4=19.68%, 10=49.18%, 20=21.19%, 50=3.53%
  lat (msec)   : 100=1.01%, 250=0.79%, 500=0.38%, 750=0.21%, 1000=0.13%
  lat (msec)   : 2000=0.13%, >=2000=0.02%
  cpu          : usr=1.78%, sys=1.96%, ctx=161455, majf=0, minf=61
  IO depths    : 1=0.1%, 2=0.1%, 4=0.2%, 8=0.3%, 16=99.4%, 32=0.0%, >=64=0.0%
     submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.1%, 32=0.0%, 64=0.0%, >=64=0.0%
     issued rwts: total=132944,68929,0,0 short=0,0,0,0 dropped=0,0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=16
stress: (groupid=0, jobs=1): err= 0: pid=2695938: Sun Aug 11 22:35:44 2024
  Description  : [Nelson small stress test]
  read: IOPS=144, BW=51.0MiB/s (53.5MB/s)(45.5GiB/913651msec)
    slat (usec): min=2, max=23315, avg=57.89, stdev=177.90
    clat (usec): min=101, max=1961.1k, avg=12840.81, stdev=60523.78
     lat (usec): min=124, max=1961.2k, avg=12898.70, stdev=60523.08
    clat percentiles (usec):
     |  1.00th=[   1057],  5.00th=[   2212], 10.00th=[   2966],
     | 20.00th=[   3949], 30.00th=[   4752], 40.00th=[   5669],
     | 50.00th=[   6587], 60.00th=[   7767], 70.00th=[   8979],
     | 80.00th=[  10814], 90.00th=[  13566], 95.00th=[  16909],
     | 99.00th=[ 113771], 99.50th=[ 480248], 99.90th=[ 926942],
     | 99.95th=[1098908], 99.99th=[1434452]
   bw (  KiB/s): min=   11, max=535318, per=100.00%, avg=116860.38, stdev=139385.70, samples=352
   iops        : min=    0, max= 1606, avg=310.24, stdev=377.85, samples=352
  write: IOPS=77, BW=27.3MiB/s (28.6MB/s)(23.6GiB/884188msec); 0 zone resets
    slat (usec): min=6, max=26990, avg=438.46, stdev=504.53
    clat (usec): min=132, max=2040.9k, avg=17837.66, stdev=67499.86
     lat (usec): min=162, max=2041.4k, avg=18276.12, stdev=67487.74
    clat percentiles (usec):
     |  1.00th=[    668],  5.00th=[   2704], 10.00th=[   3556],
     | 20.00th=[   4686], 30.00th=[   5669], 40.00th=[   6783],
     | 50.00th=[   7963], 60.00th=[   9241], 70.00th=[  10945],
     | 80.00th=[  13566], 90.00th=[  21365], 95.00th=[  46924],
     | 99.00th=[ 204473], 99.50th=[ 387974], 99.90th=[1019216],
     | 99.95th=[1434452], 99.99th=[1769997]
   bw (  KiB/s): min=   82, max=585474, per=100.00%, avg=126777.70, stdev=149747.38, samples=347
   iops        : min=    0, max= 1630, avg=335.09, stdev=397.89, samples=347
  lat (usec)   : 250=0.12%, 500=0.35%, 750=0.31%, 1000=0.27%
  lat (msec)   : 2=2.34%, 4=14.81%, 10=53.90%, 20=22.06%, 50=3.49%
  lat (msec)   : 100=0.93%, 250=0.67%, 500=0.31%, 750=0.21%, 1000=0.15%
  lat (msec)   : 2000=0.09%, >=2000=0.01%
  cpu          : usr=2.50%, sys=2.06%, ctx=165105, majf=0, minf=58
  IO depths    : 1=0.1%, 2=0.1%, 4=0.2%, 8=0.4%, 16=99.3%, 32=0.0%, >=64=0.0%
     submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.1%, 32=0.0%, 64=0.0%, >=64=0.0%
     issued rwts: total=132204,68715,0,0 short=0,0,0,0 dropped=0,0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=16

Run status group 0 (all jobs):
   READ: bw=98.6MiB/s (103MB/s), 47.6MiB/s-51.0MiB/s (49.9MB/s-53.5MB/s), io=88.0GiB (94.5GB), run=913477-913651msec
  WRITE: bw=52.7MiB/s (55.2MB/s), 25.4MiB/s-27.3MiB/s (26.7MB/s-28.6MB/s), io=45.5GiB (48.8GB), run=882111-884188msec

Accessing a Proxmox guest in ZFS from a rescue disk

Testing disaster recovery: what if my Proxmox server dies and I need to get data from a VM disk stored in it in ZFS? The simple thing is to boot Proxmox and use it to recover. But what if I don’t want to use Proxmox to get at my files? It’s possible, at least in theory, using generic ZFS and QEMU tools. I tried this and it seemed to work.

(An aside: I harshly unplugged my ZFS pool disks while Proxmox was running, then plugged them in later. Proxmox didn’t handle this very well, I ended up having to reboot the Proxmox server and then everything was back with no drama.)

Part 1: import the ZFS pool

The first step is to get the ZFS pool online in a rescue environment.

  1. Boot systemrescue-zfs on some computer.
  2. Plug the drives from your ZFS pool into the rescue machine
  3. Run lsblk to see that the drives are present.
  4. Run zpool import to see a list of pools. Your Proxmox pool should be there. Proxmox creates rpool on install, you may have others.
  5. Run zpool import -f poolname to import the pool.
  6. Run zfs list to see what the pool has in it

At this point any normal filesystems in Proxmox are mounted somewhere in the filesystem and you can cd to their directories, copy them as files, etc.

Part 2: access the QEMU virtual disks

I’m after data that’s in a guest virtual machine’s disk. And those aren’t stored in normal files. Instead they are stored in ZFS datasets with funny names like rpool/data/vm-100-disk-1. They are in QEMU disk image format. (I think raw, not qcow2, but I am not certain.)

There’s several options for what to do next. You could zfs send the data somewhere safe. In Proxmox you could access the virtual disks with the qm command line tool. There’s probably a way to use qemu-img dd to get your data. But here in systemrescue-zfs I’m going to mount it via a network block device.

I’m a little out of my depth here but I bashed my way into getting access like this

  1. cd /zvol. In here is filesystem access to the ZFS datasets (as symlinks to block devices)
  2. Find the virtual disk you want, say vm-100-disk-1
  3. qemu-img info vm-100-disk-1 to see if there’s a plausible disk image there.
  4. modprobe nbd max_part=8 to load a driver for network block devices
  5. qemu-nbd --connect=/dev/nbd0 vm-100-disk-1 to make the QEMU disk available as /dev/nbd0. Note this is the whole disk, not just one partition.
  6. fdisk /dev/nbd0 -l to see the partition table of the virtual disk
  7. mount /dev/nbd0p1 /mnt/hope to mount the partition 1 filesystem as /mnt/hope.
  8. cd /mnt/hope and there’s your stuff!

USB enclosures and Linux

I’m beginning to see why everyone says not to use USB enclosures with Linux. It’s a cursed product category. I’m finding it very hard to find a simple two bay JBOD enclosure that might work reliably. OTOH I’ve been using 2.5″ USB drives with a server successfully for a year+ now, this general concept should work. And I’ve been using a new drive in a SABRENT 3.5″ single disk enclosure successfully. But I’m having a hard time finding 3.5″ enclosures that take more than one disk.

Update 1: see at bottom

Update 2: see this video which talks favorably about newer USB 3.2 enclosures like the Mediasonic Probox.

Update 3: see this Reddit post I made.

Horror stories abound of buggy JMicron chipsets. It’s never quite clear if the reports are real, they’re mostly ranty Amazon reviews. But definitely bad vibes.

I know for sure there’s one big problem with the USB enclosure product category: power restoration. Most of these enclosures will not turn back on when power is restored until you press a button on them box. WTF? Why would you build hardware like that?

Also USB enclosures typically have a low power / idle mode when not used for awhile. I’m OK with it taking a few seconds for the disks to spin up (although it’d be nice to have control over that). But some of them seem to never come back online or start throwing errors.

None of these devices I’ve bought recently work out of the box with smartctl. They aren’t identified correctly. smartctl -d sat works around the problem, sort of. There’s also some way to register the device in a database to teach smartctl about it. This identification thing seems to be a problem with the UAS driver in particular, or maybe it’s the 2022 version of smartctl Debian is installing.

SABRENT EC-KSL3, it works?

I’ve had decent luck for a few days with a SABRENT EC-KSL3, a $30 single disk enclosure. I don’t love the physical toolless design but the interface seems to work with my Linux box running OMV. It’s fanless aluminum which I think is OK for a single disk.

The device has a physical rocker switch for power. I need to test it but I assume that means it will come back on when power is restored. I think it’s gone to sleep a few times but seems to come back every time. I saw a couple of resets from the kernel driver early in trying to use it but have gone most of a day now without a single reset. So good?

The chipset is some sort of JMicron, not sure which.

Yottamaster PS200U3: it doesn’t work?

Much worse first experience with a Yottamaster PS200U3, a $80 dual disk enclosure. The physical design is pretty nice, they even included decent tools and extra screws. No fan and it’s plastic inside, so some question about thermals.

It has pushbutton power you definitely have to press to get it to turn on after a power failure. (Confirmed with support.) But none of that matters because the device is just not working. Ugh!

The chipset is a JMicron JMS56x.

I set it up with TrueNAS and my ZFS array disappeared within a few minutes. At least, TrueNAS can’t find it. Looking at the kernel log I see a whole lot of errors from the UAS driver and attempts to reset followed by giving up on the device entirely.

Whatever the case the disks in this enclosure just do not work with TrueNAS scale. There could be other sources of errors: the disks themselves, or the virtualization in the middle, or maybe TrueNAS. But I’m inclined to blame the enclosure.

Here’s an example dmesg log for errors in TrueNAS for the USB disk. This gets triggered just trying to look at the Storage status page in the web UI. The first line shows a reset at 67 seconds, the rest of it is another problem starting at 300 seconds (errors) and then a rest at 330s. I think these things have a 5 minute idle timeout so that doesn’t even explain it.

[   67.520053] scsi host3: uas_eh_device_reset_handler success
[  300.078621] sd 3:0:0:1: [sdc] tag#6 uas_eh_abort_handler 0 uas-tag 4 inflight: IN
[  300.078642] sd 3:0:0:1: [sdc] tag#6 CDB: Read(16) 88 00 00 00 00 00 00 00 22 20 00 00 00 e0 00 00
[  330.798889] sd 3:0:0:1: [sdc] tag#4 uas_eh_abort_handler 0 uas-tag 3 inflight: IN
[  330.799100] sd 3:0:0:1: [sdc] tag#4 CDB: ATA command pass through(16) 85 08 0e 00 d5 00 01 00 06 00 4f 00 c2 00 b0 00
[  330.814733] scsi host3: uas_eh_device_reset_handler start
[  331.071192] usb 3-1: reset SuperSpeed USB device number 2 using xhci_hcd
[  331.096325] scsi host3: uas_eh_device_reset_handler success

On further testing I can reproduce the problem by trying to open the Storage Dashboard in TrueNAS, it happens even if I try again in just over a minute. My guess is TrueNAS is issuing some commands via UAS that the controller or disks really don’t like and it’s crashing the connection to the drive. Could be a Linux bug, could be a controller bug. I sure hope this problem is isolated to the Yottamaster.

Update

I’m beginning to suspect TrueNAS Scale is the issue. This exact same hardware is doing fine with a ZFS pool built inside Proxmox. I made a 4TB virtual disk and shared it into an OpenMediaVault VM and so far it’s working great. Was able to write a bunch of data and run fio tests with no problem, no errors from the kernel. Also smartctl works out of the box on Proxmox.

Maybe TrueNAS is doing more complex probing on the disk? The TrueNAS docs do say not to use it with USB, so maybe that’s why. I may still try TrueNAS with some different enclosures.

This Proxmox ZFS + OMV solution is not bad. It’s not ideal from a management perspective, I’d rather the NAS VM knew more about the real hardware. But Proxmox is pretty good at that too. And I/O performance as measured by fio is pretty good. Some numbers:

Sequential writes on PVE (direct): 727MiB/s, 186k IOPS. ?!
Sequential writes via NFS: 70.3 MiB/s, 18.0k IOPS.
Sequential writes via SMB: 70.2MiB/s, 18.0k IOPS.

Random writes on PVE: 26.3MiB/s, 6734 IOPS
Random writes via SMB: 18.6MiB/s, 4759 IOPS
Random writes via NFS: 29.1MiB/s, 7458 IOPS

Basically this tells me it’s fast enough. The actual physical disks are probably about 100-150 MiB/s depending on where on the spindle you’re writing. So ZFS is costing us something, and then the network overhead is more, but it’s all reasonably fast for low end hardware.

Clearly that 727MiB/s number is bogus, I guess ZFS write caching. Weird because I have --end_fsync=1. If I add --fsync=10000 it backs off to about 73MiB/s, more plausible.

Samsung SSD firmware updates

This post is a rant about how bad Samsung’s SSD software is. Summary: the ISOs only boot with legacy BIOS, not UEFI. Samsung Magician for Windows is awful.

My 256GB Samsung 970 Evo used to be a system drive, then sat idle, and is now a new system drive replacing the failed one in my BOSGAME. But this new (old) drive is also suspect, I got a scary looking error from the kernel last night

[28863.608367] sd 2:0:0:0: [sda] tag#0 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=0s [28863.609453] sd 2:0:0:0: [sda] tag#0 Sense Key : Illegal Request [current] [28863.610523] sd 2:0:0:0: [sda] tag#0 Add. Sense: Invalid command operation code [28863.611537] sd 2:0:0:0: [sda] tag#0 CDB: Write same(16) 93 08 00 00 00 00 00 02 fe 90 00 00 09 70 00 00 [28863.612526] critical target error, dev sda, sector 196240 op 0x3:(DISCARD) flags 0x800 phys_seg 1 prio class 0

So I checked some error logs with nvme and the firmware version with smartctl. I had firmware 1B2QEXE7 but there might be a 2B2QEXE7. There’s no clear way to update firmware from a running Linux system, so looking for options...

Updating from ISO

Samsung makes firmware available as ISO updates. Burn a small USB disk, boot it, update. Only joke’s on me, their ISO images won’t boot on a modern BIOS. Doesn’t seem to work with UEFI at all, secure boot or no. I could get it to boot in legacy mode / MBR, at least in a test VM, but screw that. (BTW the ISO contains a Linux system, lol.)

So I gave up. I pulled the drive and put it in a USB enclosure to update on my Windows machine. Which didn’t work either.

Samsung Magician Windows Updates

Samsung has a consumer management tool called Magician. I thought it used to be pretty good but over the years it has enshittified.

I had a copy of Magician my Windows system already, version 5.0.0.790. Which lies about auto-updates. Also the uninstaller fails to handle the very simple case where the program is running in the foreground.

screenshot claiming 5.0.0 is latest version

The installer is terrible. The 8.1 installer takes most of a minute to put a window on the screen. Which then inquires if I’m a member of a European GDPR country (or Brazil), so I guess this thing is preparing to fully invade my American privacy. (I wonder if Samsung is aware of California law?) Magician installs in the years-deprecated Program Files (x86) directory. It now takes up 677MB of disk space when installed (5.0 was 25MB).

The usability is terrible. You can’t copy and paste, you have to re-type the serial number off the screen. Don’t mix up those 0s and Os! Also it has stupid formatting for the SMART data, but at least here there’s an export button. Temperature in Kelvin? Really?

Also the functionality is terrible. I can’t do anything with the USB drive I’m trying to fix. It seems upset that it can’t mount the filesystem (it’s a ZFS Linux system, no duh.) and it refuses to do anything else with the drive because of that. Not a very useful hardware management tool.

Magician also says another drive is counterfeit, an internal drive I’ve used for seven years to boot Windows. That’s not impossible, but awfully unlikely. This forum thread suggests that Magician has bugs leading to false counterfeits. Either way it locks me out of updating the firmware, and I think I’m two revisions behind. Ugh.

Magician couldn’t do anything with two of three hard drives I tried. Why is so much software is so bad? Do they not give a shit?

Update: I reinstalled Magician and ran it again and now it says the drive is legit, not counterfeit. (Also a Samsung service person looked up the serial and number said the same.) I upgraded the firmware. Revealing another bug: the firmware update says “your computer will be rebooted”. But it’s not, it shuts it down instead which caused a brief moment of panic until I thought to hit the power buttonn

Did I mention Magician has some weird input thing where it blocks my global screenshot hotkey if the window had focus? How do you even do that?!

Back to the ISO

So I tried again to boot the update tool from the ISO image. I failed. First I tried setting my BIOS to legacy boot and boot that way: it didn’t recognize the USB I burned with unetbin according to instructions as bootable. Then I tried using Ventoy to boot it as an ISO. No such luck.

The only thing I’ve seen booting this ISO is Proxmox with the legacy BIOS. I suppose I could pass through the SSD to a virtual machine, maybe via USB, and update that way. But yikes that seems risky.

So I gave up. Not updating this firmware. Thanks, Samsung. Between this mess and the disaster of data loss on 980s and 990s I’m unlikely to buy another Samsung drive.

OpenMediaVault, exFAT, writeable

OpenMediaVault, the NAS, now officially supports exFAT. It’s still a lousy choice for a Unix filesystem.

I had it working with read/write access. But then the write access stopped working. Judging by searches I’m not the first one this has happened to.

I got it working again by manually editing /etc/openmediavault/config.xml and changing the options for the fstab mount to defaults,nofail,fmask=000,dmask=000. Then I ran omv-salt deploy run fstab to regenerate /etc/fstab and rebooted. Now the Unix directory in /srv has everything with permissions 777 (whee!) and SMB users can write. Total mockery of POSIX file permissions but eh, it’s exFAT.

Some other advice from the old days was to use exfat-fuse instead of exfat. I think that’s from when the Linux kernel only could read exFAT, not write it.

The main advice is “don’t use exFAT”. Which fair enough. But it’s nice to pop a USB drive in from a Windows machine or Mac and have it on the NAS.

Proxmox notifications: gotify, email

Proxmox sends emails for important notifications, there’s nice docs. But email sucks in 2024, I have no idea how to get mail like this delivered. The only other option Proxmox supports is Gotify. I wish it had some generic HTTP post or something simple, looks like the Proxmox devs are adding webhook endpoints. ntfy.sh seems popularly requested but can be supported in a webhook. See also apprise and UnifiedPush.

Gotify

Gotify is a little self-hosted server that receives notifications and does things with them. It has very nice docs. Gonna tinker by installing it in an LXC in Proxmox. This server should really be hosted elsewhere, ideally a cloud service, but those seem to start at $9/mo so let’s just hack in a container for now.

Installing was easy with the tteck script. I added tailscale and had to manually wangle the LXC config to allow access to the tunnel device, per usual. With that gotify’s web server was available. The default login is admin/admin.

AFAICT tteck doesn’t install any config script. There’s a systemd unit to start it and the software is in /opt/gotify. I think /etc/gotify/config.yml would be a reasonable place for a config. It actually seems OK with no config file? It must have reasonable defaults, like sqlite3.

Getting Gotify up and running with Proxmox isn’t too hard. You create an application, take the token, then set up a notification destination in Proxmox. I also told Proxmox’s notification matcher to deliver to gotify. Test messages post immediately and are visible in the webapp. The Android app works but I don’t like the design: I want something else connected to Gotify and just delivering push messages to my phone.

I could also use some other delivery options. Deliver to RSS in particular. There’s a bunch of plugins and contrib stuff. No Atom or RSS! There’s a Slack plugin but it’s 5 years old and doesn’t work with modern Slack tokens.

Lots of interesting plugins for receiving notifications too. A zillion RSS receivers. Support for webhooks, yay. Also an SMTP gateway. Also appreciate this reverse proxy so I could use a public IP instead of Tailscale.

I dunno, I’m left thinking the core Gotify message router is pretty good but usability and features are not. The default message view is very limited (no time filtering, doesn’t even show the application). The Android and other delivery options look limited. I’ll keep using Gotify for now because it’s all Proxmox supports but once PVE adds webhooks or something I should re-evaluate.

Email

The default configuration has you specify an Internet email address that root mail should be forwarded to. But they don’t do anything to actually help you get email delivered. The default config will gamely just try to SMTP deliver the mail but of course no modern mail system relays mail from strangers. The mail just disappears into a postfix queue until it times out.

How about local delivery? I first tried making root’s forwarding address root, the empty string, root@localhost, or other variants. None worked: either invalid or a mailer loop. I then fixed it by removing ~root/.forward. Now postfix will write to /var/mail/root. Not ideal but at least it’s not disappearing.

Another local option is to create a second user account on the PVE host (like “nelson”) and forward root’s mail to it. But I’m trying to avoid that.

Remote delivery should be possible, in the past at least it was possible to get Gmail to relay mail for you if you were authenticated enough. But every time I look at doing that it gets harder. Screw it.

Migrating Proxmox to a new install

After my Proxmox disk failed I managed to clone the disk before it died entirely and boot from it. But that’s temporary hardware, now I want to set up Proxmox again on a new permanent disk, a 256GB 970 EVO I had lying around.

I’ve decided to go for a full rebuild, installing PVE and configuring it as if new. Then restoring all my guests from a backup. There’s a simpler path where you just restore /var/lib/pve-cluster/config.db /etc/hosts /etc/hostname but I kind of want to redo the setup. I did this before in January for a different server. This post is my boring careful notes here on exactly what I did.

Backing up old host

First thing is to back up everything on the old host disk while the old host is still working. I stopped all the guests and did a full backup of every single one. This is the precious data, what I’ll be restoring.

Second is to back up /etc and /var/lib/pve-cluster/. Note that /etc/pve is special and backed by a live-mounted database in pve-cluster. I’m backing up the stuff in /etc/pve as if they were normal files (for future diffing) and taking a backup of the database with sqlite3 config.db ".backup 'config.db.backup'.

After shutdown I’m going to unplug the old host disk for safekeeping, if things go badly I can use it to restore. Note it’s awkward to read the files on it because after you install a new Proxmox you end up with two ZFS pools named rpool that both want to mount to /. zpool import -d -R should help with that but I found it tricky. Instead I’ve backed up the files I want to read to the backup disk.

Installing new Proxmox PVE server

Do the regular Proxmox install from USB. There’s very few options there, I love how simple the Proxmox installer is. But this is what I did:

  1. ZFS RAID0 as the filesystem, with the one internal SSD
  2. United States, UTC timezone, US English keyboard
  3. Password and email as nelson@monkey.org even if I never have set up outgoing mail
  4. Hostname gvpve. Verify IP address is correct (thank you DHCP).

Improving Proxmox install

These are my generic customizations to any new Proxmox install

  1. Add my ssh key to ~root/.ssh/authorized_keys. Don’t disturb the key for root PVE made!
  2. Run the tteck helper script “Proxmox VE Post Install” and accept all defaults. This does a few things to make a new install nicer.
    • enable no-subscription repositories
    • disable the nag message
    • disable the high availability services (pve-ha-lrm, pve-ha-crm, corosync)
    • software update to Proxmox (takes a few minutes)
  3. Reboot
  4. Install some useful software. apt install joe sudo avahi-daemon
  5. Install tailscale. Start with tailscale up --accept-dns=false. Disable key expiry in Tailscale console.

Restoring my guests

Proxmox can do all this automatically if you have a cluster, this task just becomes a migration. (Automatic, if you have HA configured.) But it’s nice to do it manually as a recovery exercise.

  1. Plug in the USB disks for backups and USB media and verify with lsblk
  2. Restore /etc/fstab mounts for these disks (look at backup file from old server).
  3. Mount /mnt/backup and /mnt/usb-media
  4. Under Datacenter > Storage, add my Proxmox backup volume
    id: backup, type: Directory, Content: VZDump backup file, Path: /mnt/backup
  5. Remove “backup” as a content for the storage named “local”
  6. Under Datacenter > PVE > Backup, locate the files for the backups I took just before shutting down old host
  7. Restore each one manually (a lot of clicking!). Re-type the guest IDs instead of taking newly assigned ones. Probably unnecessary.
  8. Reboot to start all the relevant guests.

The restores all went pretty well, Proxmox backs up the configuration of the guest as well as the guest’s disk images. For some reason the config for a TrueNAS VM changed, it added back the ISO for the install media. This could actually break the guest although it’s easy to fix. The vmgenid also changed on every VM.

Finishing up

  1. Add my Influx DB as a system metrics server
  2. Create a new backup job on Proxmox
    All guests, 9am, keep 6 monthly / 4 weekly / 7 daily
  3. Test a manual backup. MISTAKE. The daily retention policy means this manual backup erased the reference backup from earlier today. I’d already used those to restore all my systems, so it’s probably no big deal, but definitely not the right thing to do.

I tried diffing the old server’s /etc/pve (on backup disk) to the new one. Didn’t learn anything really. Lots of differences but most of them are what you’d expect, new security keys. Also missing config files because I looked before I restored the guest hosts. I did spot the config change for the TrueNAS VM though, still puzzled by that.

Proxmox split disk idea

A setup I did not pursue, but seemed an interesting idea.

Proxmox by default installs itself to a disk and takes over the whole disk. You can set it up with ext4 (LVM) or zfs and use that disk usefully for guest disk images, ISOs, backups, etc. But the whole thing belongs to Proxmox.

What if instead you install Proxmox to a small partition, it only needs 16GB. And then allocate the rest as a ZFS pool? That seems like a clean separation. It also means you can use ext4 for Proxmox which might make recovery simpler.

I went down this road, following notes similar to this guy. I told Proxmox to install to 32GB ext4. It creates a partition #3 with LVM. Inside is 3.8GB for swap, 13.6GB for root, and two 11.6GB marked “pve-data”. The rest of the disk is then unused.

So I used fdisk to add a partition of type bf01 (zfs). The next step would be creating a zpool on it, then telling Proxmox to use that as storage for things. But I realized in the end I’d just be replicating more or less what Proxmox does by default with a ZFS install, only with non-standard names and setup for questionable benefit. So I stopped.

There’s something vexing about systems having very capable but unreliable SSDs as their install drives. I want to use that storage better!

Some ZFS exploring, disk recovery

My BOSGAME N100’s boot SSD failed. So I learned some ZFS to recover the files. I don’t think too much important is on this disk. Proxmox has been faithfully backing up system images to another drive and I have no reason to doubt them. But I’d like to rescue the Proxmox system itself, particularly since I don’t remember what all I customized on it (and don’t have a backup).

Summary

This post is more scattered than usual and unlikely to be interesting. This is what I learned:

  • You can boot off a dd clone of the Proxmox ZFS boot disk and it will work fine.
  • My disk failed with random access reads but I could use dd to clone it still. Weird.
  • You can recover the files on a ZFS pool with a system rescue disk. The key command is zfs import which brings the pool online in a new operating system.
  • zpool list and zpool status give you basic info. zdb is useful if you can’t get a pool online
  • Cheap SSDs are not to be trusted.

Lots of details

The big help here was the SystemRescue-ZFS fork. That’s the venerable Linux SystemRescueCD modernized and with ZFS installed for you.

ZFS docs are confusing. There were a bunch written really well by Sun and/or Oracle in the early days. But that was over a decade ago. OpenZFS has good man pages but I’m missing an overall gestalt of understanding the system. And ZFS is complicated, it’s a comprehensive implementation of a lot of data storage concepts.

Claude was a big help for me exploring ZFS. So was this StackOverflow post which has some recovery commands to try. And this recovery book was mildly helpful but is mostly about how to recover from partial failures where your pool still exists. My whole pool is gone because I’m using ZFS on a single disk, shame on me. These Proxmox docs for ZFS are also helpful.

One ZFS concept I’ve learned: ZFS doesn’t really have fsck. It’s constantly fixing itself (hopefully), there’s no big check-the-thing-offline. (scrub is the closest it gets.) A second concept I’m only getting now: ZFS has a notion of “imported” pools, where the ZFS system becomes aware of some storage. It’s a little like mounting a filesystem but it is not just mounting into Unix namespace, it’s also enabling all the access to the pool, datasets, filesystems, etc.

Another key concept: Proxmox creates a ZFS pool called rpool for its system boot disk. That’s what’s not working for me.

Using SystemRescue

SystemRescue is great, and the ZFS fork is perfect for me. Try setfont -d if the console font is too small. Remember that Linux lets you have multiple console windows: Try Ctrl-Alt-F2 to switch to window 2. Even better set a root password and then systemctl stop iptables.service so you can ssh in from a humane terminal emulator.

Cloning the bad disk

I suspected hardware failure so first thing I did once I had the rescue system booted was dd if=/dev/sda of=/dev/sdc bs=1M to do a block by block clone of the disk. This worked with no hitches, suggesting maybe the disk is not entirely gone. I unplugged the backup, that may be crucial since ZFS might be confused by having two copies of the same pool.

Exploring the problem disk with SystemRescue

I booted SystemRescue and first thing I tried was zpool status. It says no pools available. Same thing with zpool list. Um, is that bad? (I’d briefly tried Proxmox rescue too and it said the same thing). So I asked some AIs to go deeper and got to the ZFS debugger. zdb -lu /dev/sda3 does find some ZFS labels and stuff that I need. So the data is there and at least a little ZFS-shaped.

Asking more AIs I learned that you have to “import” a pool: presumably this SystemRescue ZFS system has never heard of this ZFS pool and so didn’t import it. Sure enough zfs import finds my missing rpool. It doesn’t want to import it by default because it wasn’t cleanly exported by some previous system. But I can zfs import -f rpool to force it. Which I have done and it takes an alarmingly long time to respond! What’s it doing? After a couple of minutes it gives up and says cannot import 'rpool': one or more devices is currently unavailable. That’s bad right?

Yes, it’s bad. journalctl has the news. The kernel module ata2, the driver for the SSD, is reporting errors. A lot of them, but the bad ones are failed command: READ FPDMA QUEUED, hard resetting link, COMRESET failed, and eventually ata2: reset failed, giving up. At which point zio and sd 1:0:0:0 start complaining about read errors. Also I have to reboot now, /dev/sda is no longer a working device.

This sure seems like a hardware failure to me! I wonder why the dd worked though? Maybe it’s just random access reads that fail? Or maybe zpool import was trying to write and it’s the writes that are failing? But those errors were triggered by reads... I tried again with zpool import -o readonly... and got the same errors. I think this disk is cooked.

Exploring the cloned image

I took a gamble and tried to import the backup cloned disk image disk. It worked immediately! zpool import -o readonly -d /dev/sdc3 -f rpool. Note I’m using the -d option to specify what device to import from because I think I have two different disk devices with an rpool on them (one of which is offline.) Also that readonly turns out to be a lie.

I think zpool import tries to mount all the filesystems where they were last time. But there was some error about rpool/ROOT/pve-1 not mounting, I assume because it wanted to mount to /. So nothing mounted. I can manually mount other filesystems with zfs mount but I really need pve-1 and it really wants to mount to /.

In theory zpool import -R /tmp/restore should mount everything under /tmp/restore. But I kept getting confusing errors. I finally got the thing mounted by doing zfs set mountpoint=/tmp/rr rpool/ROOT/pve-1. Which mounted it under /tmp/restore/tmp/rr, not what I wanted, but close enough. (Note this edit was permanent, written to the disk, despite the pool being imported readonly. I had to undo it later.)

Anyway all this hackery later and I have access to my files! They are mounted and I can make a backup of my Proxmox boot disk.

Backing up Proxmox PVE itself

One annoying thing about Proxmox is it has no system for backing up Proxmox itself. Everyone says “don’t customize it, just run guests and back those up” and mostly that works but still, it’d sure be nice to have a backup for situations like this.

Here’s a five-year-old gist backup script. The discussion there is more valuable than the script. It backs up a bunch of stuff in /etc one by one. Me, I just took all of /etc.

The Proxmox docs for Recovery are also useful. They suggest backing up /var/lib/pve-cluster/config.db /etc/hosts /etc/hostname.

Big gotcha here: a lot of configs are in /etc/pve. But those aren’t normal files stored in ZFS. Instead that’s a FUSE filesystem Proxmox runs (keyword pmxcfs) so in my non-running system here /etc/pve is empty and my tar got nothing. Those files are backed by a sqlite database in /var/lib/pve-cluster/, as the docs above discuss. With the system offline you can just copy those files. With it online and live something like sqlite3 config.db ".backup 'config.db.backup'" is safer.

Setting up a replacement Proxmox

Now that I have a backup of my files I’ve got several options to bring something back online.

  1. Try jiggling the SSD a bit, maybe it’s just a loose connection? This problem started after I opened the case, maybe I disturbed it. Nope, no such luck.
  2. Try booting off the clone I made. That might Just Work, actually. Probably should make a second clone first. Yep, this worked!
  3. Reinstall Proxmox on clean disk, then follow those recovery notes to do a quick restore. But I have to re-apply whatever other customizations I did myself, too. And manually restore all the guest hosts.
  4. Reinstall Proxmox and just configure it again. May not be much more work than #3.

No matter what I do I should replace that SSD, I’m never going to trust it. Was a cheap one anyway.

New Install

Option 2 worked so I have a working server again. I ran zpool scrub just to be safe and it found no errors.

But I’d like to install cleanly on a new SSD. So I ordered a 1TB WD_BLACK 1TB SN850X based on these reviews. I used to be a Samsung partisan but they really screwed up with the 980s and 990s. There’s an argument that you should just use a tiny scratch drive to install Proxmox on, or maybe a fancy enterprise-grade SSD instead. Eh, I’ll go with this. (No one makes high quality 512GB SSDs anymore!)

I will probably go with option 3 on this new install. Reinstall Proxmox, but then clone the config by copying a few files around. If I’m patient I should do option 4 and change the way some things work on my system. This was the first Proxmox install I did and I could do a cleaner job the fourth time around.

Bonus: Exploring a healthy Proxmox install disk

Before I worked on the bad disk I took a look at what a good disk looks like in ZFS. Here’s some things I learned from a working Proxmox system with no problems. Proxmox is installed to a single 2TB SSD with default ZFS options.

The physical disk is /dev/nvme0n1. Proxmox created three GPT partitions. fdisk tells me nvme0n1p1 is about 1M big and is labelled “BIOS boot”. p1 is 1GB big and is “EFI System”. The rest of the disk is in partition 3 labelled “Solaris /usr & Apple ZFS”. lsblk -o +PARTTYPE will show the GUIDs for the types and that partition 3 is 6a898cc3-1dd2-11b2-99a6-080020736631. Which honest-to-goodness has two meanings in this reference table. (Neither of which are “OpenZFS” or “Linux ZFS”, lol.)

lsblk also shows the SSD partitions and a couple of USB drives I have. And a bunch of /dev/zd* devices, which I gather are device names for ZFS snapshots or datasets or something. Presumably I shouldn’t mess with them.

zpool status shows that I have one pool named rpool, that’s what Proxmox created. It has one device in it, nvme-eui.002538b22140b542-part3, which corresponds to my SSD partition. zpool list shows me a basic status of rpool, how much disk space is free and the like.

zfs list shows me a whole bunch of datasets in ZFS, I think this is the top list of every thing in this pool. Most of these are under rpool/data and are either filesystems (for containers) or disk images (for VMs). But there’s also a few extras that I think are related to the PVE host: rpool/ROOT/pve-1 is the important one, also rpool/var-lib-vz. rpool/ROOT and rpool itself exist but seem pretty empty, mostly there to hold the subdirectory rpool/ROOT/pve-1.

zfs list -t snapshot shows snapshots, just snapshots and not the primary datasets.

mount | grep rpool shows me a bunch of ZFS things mounted in various places. rpool/ROOT/pve-1 is mounted on /, that’s my root filesystem. Most other things are mounted under /rpool and include a bunch of subvolumes for containers filesystems.

zfs get all rpool/ROOT/pve-1 gives me a very deep list of properties for the root filesystem. Not much of interest here but it’s exhaustive.

zdb -l /dev/nvme0n1p3 is a low-level ZFS debugger, it shows the labels on the disk device. I have a single one, “LABEL 0”, with the name rpool, a hostname that matches my PVE host’s name, and a bunch of stuff I don’t understand. Mostly looking at this because it was helpful with the broken disk since zpool wasn’t even showing it.

Linux console fonts are too small

My eyes are getting older and I have big screens: the default Linux console fonts are too small. And I’ve been spending more time than I’d like in consoles lately. Some ideas here for coping.

setfont -d is the quick fix. This will double the size of the current font as a one-off thing.

setfont in general is the tool for changing fonts. But it’s hard to find a nice clear choice for an alternate bigger font, there’s a list of a zillion for different languages. I should go find one good font that’s likely be available on a system and remember its name.

dpkg-reconfigure -plow console-setup works on Debian systems and gives you a nicer chooser.