Post

Make TrueNAS ignore /dev/sde on a Terramaster F4-425 Plus

A user on Reddit made me aware of the fact that while running TrueNAS on a Terramaster F4-F425 Plus like I do (possibly also on other models), the file /var/log/netdata/error.log is full of rapidly produced (and continuously producing) messages like this:

1
2
3
4
5
6
7
8
9
PermissionError: [Errno 13] Permission denied: '/dev/sde'
Unexpected error reading partitions for device: '/dev/sde'
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/middlewared/utils/disks_/disk_class.py", line 397, in partitions
    return read_gpt(dev_fd or self.devpath, self.lbs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/middlewared/utils/disks_/disk_io.py", line 86, in read_gpt
    dev_fd = os.open(devobj, os.O_RDONLY)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The device /dev/sde corresponds to the internal USB stick inside the TerraMaster that holds the TOS operating system, assuming you have a four-bay device and all bays are occupied. For a two-bay device, it might be /dev/sdc, etc. When running TrueNAS, as I do, from an NVMe drive or another USB stick, this internal USB device remains visible to the operating system unless special measures are taken.

Note that the above does not apply if you either removed the internal USB stick or if you overwrote it with TrueNAS.

While this behavior did not cause trouble for me, I wanted to stop it and I went looking for a solution. Sparing you the details, the answer lies in telling the USB subsystem to hide that device.

To do this, first open up the shell in TrueNAS. Then confirm where your device is located on the USB bus by issuing this command:

1
lsusb -t

For me, that produced:

1
2
3
4
5
6
7
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 10000M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 10000M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/12p, 480M
    |__ Port 2: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 480M
    |__ Port 4: Dev 3, If 0, Class=Hub, Driver=hub/5p, 480M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 20000M/x2
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/1p, 480M

The line of interest is the one saying Class=Mass Storage. In this case, the device is identified as bus 3, port 2, also known as 3-2. Going forward in this post, we will use 3-2; if your device is on a different bus or port, substitute the corresponding “id” for 3-2.

With this information in hand, you can test hiding the device immediately by issuing these commands:

1
2
echo 0 | sudo tee /sys/bus/usb/devices/3-2/authorized
ls /dev/sde

The ls command should give you output like this:

1
ls: cannot access '/dev/sde': No such file or directory

Now that we see this works, Netdata might still be a little confused because we “removed” the device mid-flight. To solve that problem and have it run after every reboot, we need to install a post-init script to execute the command.

In the UI, go to System > Advanced Settings and locate the Init/Shutdown Scripts section, which has an Add button on the top-right. Click it. You’ll get a warning that you are about to do something that could be dangerous. You’ll need to close it. Fill out the form presented like this:

  • Description: Remove /dev/sde
  • Type: command
  • Command: echo 0 > /sys/bus/usb/devices/3-2/authorized
  • When: Post init
  • Enabled: checked
  • Timeout: 10 and save.

Next, use the button in the top-right corner of the UI to Restart the system. Once the system has restarted, the device should no longer be visible (confirm with an ls command if you like), and Netdata should be much quieter.

This post is licensed under CC BY 4.0 by the author.