Map lto-drive into container

I want to build up a bareos backup container. The basis on which the host runs is Proxmox 4.4.

Attached to this host is a LTO6-drive which can be accessed e.g. with tar.

Now I want to use this LTO-drive with bareos in the container.

Therefore I listed the devices which I wnat to map into the container:

root@vhost:/etc/pve/lxc# ll /dev/*st0
crw-rw---- 1 root tape 9, 128 Jun  7 18:24 /dev/nst0
crw-rw---- 1 root tape 9,   0 Jun  7 18:24 /dev/st0

root@vhost:/etc/pve/lxc# lsscsi
[6:0:0:0]    tape    IBM      ULT3580-TD6      D8E4  /dev/st0

Without doing anything the drive is visble in the container:

root@bareos:~# lsscsi
[6:0:0:0]    tape    IBM      ULT3580-TD6      D8E4  -

As accepted there is no device mapped.

I tried several parameters in the conf of the container:

##Tape einbinden Start
#lxc.aa_profile = lxc-container-default-with-mounting
lxc.aa_profile = unconfined
lxc.cgroup.devices.allow = c 9:* rwm
#lxc.mount.entry: /dev/nst0 /nst0 none bind 0 0
#mp0: /dev/ultrium,mp=nst0
##Tape einbinden Ende

I also tried

mknod -m 666 /dev/st0 c 9 0
mknod -m 666 /dev/nst0 c 9 128

but nothing changed.

Google also couldn’t help. I only found configurations to map a partition to the container.

I think (hope) I am on a good way, but I get stuck.

The cgroup entry + mknod should be the right answer to this. I’m assuming you confirmed that you do get matching device nodes after that?

I don’t know exactly how lsscsi resolves the /dev path from the /sys entry but my guess is that it’s that code which doesn’t find the right path in the container rather than there being an actual issue with your /dev/st0 and /dev/nst0 devices.

What happens if you actually run software that directly interacts with those devices?

Amazingly now it works!

I played with the parameters and this is the solution:

lxc.aa_profile: unconfined
lxc.cgroup.devices.allow: c 9:* rwm

After that I created the nodes with

mknod -m 660 /dev/st0 c 9 0
mknod -m 660 /dev/nst0 c 9 128
chgrp tape /dev/*st0

I could use both devices to backup some data.

It was the same I did before…

Strange things happened… :wink: