Run SMART disk monitor in LXD

Hi,

I was hoping to spin up a container to run SMART disk monitoring within (via smartmontools).

When I run lsblk, I can see the devices, but I am unable to use them in the smartctl tool.

root@smartmon:~# lsblk 
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0    7:0    0  55.4M  1 loop 
loop1    7:1    0  55.4M  1 loop 
loop2    7:2    0  31.1M  1 loop 
loop3    7:3    0  69.9M  1 loop 
loop4    7:4    0  32.1M  1 loop 
loop5    7:5    0  67.6M  1 loop 
sda      8:0    0 931.5G  0 disk 
├─sda1   8:1    0   512M  0 part 
└─sda2   8:2    0   931G  0 part 
sdb      8:16   0 931.5G  0 disk 
└─sdb1   8:17   0 465.7G  0 part 
sdc      8:32   0 931.5G  0 disk 
├─sdc1   8:33   0 931.5G  0 part 
└─sdc9   8:41   0     8M  0 part 
sdd      8:48   0 931.5G  0 disk 
└─sdd1   8:49   0 372.5G  0 part 
sde      8:64   0 931.5G  0 disk 
└─sde1   8:65   0 931.5G  0 part 
sdf      8:80   0   3.7T  0 disk 
└─sdf1   8:81   0   3.7T  0 part 
sdg      8:96   0   2.7T  0 disk 
├─sdg1   8:97   0     1K  0 part 
├─sdg5   8:101  0     2T  0 part 
└─sdg6   8:102  0    48G  0 part 
sr0     11:0    1  1024M  0 rom  
zd16   230:16   0   9.3G  0 disk 
zd32   230:32   0   9.3G  0 disk 
root@smartmon:~# smartctl -i /dev/sda
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.4.0-73-generic] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org

Smartctl open device: /dev/sda failed: No such device

I assume this is because I am running an un-privileged container.

Is there a good way to enable this, without just running the container in privileged mode?

Cheers,
Whytey

For SMART access I believe you’d need to both add unix-block device entries to your container for every device in /dev/ that you want to access and then possibly still make the container privileged on top of that as SMART likely relies on privileged IOCTLs to do the job.

Overall, if you can instead do this from the host, I think it’d be preferable.

As always, thanks for the reply! :+1: