Some Bits: Nelson's log

13 posts about zfs

ZFS on an external USB drive

I’m liking ZFS so much I decided to use it on my new media storage drive. A 14TB external USB drive with video and music files. The serious nerds who use ZFS will tell you that USB is unsuitable and there’s no point in using ZFS without reundancy. Phooey!

It works quite well. You plug the disk in, create a pool on it (with just the one disk), and you’re done. It automounts for you. You can create datasets to segregate data and they automount. (Be aware you can’t efficiently move files between datasets, that ends up being a byte by byte copy.) And as a bonus you get ZFS features like checksums, deduplication, snapshots, etc. It’s nice!

What happens if you unplug the disk? If you unplug while the disk is mounted (“imported”) it’s a total mess. Don’t do that. This is the problem with USB, it can be a bit flaky and act like it unplugs itself, but I think that’s mostly a problem of the bad old days. So far so good!

If the disk is unplugged and the system is rebooted, the directories won’t exist at all. This is different from ext4 or other fstab filesystems. For instance, say /jukebox is my USB disk. With ext4fs I have to do a mkdir /jukebox before mounting, so there’s a /jukebox present on the root filesystem. The mount replaces the directory. If the disk doesn’t mount you still have that /jukebox visible and other stuff might try to use it. Instead if you have a ZFS pool named “jukebox” it just automounts to /jukebox even if that name doesn’t exist at all in the root filesystem. And if it doesn’t mount, that means there’s no /jukebox at all. In my case I’m using these USB disks as bindmounts for LXC containers. Proxmox notices the directory doesn’t exist and refuses to even start the container. I like that failure mode.

Mostly the disk is plugged in though and ZFS seems to work pretty well with it.

(Elsewhere I have a deployed system with ZFS mirroring deployed on two USB disks in the same enclosure. This also seems to work reliably, after one USB hiccup scared me right at the start.)

Hacking Proxmox boot process (ZFS)

I’m upgrading my main Proxmox home server from a single SSD with ZFS to two SSDs mirrored in ZFS. Some discussion here. The simple thing is just to reinstall Proxmox new but I’m going to try to do it in-place first. Either way requires careful backups.

The docs on changing a failed boot device are the in-place process I’m following. More or less. It boils down to “set up the new disk in ZFS, then run proxmox-boot-tool to make it bootable”. The blessing process is complicated. Booting with ZFS is always tricky. And Proxmox is rumored to have a special thing where it installs boot loaders on all mirror devices for redundancy. I want that with my new drive! This post is me learning about how it all works.

Summary: this worked very well and is simpler than imagined. Also Proxmox is remarkably well documented. Hurray!

How is Proxmox booting now?

A year ago Proxmox installed something that made it boot from ZFS. Works great. What’s it doing? The challenge is Proxmox has three different ways of booting and I’m not sure which mine is. These docs on using the boot tool are helpful. Some other useful docs here. I should just plug in a monitor and look at the boot process but no, I’m stubborn. The docs say proxmox-boot-tool status will show you the current boot method but the output is not illuminating.

System currently booted with uefi
4B96-7CDC is configured with: uefi (versions: 6.5.13-6-pve, 6.8.12-1-pve, 6.8.12-2-pve)

Yes, it’s UEFI, I knew that. But is that GRUB? Something else? Looking around for advice in docs and from Phind I got some other ideas to try, looking at the EFI boot options:

# efibootmgr -v
BootCurrent: 0002
Timeout: 1 seconds
BootOrder: 0002,0003,0001,0004,0005
Boot0001* UEFI:CD/DVD Drive BBS(129,,0x0)
Boot0002* Linux Boot Manager HD(2,GPT,55f108de-abfa-4dad-b478-641a6d640390,0x800,0x200000)/File(\EFI\SYSTEMD\SYSTEMD-BOOTX64.EFI)
Boot0003* UEFI OS HD(2,GPT,55f108de-abfa-4dad-b478-641a6d640390,0x800,0x200000)/File(\EFI\BOOT\BOOTX64.EFI)..BO
Boot0004* UEFI:Removable Device BBS(130,,0x0)
Boot0005* UEFI:Network Device BBS(131,,0x0)

So that says it’s “Linux Boot Manager”, which is systemd (why doesn’t it say so?). Other docs I read suggest ZFS systems boot from a whole Linux system installed in the ESP. That may involve systemd too. In any case it probably does not involve GRUB. I finally hooked up a monitor and rebooted and saw a menu but it didn’t quite look like GRUB. I did see a message go by about EFI Boot Stub.

Bottom line: I think I’m booting with Linux Boot Manager which involves systemd and a Linux kernel on the ESP partition. Not GRUB.

It’s possible to inspect the boot stuff. It’s on partition 2, the ESP partition in a VFAT filesystem. It has stuff in it like EFI/BOOT/BOOTX64.EFI, EFI/proxmox, and loader/entries.

Identifying the disks

/dev/nvme1n1 is my existing Proxmox boot drive, a zpool with just the one disk in it. I want to add /dev/nvme0n1 to the pool and make it a mirror. But there’s many ways to name a device on Linux and you want a stable name. (Fun fact: the drives on 0 and 1 have swapped between reboots without me changing the hardware.) What’s best?

zpool status -v rpool tells me the status of my existing one disk pool.

        NAME                               STATE     READ WRITE CKSUM
        rpool                              ONLINE       0     0     0
          nvme-eui.002538b22140b542-part3  ONLINE       0     0     0

What is that EUI string? That’s another name for /dev/nvme1n1p3, the “Extended Unique Identifier”. A 64 bit ID, different from the UUIDs, serial numbers, and other identifiers I’ve used before.

I first found this same name with this query: udevadm info --query=all --name=/dev/nvme1n1. But I don’t really know what that tool is. Simpler is ls -l /dev/disk/by-id/ | grep nvme, which shows that nvme-eui.002538b22140b542-part3 is (currently) a symlink to nvme1n1p3. That I understand. So I looked for what linked to nvme0n1 and found that nvme-eui.002538bc3140272b-part3 is the name for the new SSD’s partition 3.

Adding the ZFS mirror disk

OK, time to do surgery on my machine. I am more or less following this guide.

Step 1: clone the partition table to the new disk. sgdisk /dev/nvme1n1 -R /dev/nvme0n1. After doing this the new disk has the same layout as the old one. blkid will show the partitions. (Although confusingly blkid doesn’t show filesystem types: fdisk showed they were labelled as VFAT etc, just like the original disk.) However the UUIDs of each partition are the same too which is not good, we’ll change that soon.

Step 2: give partitions unique UUIDs. sgdisk -G /dev/nvme0n1. Partitions are the same but now they have new IDs.

Step 3: attach the new SSD to the pool. zpool attach rpool nvme-eui.002538b22140b542-part3 $nvme-eui.002538bc3140272b-part3. Why attach and not add? (Edit: add expands storage, attach mirrors it.) Not sure but that’s what Phind told me to do. This pauses a couple of seconds and then returns. zpool status -v rpool shows what’s going on. The ZFS docs suggest that “attach” is a special thing that only directly mirrors devices. I would have guessed zpool add would have been the command to use but that seems to be a more general purpose thing for other configurations with vdevs and maybe RAID-Z.

  pool: rpool
 state: ONLINE
status: One or more devices is currently being resilvered.  The pool will
        continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
  scan: resilver in progress since Sun Oct 27 19:49:41 2024
        114G / 114G scanned, 2.24G / 114G issued at 2.24G/s
        2.31G resilvered, 1.97% done, 00:00:49 to go
config:

        NAME                                 STATE     READ WRITE CKSUM
        rpool                                ONLINE       0     0     0
          mirror-0                           ONLINE       0     0     0
            nvme-eui.002538b22140b542-part3  ONLINE       0     0     0
            nvme-eui.002538bc3140272b-part3  ONLINE       0     0     0  (resilvering)

Just a bit later it reports resilvered 116G in 00:01:02 with 0 errors on Sun Oct 27 19:50:43 2024. Nice! These SSDs are fast.

At this point the ZFS stuff is all done. The system reboots fine. I did a zpool scrub for good measure and it reported no errors. I’m now getting most of the benefits of ZFS mirroring for data integrity. However there’s still only one boot device: if that fails, I’ll have to recover with some other boot media.

Installing boot stuff on the new disk

Proxmox has extra stuff for making boot more durable. proxmox-boot-tool manages it. See docs here.

Step 1: I verify that the new disk doesn’t have a boot ESP partition. Device names have changed on me after I rebooted, so /dev/nvme0n1p2 is the original bootable partition. /dev/nvme1n1p2 is the new one.

# old=/dev/nvme0n1p2
# new=/dev/nvme1n1p2
# mount $old m
# ls m
EFI  loader
# umount m
# mount $new m
mount: /tmp/m: wrong fs type, bad option, bad superblock on /dev/nvme1n1p2, missing codepage or helper program, or other error.
       dmesg(1) may have more information after failed mount system call.

Step 2: format the ESP on the new disk. proxmox-boot-tool format $new. After this there’s a brand new VFAT filesystem on the partition, it is empty.

Step 3: get Proxmox to install its boot process on the new disk as well as the old. proxmox-boot-tool init $new. This copies all the kernels, etc to the new disk and enrolls it so updates should be written to it. After running this both disks have nearly identical boot partitions.

Step 4 (option): refresh. proxmox-boot-tool refresh. Just a sort of verification thing, shouldn’t be necessary, but it writes the kernels again to all enrolled disks.

Rebooting

It works! On reboot it just loads like nothing’s changed.

In the BIOS I now see more EFI boot options. Linux Boot Manager is now on both disks, other entries are also doubled. The EFI boot menu is totally rewritten and has two extra entries.

# efibootmgr -v
BootCurrent: 0000
Timeout: 1 seconds
BootOrder: 0000,0002,0003,0004,0001,0005,0006
Boot0000* Linux Boot Manager    HD(2,GPT,63a5e06a-3206-4a55-957c-0878a2275a8c,0x800,0x200000)/File(\EFI\SYSTEMD\SYSTEMD-BOOTX64.EFI)
Boot0001* UEFI:CD/DVD Drive     BBS(129,,0x0)
Boot0002* Linux Boot Manager    HD(2,GPT,55f108de-abfa-4dad-b478-641a6d640390,0x800,0x200000)/File(\EFI\SYSTEMD\SYSTEMD-BOOTX64.EFI)
Boot0003* UEFI OS       HD(2,GPT,55f108de-abfa-4dad-b478-641a6d640390,0x800,0x200000)/File(\EFI\BOOT\BOOTX64.EFI)..BO
Boot0004* UEFI OS       HD(2,GPT,63a5e06a-3206-4a55-957c-0878a2275a8c,0x800,0x200000)/File(\EFI\BOOT\BOOTX64.EFI)..BO
Boot0005* UEFI:Removable Device BBS(130,,0x0)
Boot0006* UEFI:Network Device   BBS(131,,0x0)

The real question is what happens if the boot disk fails. Will the system still boot? In theory yes, if you have ZFS mirrors and Proxmox’ magic boot setup. I don’t want to pull the M.2 drive in my machine to test it so I don’t know if it works. There’s two genuine looking boot partitions both listed in the EFI boot menus so I think odds are good.

Vault: towards my own NAS

Working on rationalizing my file storage now that I’m in a Proxmox universe. The idea here is to put all my important stuff on a NAS VM running the following services:

  • NFSv4
  • Samba
  • Syncthing
  • Restic with BackRest

I’ve got a basic cut at it working (other than Samba) and it seems good. Some notes on what and why.

Contents

What am I storing on the NAS? Very little right now, but the plan is:

  • 14GB of source code. Most of this never changes and it’s mostly small files although some 1GB data blobs sneak in occasionally.
  • 7GB of Windows Documents. Random stuff here but it’s helpful to sync and backup.
  • < 1GB of files on mobile devices. I use Syncthing to get stuff off my Android devices.
  • 4TB of Media archives. NFS and SMB mounted locally. No Syncthing, no backups. Right I am manually rsyncing them occasionally to the second house. I may migrate this to backups (local only, Backblaze is expensive) and Syncthing.

Access over the Internet

The challenge here is I want my files accessible over the Internet, because I have two houses. My house with Starlink is 50ms away from the house with the server (and Sonic fiber). NFS and Samba are only good for LAN access. Those network file systems sorta work over the Internet but it’s slow and awful.

So instead I’m using Syncthing to maintain a working copy of files on my local machine. That makes my setup a lot like what Dropbox or other cloud drives is doing. I’ve done it for years with important stuff including all my source code and it’s worked fine. A key thing here: I am almost never modifying files in two places at once. Syncthing has a conflict resolution system for that but it’s a little primitive.

I’m using Tailscale for now to access the Syncthing server on the vault. That shouldn’t strictly be necessary.

Storage medium

Where are my files stored? On virtual disks that Proxmox provides. Those virtual disks are allocated on a ZFS pool that Proxmox maintains. That way the NAS VM doesn’t need to use ZFS directly, instead it just puts an ext4 filesystem on the virtual disks and it’s simple.

It’s a little weird that ZFS doesn’t see the individual files and the NAS is unaware of the ZFS pool status. But it turns out almost all the advantages of ZFS operate at the block level. Proxmox creates the virtual disk as a ZFS dataset, a block device, and ZFS will happily snapshot and compress and checksum and self-heal those blocks for me. There are a few filesystem-level ZFS features (like ACLs) but I don’t really care about them, so not having them in the NAS is no big loss.

The other option would be to pass through raw disk devices to the VM and let it run a ZFS pool itself. That’s more like what a TrueNAS setup does.

Still on the fence about what physical media I’ll use. So far I’m doing it on a single SSD in the Proxmox server. I think a pair of spinning disks with mirroring makes sense for the media archive but might be a little slow for the NFS clients accessing the source code.

I’m using Restic (with Backrest) for two sets of backups. One of everything to local disk, an extra disk in my Proxmox server. (See this pattern). One leaving out the media archives to Backblaze.

Product design

So far I’m at the “hack config files” stage of building this out. And that’s fine. Backrest and Syncthing already offer Web GUIs. I’d like to streamline the NFS and Samba configs so I don’t have to keep re-referencing the same disk volume over and over in several config files but eh, whatever. I could imagine making this into an actual product other people could use but it’d take a lot of configuration and testing. The VM might also make a good NixOS project.

Why not Cockpit for a GUI? It might actually be a good idea, I’ve never tried it.

Why not TrueNAS or OMV? Partly because I don’t like either very much. Also because neither supports Restic or Syncthing. You can install them in the VM but it’s kind of a kludge and really, I’m OK just managing NFS and Samba myself. TrueNAS can also manage a ZFS array which would be a different storage solution than what I’m doing.

As always with hacker projects there’s a lot niceties of monitoring and alerting I should be doing but haven’t set up yet. At least Proxmox ZFS will tell me if something catastrophic happens to the data.

Wrinkles

One problem with any NAS is managing file ownership. The POSIX file model is very clear for ownership and permissions. But SMB kind of screws that up. And so does Syncthing: it really wants to run as a single non-root user. (Although it has some support for multiple owners). For now I’m going to stick with POSIX files but they’re all just owned by me. That’s a good match for my data. OTOH I am allowing NFS clients to be root on the server, so maybe I can do more when Syncthing isn’t involved.

NFS still sucks for clients when the server fails. I’m mounting with noauto,x-systemd.automount,x-systemd.idle-timeout=60,soft,timeo=15,retrans=2 which first of all, lol, why aren’t the defaults adequate? And x-systemd really? But it seems to work; if the server is down the client will throw an error in under a minute.

Setup details.

The Vault VM is set up to use two vCPUs and 2GB of RAM. There’s a 4GB disk for the system volume (including 0.5GB of swap) and then as many user data volumes as I want.

I’m running Debian 12 on the VM with just the basics installed: nfs-kernel-server, samba, syncthing, backrest. The system seems to be using an actual 400MB of RAM, very little. I think the most RAM-hungry thing is Restic, it likes to do a lot of housekeeping when de-duping backups etc. It might make sense to give more RAM to the NAS just for it to cache files its serving.

Right now I’m mounting the datasets on virtual disks into /mnt/UUID, big ugly names. Then I have a second fstab entry to bind mount from /mnt/UUID to /export/friendlyname. Trying to reference the datasets everywhere else with the /export name.

Some specifics:

  • /etc/interfaces: modified to add 192.168.240.* subnet for sharing within Proxmox
  • /etc/fstab: edited to mount disks into /mnt and bind mount into /export
  • /etc/exports: individually names each /export filesystem so NFS will send them
  • /etc/default/nfs-kernel-server was modified to be NFSv4 only. Debian has some docs on this but they seem to be badly out of date.
  • Backrest config is mostly in ~root/.config/backrest, also the systemd unit file. The GUI manages that.
  • Syncthing runs as user nelson via systemd user (with loginctl linger enabled so it runs without me being logged in). The GUI manages configs, they are stored in /home/nelson/.local/state/syncthing

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.

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!

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.

Towards a Proxmox NAS

After trying out OpenMediaVault and TrueNAS I’m still left wanting a good NAS for Proxmox. It seems odd to me that the Proxmox folks don’t have their own product. They’ve got most of the pieces already, and a similar product in Proxmox Backup Service. They also bet heavily on Ceph but that’s a high performance distributed storage system, not a simple SMB or NFS server.

Update: HexOS might be worth keeping an eye on. It’s TrueNAS with usability stuff on top for ordinary users.

Now I’m wondering if I should just roll my own NAS services in a container or VM. I’m kind of doing that already, it works fine. I’m not going to make a fancy GUI for it, I’ve been editing /etc/exports and /etc/samba/mb.conf for 20+ years, why stop now? Although Cockpit and the file-sharing plugin might work?

The key thing here is Proxmox can manage ZFS itself. It seems strange to pass through disk hardware devices to a VM to have a separate kernel manage the disks when Proxmox can do it. So here’s the idea:

  1. Create a ZFS pool in Proxmox for NAS data.
  2. Create datasets for network file shares in Proxmox.
  3. Do not make filesystems or mount the network file shares in Proxmox itself
  4. Install Debian in a VM, maybe with Cockpit as a GUI.
  5. Pass the network file share datasets in as VirtIO-SCSI single disks to the VM.
  6. Configure samba and NFS in the VM to share the disks
  7. Bonus: disks can be shared on a private Proxmox-only bridged network for other guests to access them.
  8. Optional: install syncthing in the VM
  9. Optional: enable Restic backups of the file shares in the VM

The part I’m not entirely clear about is the “VirtIO-SCSI” part. I like the idea that ZFS is in Proxmox. What I don’t know is how good performance is virtualizing it t his way. And you don’t have ZFS-level features available in the VM like snapshots and stuff, you would want to use simple ext4fs or something. (ZFS-in-ZFS is possible but can quickly cause problems.) That’s not ideal, ZFS snapshots (for instance) are great for backups. OTOH you can use Proxmox own backup software for the datasets.

Another option would be to create and mount the filesystems in Proxmox and then pass them to all the guests with virtiofs. You wouldn’t even need SMB or NFS if you aren’t sharing data outside Proxmox! But virtiofs isn’t fully baked yet, Proxmox kinda supports it but not fully.

I’m also not clear if a VM is necessary; you might be able to do this all in a container. In that case you’d make the filesystems and mount them in proxmox, then pass them through with a bindmount.

I think there’s a potential product here, a new NAS operating system. Designed to be used as a VM inside Proxmox with Proxmox managing the storage. Just a small thing to publish network shares. Building a real product is a lot of work though, particularly if you want a GUI.

But maybe I’ll make this VM for myself just as a hack. Honestly I’ve done most of the pieces in different ways already, the difference here is being more systematic with managing the storage in Proxmox. I bet in two hours I could have NFS and Samba fully set up and going.

I wonder if this would be a good NixOS project?

Proxmox moving to a new server

I migrated my first Proxmox system to a new server. It went very well. Basically you just back up all the containers and VMs, restore them, and Bob’s your uncle. Took under an hour, more because I did a test run installing to an external USB disk first. Really I’m migrating to the same server, I just wanted to switch from btrfs to zfs.

Proxmox backups include not only the guest OS image but also Proxmox’ own configuration. The restore is smart enough to adjust the config to, say, handle that the virtual disk image now lives in ZFS. The only place anything failed is that my VM had a virtual CDROM mounted; the restore still referenced the image via BTRFS. Then again the CDROM didn’t even exist in the new zfs server, I no longer needed it. No big deal: the error message was clear and I could easily edit the config to remove it.

The other hassle was restoring Proxmox itself. There’s no way to back up a Proxmox server, just its guests! I think they’re idea is you’re using a cluster with several servers and so if one fails you just add a new host and have it learn what to do. Still seems like they should have a backup option.

For a small home user it’s good discipline to do as very little on the Proxmox server itself as you can. I made a checklist of things to set up on the new one, here’s a quick list:

  • update repositories and upgrade
  • configure /etc/fstab to mount my disks
  • configure backup disk as new storage type
  • set up guest backup schedule in the GUI (again)
  • add a system metrics server
  • apt install joe sudo avahi-daemon
  • install a user nelson for convenience but try not to use it
  • install tailscale and remember --accept-dns=false

I tried a couple of things to verify the new Proxmox was configured the same as the old without a lot of success. I was hoping that comparing /etc/pve would tell me more, that’s where Proxmox keeps its configs. But mostly it was stuff you’d expect to be different: crypto keys, details related to file system storage. Hard to find meaning in the noise. I was glad to find jobs.cfg though with a record of my backup configuration. (Note that /etc/pve is actually a pmxcfs FUSE filesystem for clusters; the actual truth lies elsewhere.)

Really pleased at how all this was. Virtualization is great! Next time will probably take half an hour at most and most of that time is waiting for disk images to copy around.

Proxmox disk wear

Does Proxmox 8.1 wear out my disks? Maybe. A fairly idle Proxmox server is writing 40GB a day and I think most of that is wasteful. My SSD will last 10+ years at that rate but maybe I can make it better. So I looked more closely and in the end concluded most of the write activity is related to the guest operating systems I’m running, not Proxmox itself. Proxmox alone is writing about 50KB/second of data.

Wear is a concern with consumer SSDs; even a high end Samsung 980 Pro is rated for only 600 TB of writes for a 1TB drive. (Enterprise SSDs are 3x that or more.) It should be enough for an ordinary home server not doing a whole lot but a misbehaving system could make things bad. There’s several kinds of misbehavior with different solutions.

The Proxmox subreddit is full of posts like this or this with people noting high wear on their SSDs. The discussions are muddled. Someone says “it’s a problem!” and several people immediately respond “not a problem for me”. Inevitably someone says “buy an expensive enterprise SSD you fool”. Out of that noise I’ve found some pattern: Proxmox can write a lot of data.

Measuring disk writes

How do you measure the problem? The easy way is to use the Proxmox GUI to look at “Disks” for the host; the last column is “Wearout”. That’s current state of use and comes from SMART data. (Or should; my cheap N100 server doesn’t have the info.) Take a look, you may be surprised! I haven’t run Proxmox long enough to really know, my old Ubuntu server was running for a year+ without Proxmox and is only at 1%.

You can also get more insight by setting up system metrics on Proxmox. That has it export data to an Influx database when you can then visualize with Grafana.

More hands-on, you can measure write load with various Linux IO tools. Good old iostat is one way, ZFS has its own version of that:

$ zpool iostat

capacity operations bandwidth
pool alloc free read write read write
---------- ----- ----- ----- ----- ----- -----
rpool 72.4G 1.74T 28 21 1.91M 727K

That tells me the ZFS pool on my SSD has averaged 727KB a second since the last reboot. Watching zpool iostat 60 for minute-by-minute reports it’s averaging about 500KB a second on both Proxmox hosts I have. That’s about 40GB a day or 16TB a year. That still gives me decades before the device wears out. But it seems pretty wasteful, what’s doing all that writing?

Another tool is iotop or pidstat -d which show per-process IO stats. fatrace is also interesting, it gives you a log of file access.

Guest system write load

A simple explanation for the writes is the VMs or Containers running as guests on Proxmox may be writing to (virtual) disk, doing real work or writing logs. That’s got nothing much to do with Proxmox.

Proxmox has a nice tool for understanding disk I/O in guests; a graph right there in the GUI.

On my BTRFS machine the graph above tells me the Ubuntu VM guest is writing about 200KB/s. Another graph shows only one of the three containers has sustained writes, it says about 15KB/s. FWIW if I stop just the containers the iostat on the hypervisor goes from 500KB/s to 350KB/s, suggesting the three containers are writing 150KB/s between them. If I then also shut down the VM it saves another 300KB/s. The numbers don’t quite add up but I’m willing to believe that most of the disk writes are things the guest systems are doing. The Proxmox host itself is only writing 50–100KB/s, a small enough number I can ignore it.

On the ZFS machine where I measured 500KB/s writes, the VM itself says it was writing about 100KB/s. That still leaves 80% of the write load coming from the Proxmox hypervisor and maybe a mystery. Or maybe not, like I said the numbers don’t always add up.

Write amplification

A systems problem, write amplification is when writing (say) 1GB of application data results in a lot more than 1GB of write operations on the disk. Pathological systems can have 100x write amplification, a real problem. There’s various possible causes for this, I don’t really understand it.

On a simple test using iostat and dd I verified that writing 100MB of data from /dev/urandom in a VM resulted in about 100MB actually being written to the ZFS pool. Careful how you test; if something’s compressing the actual write might be less than the application data.

I think write amplification is a particular concern with ZFS depending on what RAID configuration you choose. Particularly if you run ZFS in a guest on a virtual disk backed by a physical ZFS pool. The VM itself can also be relevant, see zoned-storage for instance in QEMU. One drawback of virtualization is you’re so far removed from the hardware that things can get out of hand quickly.

Proxmox itself

On to the real question, does Proxmox itself write too much to disk? I’ve got a measurement that it’s only 50–100KB/s. Still, why that much? The Internet is full of advice on how to make Proxmox write less; this guide is particularly good.

The suggestion I was hoping would work is stopping services related to clusters if you only have a single node. The usual suggestion is to stop four: pve-ha-crm, pve-ha-lrm, pvesr.timer, and corosync. Of those only the two pve-ha services were even running. Stopping them didn’t really change the write load.

Another suggestion is to install log2ram and use that for /var/log instead of the real disk. Which could be a nice solution but you lose your logs in case of a hard system crash. Along those lines I’ve used tmpfs before for temporary directories. It helps as long as no one is expecting /tmp to be big.

Another recommendation is to change the vm.swappiness property; apparently Proxmox preemptively starts swapping things to disk when RAM is just 60% full. I don’t have any swap configured so that’s not going to change anything. Memory thrashing to swap could very quickly overwhelm an SSD.

File access details on Proxmox

I tried using iotop, pidstat -d, and fatrace to better understand what was going on. iotop is hard to read or possibly useless because ZFS or BTRFS themselves dominate the reports. pidstat -d is similar to iotop but different packaging. fatrace is a neat tool, and new to me. It shows which files are being written over the whole system. Sadly not how much are being written. Also it can’t show writes to a ZFS volume like my VM is stored on, since those aren’t files.

Shutting down all guests I’m left with proxmox itself. I’m still at 50KB/s or so, it’s hard to be sure exactly. fatrace tells me disk writes go to the following places:

  • pmxcfs: /var/lib/pve-cluster/config.db-wal. This is the PVE High Availability stuff I talked about turning off earlier. Even with those two services turned off there’s still some writes there.
  • pvescheduler: /var/lib/pve-manager/pve-replication-state.lck. Something related to a replication feature I’m not using. There are instructions on how to turn this off but they don’t seem to apply to modern versions.
  • pvestatd: /var/log/pve/tasks/.active.lock. Presumably an important part of PVE’s task scheduler.
  • pvestatd: /var/lib/rrdcached/journal/rrd.journal... Guessing this is the database for the nice graphs in the UI.
  • tailscaled: /var/lib/tailscale/tailscaled.log?.txt. Tailscale writes data briefly to its own log before pushing it to journalctl and removing it. This discussion has some notes about moving or disabling it. It seems to be about 30 writes a minute, 100 bytes at a time.

So that’s that. Most of my writes are coming from guests. Proxmox could be a little more efficienct, so could tailscaled, but what it’s doing now is not awful. And the amount of writes isn’t significant enough to worry about my disk lifespan.

QEMU virtual disks: clearing unused blocks

How do I get Proxmox VM backups to back up actual data and not disk blocks that were written once but no longer used?

Update: the answer for me was to enable the “Discard” option in the hardware options for the VM disk. That’s documented here in the Proxmox manual and for some unknown reason the default is off. After enabling this, trim in the guest OS propagates up to the storage; running fstrim -va in the guest resulted in the ZFS volume in the hypervisor dropping from 167G used to 64G used. This works with VirtIO block devices although next time I set up a VM I’ll still prefer using VirtIO SCSI. (On the other machine which I created with a Clonezilla clone it dropped from 69G to 24G. I wonder if Clonezilla cloned all the blocks even when they weren’t being used.)

Update 2: I also had to add the discard option in fstab for my ext4 filesystem. It’s not the default. I think it may be the default for btrfs and other file systems, not positive.

I ran into a funny problem today. The Proxmox backups of my main Linux VM were taking a tidy 56GB, about as much data (compressed) as there actually is on the 2TB virtual disk. Then I accidentally created a 100GB file (all of Wikipedia in ZIM format). I removed it, df shows its gone. But now a VM backup is taking 156GB. Presumably it’s backing up all the unreferenced blocks that were deleted but still have data on them. I suspect the QEMU clones I started with weren’t copying unused blocks.

You can see how much space ZFS has reserved for a virtual disk like this

root@sfpve:/home/nelson# zfs get used rpool/data/vm-100-disk-1
NAME PROPERTY VALUE SOURCE
rpool/data/vm-100-disk-1 used 167G -

I want that 167GB to be more like 67GB.

I tried using trimfs in the VM guest but it didn’t do much. It’s not clear the trim command ever makes it to the hypervisor host OS. Anyway, fwiw: /: 35 GiB (37617963008 bytes) trimmed. Right after a reboot I ran it again and got /: 139.2 GiB (149456355328 bytes) trimmed, but the second time it was back to 35 GiB. I have no idea what any of this means.

The Proxmox docs have details on how to make trim work in VMs get through to the host OS. They require the virtual disc be of type virtio-scsi and unfortunately I created the VM with a virtio-block. Apparently the SCSI storage type is the more modern and capable one. Also note this wiki page is 4 years old and I can’t quite tell if it’s really relevant now.

virt-sparsify is a QEMU tool for removing unused blocks from an unmounted virtual disk image, see here for more details. This looks perfect for what I need. But it’s not installed by default and installing it includes bringing in all of X11 in Debian, so I’m reticent. Also it requires operating on a file and Proxmox stores VM disks in block storage as a ZFS volume.

That same old Proxmox wiki page also has another solution; just use qemu-img convert to copy the virtual disk and you’re done. The qemu tools seem to be filesystem aware and smart about avoiding unreferenced blocks, I suspect I benefitted from that when I first created the VM disk by cloning my physical disk. But again this requires operating on files and Proxmox has them the disk image as a volume.

This discussion has some notes on using qm disk instead of qemu-img to operate on disk images; it’s able to work with volumes as well as files and presumably is just calling qemu-img to do the real work. I think it’d be as simple as using import to create a new disk that’s a clone of the existing one.

My fear with any of these methods is that they might change the block IDs or device names on my Linux guest and then it won’t boot. Updating /etc/fstab is easy enough but updating Grub is harder. (See my notes here, section “Fix the block IDs”).

The current state is not awful; backups are taking 3x as long and 3x the space as they should, but they all still work. But the problem will only keep getting worse. I think I’ll let it go for now but if I come back to this, ideas to try:

  • Switch to virtio-scsi for the VM and enable the trim command. See if that fixes it.
  • Make a qm disk import clone of the VM disk image and see if the new one is smaller. I can test that entirely with zfs get.
  • Clone the VM disk image to a file and use qemu-img or virt-sparsify to fix it.

Proxmox and data management

Still loving Proxmox but I’ve run into one product limitation: it doesn’t really have a good way of sharing filesystems across guest operating systems. If you want a disk managed by Proxmox to be available in a VM, or to share files between VMs, you pretty m uch have to use a network filesystem like NFS or CIFS (Samba). And Proxmox doesn’t run those itself servers. It seems like a gap in the product.

Proxmox has a fantastic system for managing storage for itself. You have your choice of filesystems but it really wants you to use ZFS. And it uses ZFS great. You can hand Proxmox a bunch of disks and it’ll set up ZFS, create ZFS datasets for container filesystems and volumes for VM disks, etc. It’s very nice.

But if you want to make, say, your home directory as a filesystem and share it to several VMs you’re on your own. There’s a bunch of ways to do this. What I’m doing now is I just make it a normal filesystem (or ZFS dataset) in Proxmox. Then I export them with an NFS server on the Proxmox hypervisor server and NFS mount the filesystem in VM guests. With all the overhead and (virtual) network awfulness NFS implies. Container guests have it easier than VMs, they can access the filesystem more or less directly with a bind mount.

The bummer here is I have to install and manage the NFS server manually on Proxmox. It’s easy enough to set up an NFS server as a Debian package but now I’m outside the Proxmox product, it has zero support for it. Same goes if I chose to use Samba for CIFS instead. For that matter Proxmox GUI doesn’t know about bindmounts for containers either although it’s easy enough from the Proxmox CLI, they even document it.

There’s fancier possible setups. One interesting possibility is to install TrueNAS in a guest VM in Proxmox. And use that as the NFS server with its management GUI. But then how does TrueNAS access the disks? The simple way would be to make a big virtual disk for the TrueNAS VM (backed by ZFS on the Proxmox hypervisor) and use it. But.. yuck! You lose most of the advantage of TrueNAS managing physical disks. The other choice would be to not use the physical disks at all in Proxmox and just pass the hardware through to the VM and let TrueNAS manage them. I may yet end up setting that up.

Another option coming is virtiofs. That’s a way for a hypervisor to share filesystems to a VM without a network filesystem. I think it’s pretty fully baked in Linux now but not quite ready in Proxmox.

A third option fully supported by Proxmox is Ceph, a distributed storage system. I haven’t looked at it, Ceph seems far too big and complicated for my needs.

The NFS server on the Proxmox hypervisor is working OK with me. Mostly I hate how abstracted it becomes, how far removed a disk write on a Linux VM is from what the actual hardware is doing. Performance went to shit yesterday on my system when I moved a 100GB file from a virtual disk in a VM via NFS to a physical disk. The VM’s IO response went to multi-second latency. Load average on the proxmox server went to 9 as a bunch of nfsds sat there hanging in device wait. To be fair, the disk copy happened at max speed so it did complete reasonably but it sure reminded me of the cost of all these abstractions and virtualization.

Post-virtualization thoughts

Phew, my physical to virtual server migration using Proxmox mostly worked. I’ve now moved my main life server, the one I’ve been maintaining or evolving over 25+ years, for the first time into a VM. And it mostly works! Some collected thoughts after the fact.

Checkpoints and backups at the VM level are nice. Really looking forward to that.

This plan of virtualizing a server by first making one giant VM is nice. I can now hive off services to run in specific containers or VMs at my leisure.

Jeff N talked me into trying ZFS on the Proxmox host and so far I’m glad for it. ZFS seems complicated to me but Proxmox is clearly built to take advantage of it. Checkpoints already work better than on BTRFS.

I’m still working out where stuff should live and how it should be shared once I start containerizing services. The obvious thing is to put the primary home for everything in a ZFS pool maintained by the Proxmox server itself (just with ZFS, no Ceph.) My home directory, my Music library, my Video library, a place for backups. Share to containers via bindmounts. Sharing to VMs is harder. I think NFS is the best solution for now until virtiofs in Proxmox is a bit more finished.

Yes, I said NFS. Ugh. I’ve got it working with an NFS server on the Proxmox host itself and the VM mounting it. Setting up automount gave me bad flashbacks to the 1990s, although of course systemd has its own way of doing things. But NFS implies a lot of overhead. Also the confusion of user ID mappings. I’ve never really administered NFSv4 which has some nice things but I may gouge my eyeballs out of I have to set up Kerberos. OTOH I’m really not comfortable letting anything on my LAN mount stuff with root privileges. A work in progress.

Syncthing is working OK in the VM right now. Syncthing is peer to peer but I think of it as hub-and-spoke, with this server being the hub. I think I want to hive that Syncthing hub off to its own container. I see myself possibly also setting up a separate Syncthing instance in some containers or VMs but that sure seems dumb. More work in progress.

Syncthing + NFS is scary. The risk is that NFS is unreliable, so the directory for a synced folder might disappear. And in a bad case Syncthing might interpret that as a command “Delete all the files” and propagate that to all the clients. This really happens in practice and is very bad. They have a sentinel file to protect against this, the .stfolder. I still can’t help but think that syncthing is best run on a local filesystem and not a networked one.

I’ve got Plex running in a VM. Right now it doesn’t have access to the Intel GPU, so it can’t do hardware acceleration of transcoding with Quicksync. There’s ways to make that work but I think I should prioritize moving Plex first into a container, the tteck scripts work with hardware transcoding.

Backups are a big question mark. I’ve generally used rsnapshot but that requires root access to work well, since it’s setting file ownership. And root access to NFS is a no. I’m thinking of switching to Restic for backups instead. How this will work depends a bit on my “who should own what files” question.

I also want to make VM and container backups in Proxmox itself, separate from my personal data. And I’d like to back up the Proxmox server configuration itself; it’s crazy there’s no tool for that.

I need to rethink using RAM for tmpfs in the VM. Also using a swapfile. It’s all working but I bet it’s not optimal.