I created a lxc container with sudo lxc-create -n ubuntu-trusty-amd64 -t ubuntu -- --arch amd64 --release trusty
on Ubuntu 14.04 with lxc 1.0.5-0ubuntu0.1 and realized that there're no device files in /dev/
for my HDDs. How can I make them available (via device file or a similar workaround) in the lxc so that I can mount the device?
I figured (with muru's link in comments) that adding
lxc.hook.autodev = /path/to/script
to a config file (which BTW?) is necessary and script
contains a mknod
statement, but I don't understand the usage of mknod
.
ls -a /dev/
in the lxc gives
. dsp1 loop3 midi03 port ram15 rmidi0 stderr tty7
.. dsp2 loop4 midi1 ptmx ram16 rmidi1 stdin tty8
agpgart dsp3 loop5 midi2 pts ram2 rmidi2 stdout tty9
audio fd loop6 midi3 ram ram3 rmidi3 tty urandom
audio1 full loop7 mixer ram0 ram4 sequencer tty0 zero
audio2 kmem lxc mixer1 ram1 ram5 shm tty1
audio3 kmsg mem mixer2 ram10 ram6 smpte0 tty2
audioctl log midi0 mixer3 ram11 ram7 smpte1 tty3
console loop0 midi00 mpu401data ram12 ram8 smpte2 tty4
core loop1 midi01 mpu401stat ram13 ram9 smpte3 tty5
dsp loop2 midi02 null ram14 random sndstat tty6
I tried to mount the device file (although it seems strange). Therefore the mountpoint under /var/lib/lxc/<name>/rootfs/dev/
has to be created. Creating a file with touch
doesn't work because the host can't mount a device file under a file. Creating a directory with mkdir
on the host works, but doesn't allow to mount it in the lxc because it's recognized as directory.
It should be possible to create a dd
image of the device using the device file inside the lxc, for example.
lxc.cgroup.devices.allow = b 8:* rwm
in the LXC configuration? – muru Sep 25 '14 at 02:07/var/lib/lxc/<name>/config
and started the lxc, but no HDD device files in/dev/
. – Kalle Richter Sep 25 '14 at 02:15