Target.
1. Install OpenMediaVault NAS into Debian 8 LXC container on ProxmoxVE server with hardware RAID controller card.
2. Provide to OpenMediaVault in LXC container as a storage LSI MegaRAID RAID1 - /dev/sda1.
3. Also continue to use /dev/sda1 as a backup storage for many backup scripts (mysqldump for example) from ProxmoxVE itself.
Definitions.
ProxmoxVE — latest official 4.3 release from http://www.proxmox.com/en/downloads with testing updates;
OpenMediaVault — latest 3.beta (3.0.47) from http://www.openmediavault.org with codename Erasmus;
OpenMediaVault plugins — plugins for Erasmus from http://omv-extras.org/joomla/;
Debian 8 (codename Jessie) LXC template — obtained from ProxmoxVE built-in LXC templates repository - debian-8.0-standard_8.4-1_amd64.tar.gz
*** Daily LXC Template Images from https://jenkins.linuxcontainers.org/view/LXC/view/LXC Templates/ for Debian will be also suitable, but up to 2016.10.21 it has a poor status.
LXC container config — file, located in /etc/pve/lxc/XXX.conf where XXX is a container number from ProxmoxVE.
LXC container hook script — bash shell script, located in /var/lib/lxc/XXX/<script-name>.sh where XXX is a container number from ProxmoxVE.
Decision.
Step 1 — installation of OpenMediaVault
1. update available containers list in ProxmoxVE shell: pveam update
2. download latest available Debian 8 template into container templates storage (via web-gui or from shell). I found debian-8.0-standard_8.4-1_amd64.tar.gz.
3. create Debian 8 LXC container with at least 1Gb RAM (2Gb as RAM will be much comfortable. But if You are planning to use ZFS — You need much more RAM and should consult with ZFS system requirements) and 2Gb RootFS. Also required at least one network device with Internet connection.
*** Notes for point 3:
You should add a few lines into LXC container config before it first start:
lxc.aa_profile: unconfined
lxc.mount.auto: cgroup:rw
lxc.mount.auto: proc:rw
lxc.mount.auto: sys:rw
In a few words — this lines required to start a Debian network scripts (eth0 netcard was not start until I’ve added unconfined profile, proc and sys mount for container), cgroup and unconfined profile required for OpenMediaVault services, such as nfs for example.
4. login into this container and update system:
apt-get update && apt-get dist-upgrade
5. add OpenMediaVault repository and start it installation
echo «deb http://packages.openmediavault.org/public erasmus main» > /etc/apt/sources.list.d/openmediavault.list
apt-get update
apt-get install openmediavault-keyring
* Don’t forget to answer «Y», and only after it push «ENTER»
apt-get update
apt-get install openmediavault
but our installation stopped with an error:
… Socket error – Connection refused
Cannot connect to the monit daemon. Did you start it with http support?
Failed to get D-Bus connection: Unknown error -1
dpkg: error processing package openmediavault (–configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
openmediavault
E: Sub-process /usr/bin/dpkg returned an error code (1)
5.1 Stop this container
5.2 We shoult mount LXC container virtual hard drive for example into /mnt directory in ProxmoxVE
mount /dev/mapper/pve-vm–102–disk–1 /mnt/
5.3 We should chroot into mounted LXC container virtual hard drive:
mount -t proc none /mnt/proc/
mount - - rbind /dev/ /mnt/dev/
mount - - rbind /sys/ /mnt/sys/
chroot /mnt/ /bin/bash
* This is a «true Gentoo way» ;-)
5.4 continue installation of OpenMediaVault in chroot
apt-get install openmediavault
5.5 start post-installation command
omv-initsystem
but our installation stopped with a first error:
run-parts: /usr/share/openmediavault/initsystem/20hostname exited with return code 1
Our container does not have it’s own hostmane, and in chroot we have hypervisor’s hostname …
You can simply change hostmane from OpenMediaVault Web Management interface, so simply move this file:
mv /usr/share/openmediavault/initsystem/20hostname /root/
continue firs time system initialization
omv-initsystem
but our installation stopped with a second error:
run-parts: /usr/share/openmediavault/initsystem/60rootfs exited with return code 2
LXC container has no fstab mounted rootfs. This is only a rootfs check in OpenMediaVault. In this case we can also simply drop this steb by mooving this file:
mv /usr/share/openmediavault/initsystem/60rootfs /root/
continue firs time system initialization
omv-initsystem
And after a few perl warnings about locales - finish successfully installation procedure.
5.6 exit from container by «ctrl+D»
5.7 start this container from ProxmoxVE
5.8 login into web-gui of OpenMediaVault
It seems to be all ok. But there is an error with applying changes — Avahi-daemon error …
After a few time googling I have found a solution for Avahi in https://loune.net/2011/02/avahi-setrlimit-nproc-and-lxc/.
We should patch the file - /usr/share/openmediavault/mkconf/avahi-daemon in container.
Go back to ProxmoxVE shell and edit file in pre-mounted rootfs:
nano /mnt/usr/share/openmediavault/mkconf/avahi-daemon
At the end of it we should to remove the last line:
rlimit-nproc=3
by
#rlimit-nproc=3
Our installation of OpenMediaVault is finished successfully.
Step 2 — installation of OpenMediaVault plugins
1. Go back to web-gui of OpenMediaVault
2. Download via your browser plugins from omv-extras.org:
http://omv-extras.org/debian/pool/m...org/openmediavault-omvextrasorg_3.3.3_all.deb
and install it via web-gui of OpenMediaVault.
This all for the installation.
We need to reboot the whole ProxmoxVE (to unmount /mnt/proc, /mnt/dev/ and /mnt/sys/)
Step 3 — provide block device (hard disk) from ProxmoxVE to OpenMediaVault in LXC container to operate it as a storage device.
I’m trying to attach /dev/sda1
This is my LSI MegaRAID mirrored volume.
I obtain a cooking receipt from here:
https://forum.proxmox.com/threads/lxc-cannot-assign-a-block-device-to-container.23256/#post-118361
1. in ProxmoxVE shell type this commands:
1.1 ls -la /dev/sda*
brw-rw—- 1 root disk 8, 0 Oct 20 20:12 /dev/sda
brw-rw—- 1 root disk 8, 1 Oct 20 20:12 /dev/sda1
1.2 edit LXC container config (with number XXX) to add a few new lines:
nano etc/pve/lxc/XXX.conf
lxc.cgroup.devices.allow: b 8:0 rwm
lxc.cgroup.devices.allow: b 8:1 rwm
lxc.autodev: 1
***
This lines allow to use /dev/sda, /dev/sda1 (with read-write-mount) inside container itself.
But our LXC container has none block devices in /dev
There is one way is to create device via mknod. But after container reboot we’ll loose those devices. We should create a hook.
1.3 In ProxmoxVE shell create this file:
nano /var/lib/lxc/XXX/mount-hook.sh
and add the following lines into it:
#!/bin/sh
mknod -m 777 ${LXC_ROOTFS_MOUNT}/dev/sda b 8 0
mknod -m 777 ${LXC_ROOTFS_MOUNT}/dev/sda1 b 8 1
Don’t forget to make this file executable (chmod +x)
1.4. The last thing is to do — to add a lxc.mount line in container config.
To my own purposes, I mounted /dev/sda1 via fstab into /raid folder in ProxmoxVE. My own backup scripts operates in /raid/backup folder. OpenMediaVault automatically mounts devices into /media folder with device UUID folder.
In ProxmoxVE shell type:
ls -la /dev/disk/by-uuid | grep sda1
lrwxrwxrwx 1 root root 10 Oct 20 20:12 7078dfe1-70c5-46eb-97ec-cca6d2fcff37 → ../../sda1
As for me, I added this line to my LXC container config:
lxc.mount.entry: /raid media/7078dfe1-70c5-46eb-97ec-cca6d2fcff37 none bind,create=dir,optional 0 0
1.5. Stop and start LXC container to apply changes.
After that you can simply mount /dev/sda1 from OpenMediaVault web-gui and start normal operation of any services of OpenMediaVault codename Erasmus in LXC container as a NAS.
Voi la !!!
I tested successfully this services from OpenMediaVault in LXC container:
- nfs
- samba
- ftp
- ssh
Don’t forget to set correct user and group permissions in it ;-) This is the only one way for errors in OpenMediaVault as for me.
My own complete config file (/etc/pve/lxc/100.conf) is:
arch: amd64
cpulimit: 1
cpuunits: 1024
hostname: omv
memory: 2048
nameserver: 192.168.80.1
net0: name=eth0,bridge=vmbr80,hwaddr=82:EA:BA:52:09:CD,ip=dhcp,type=veth
ostype: debian
rootfs: local-lvm:vm-100-disk-1,size=2G
searchdomain: omv
swap: 1024
lxc.aa_profile: unconfined
lxc.mount.auto: cgroup:rw
lxc.mount.auto: proc:rw
lxc.mount.auto: sys:rw
lxc.cgroup.devices.allow: b 8:0 rwm
lxc.cgroup.devices.allow: b 8:1 rwm
lxc.autodev: 1
lxc.hook.autodev: /var/lib/lxc/100/mount-hook.sh
My own complete hook file (/var/lib/lxc/100/mount-hook.sh) is:
#!/bin/sh
mknod -m 777 ${LXC_ROOTFS_MOUNT}/dev/sda b 8 0
mknod -m 777 ${LXC_ROOTFS_MOUNT}/dev/sda1 b 8 1
My ProxmoxVE is:
pve-manager/4.3-6/460dfe4c (running kernel: 4.4.21-1-pve)
Hope that this short man will help a few people to save cost and start their own-made SOHO NAS, based on truly free software. This man is not suitable for production and/or commercial use as a NAS Solution.
P.S.
Take my pardon for my English.
1. Install OpenMediaVault NAS into Debian 8 LXC container on ProxmoxVE server with hardware RAID controller card.
2. Provide to OpenMediaVault in LXC container as a storage LSI MegaRAID RAID1 - /dev/sda1.
3. Also continue to use /dev/sda1 as a backup storage for many backup scripts (mysqldump for example) from ProxmoxVE itself.
Definitions.
ProxmoxVE — latest official 4.3 release from http://www.proxmox.com/en/downloads with testing updates;
OpenMediaVault — latest 3.beta (3.0.47) from http://www.openmediavault.org with codename Erasmus;
OpenMediaVault plugins — plugins for Erasmus from http://omv-extras.org/joomla/;
Debian 8 (codename Jessie) LXC template — obtained from ProxmoxVE built-in LXC templates repository - debian-8.0-standard_8.4-1_amd64.tar.gz
*** Daily LXC Template Images from https://jenkins.linuxcontainers.org/view/LXC/view/LXC Templates/ for Debian will be also suitable, but up to 2016.10.21 it has a poor status.
LXC container config — file, located in /etc/pve/lxc/XXX.conf where XXX is a container number from ProxmoxVE.
LXC container hook script — bash shell script, located in /var/lib/lxc/XXX/<script-name>.sh where XXX is a container number from ProxmoxVE.
Decision.
Step 1 — installation of OpenMediaVault
1. update available containers list in ProxmoxVE shell: pveam update
2. download latest available Debian 8 template into container templates storage (via web-gui or from shell). I found debian-8.0-standard_8.4-1_amd64.tar.gz.
3. create Debian 8 LXC container with at least 1Gb RAM (2Gb as RAM will be much comfortable. But if You are planning to use ZFS — You need much more RAM and should consult with ZFS system requirements) and 2Gb RootFS. Also required at least one network device with Internet connection.
*** Notes for point 3:
You should add a few lines into LXC container config before it first start:
lxc.aa_profile: unconfined
lxc.mount.auto: cgroup:rw
lxc.mount.auto: proc:rw
lxc.mount.auto: sys:rw
In a few words — this lines required to start a Debian network scripts (eth0 netcard was not start until I’ve added unconfined profile, proc and sys mount for container), cgroup and unconfined profile required for OpenMediaVault services, such as nfs for example.
4. login into this container and update system:
apt-get update && apt-get dist-upgrade
5. add OpenMediaVault repository and start it installation
echo «deb http://packages.openmediavault.org/public erasmus main» > /etc/apt/sources.list.d/openmediavault.list
apt-get update
apt-get install openmediavault-keyring
* Don’t forget to answer «Y», and only after it push «ENTER»
apt-get update
apt-get install openmediavault
but our installation stopped with an error:
… Socket error – Connection refused
Cannot connect to the monit daemon. Did you start it with http support?
Failed to get D-Bus connection: Unknown error -1
dpkg: error processing package openmediavault (–configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
openmediavault
E: Sub-process /usr/bin/dpkg returned an error code (1)
5.1 Stop this container
5.2 We shoult mount LXC container virtual hard drive for example into /mnt directory in ProxmoxVE
mount /dev/mapper/pve-vm–102–disk–1 /mnt/
5.3 We should chroot into mounted LXC container virtual hard drive:
mount -t proc none /mnt/proc/
mount - - rbind /dev/ /mnt/dev/
mount - - rbind /sys/ /mnt/sys/
chroot /mnt/ /bin/bash
* This is a «true Gentoo way» ;-)
5.4 continue installation of OpenMediaVault in chroot
apt-get install openmediavault
5.5 start post-installation command
omv-initsystem
but our installation stopped with a first error:
run-parts: /usr/share/openmediavault/initsystem/20hostname exited with return code 1
Our container does not have it’s own hostmane, and in chroot we have hypervisor’s hostname …
You can simply change hostmane from OpenMediaVault Web Management interface, so simply move this file:
mv /usr/share/openmediavault/initsystem/20hostname /root/
continue firs time system initialization
omv-initsystem
but our installation stopped with a second error:
run-parts: /usr/share/openmediavault/initsystem/60rootfs exited with return code 2
LXC container has no fstab mounted rootfs. This is only a rootfs check in OpenMediaVault. In this case we can also simply drop this steb by mooving this file:
mv /usr/share/openmediavault/initsystem/60rootfs /root/
continue firs time system initialization
omv-initsystem
And after a few perl warnings about locales - finish successfully installation procedure.
5.6 exit from container by «ctrl+D»
5.7 start this container from ProxmoxVE
5.8 login into web-gui of OpenMediaVault
It seems to be all ok. But there is an error with applying changes — Avahi-daemon error …
After a few time googling I have found a solution for Avahi in https://loune.net/2011/02/avahi-setrlimit-nproc-and-lxc/.
We should patch the file - /usr/share/openmediavault/mkconf/avahi-daemon in container.
Go back to ProxmoxVE shell and edit file in pre-mounted rootfs:
nano /mnt/usr/share/openmediavault/mkconf/avahi-daemon
At the end of it we should to remove the last line:
rlimit-nproc=3
by
#rlimit-nproc=3
Our installation of OpenMediaVault is finished successfully.
Step 2 — installation of OpenMediaVault plugins
1. Go back to web-gui of OpenMediaVault
2. Download via your browser plugins from omv-extras.org:
http://omv-extras.org/debian/pool/m...org/openmediavault-omvextrasorg_3.3.3_all.deb
and install it via web-gui of OpenMediaVault.
This all for the installation.
We need to reboot the whole ProxmoxVE (to unmount /mnt/proc, /mnt/dev/ and /mnt/sys/)
Step 3 — provide block device (hard disk) from ProxmoxVE to OpenMediaVault in LXC container to operate it as a storage device.
I’m trying to attach /dev/sda1
This is my LSI MegaRAID mirrored volume.
I obtain a cooking receipt from here:
https://forum.proxmox.com/threads/lxc-cannot-assign-a-block-device-to-container.23256/#post-118361
1. in ProxmoxVE shell type this commands:
1.1 ls -la /dev/sda*
brw-rw—- 1 root disk 8, 0 Oct 20 20:12 /dev/sda
brw-rw—- 1 root disk 8, 1 Oct 20 20:12 /dev/sda1
1.2 edit LXC container config (with number XXX) to add a few new lines:
nano etc/pve/lxc/XXX.conf
lxc.cgroup.devices.allow: b 8:0 rwm
lxc.cgroup.devices.allow: b 8:1 rwm
lxc.autodev: 1
***
This lines allow to use /dev/sda, /dev/sda1 (with read-write-mount) inside container itself.
But our LXC container has none block devices in /dev
There is one way is to create device via mknod. But after container reboot we’ll loose those devices. We should create a hook.
1.3 In ProxmoxVE shell create this file:
nano /var/lib/lxc/XXX/mount-hook.sh
and add the following lines into it:
#!/bin/sh
mknod -m 777 ${LXC_ROOTFS_MOUNT}/dev/sda b 8 0
mknod -m 777 ${LXC_ROOTFS_MOUNT}/dev/sda1 b 8 1
Don’t forget to make this file executable (chmod +x)
1.4. The last thing is to do — to add a lxc.mount line in container config.
To my own purposes, I mounted /dev/sda1 via fstab into /raid folder in ProxmoxVE. My own backup scripts operates in /raid/backup folder. OpenMediaVault automatically mounts devices into /media folder with device UUID folder.
In ProxmoxVE shell type:
ls -la /dev/disk/by-uuid | grep sda1
lrwxrwxrwx 1 root root 10 Oct 20 20:12 7078dfe1-70c5-46eb-97ec-cca6d2fcff37 → ../../sda1
As for me, I added this line to my LXC container config:
lxc.mount.entry: /raid media/7078dfe1-70c5-46eb-97ec-cca6d2fcff37 none bind,create=dir,optional 0 0
1.5. Stop and start LXC container to apply changes.
After that you can simply mount /dev/sda1 from OpenMediaVault web-gui and start normal operation of any services of OpenMediaVault codename Erasmus in LXC container as a NAS.
Voi la !!!
I tested successfully this services from OpenMediaVault in LXC container:
- nfs
- samba
- ftp
- ssh
Don’t forget to set correct user and group permissions in it ;-) This is the only one way for errors in OpenMediaVault as for me.
My own complete config file (/etc/pve/lxc/100.conf) is:
arch: amd64
cpulimit: 1
cpuunits: 1024
hostname: omv
memory: 2048
nameserver: 192.168.80.1
net0: name=eth0,bridge=vmbr80,hwaddr=82:EA:BA:52:09:CD,ip=dhcp,type=veth
ostype: debian
rootfs: local-lvm:vm-100-disk-1,size=2G
searchdomain: omv
swap: 1024
lxc.aa_profile: unconfined
lxc.mount.auto: cgroup:rw
lxc.mount.auto: proc:rw
lxc.mount.auto: sys:rw
lxc.cgroup.devices.allow: b 8:0 rwm
lxc.cgroup.devices.allow: b 8:1 rwm
lxc.autodev: 1
lxc.hook.autodev: /var/lib/lxc/100/mount-hook.sh
My own complete hook file (/var/lib/lxc/100/mount-hook.sh) is:
#!/bin/sh
mknod -m 777 ${LXC_ROOTFS_MOUNT}/dev/sda b 8 0
mknod -m 777 ${LXC_ROOTFS_MOUNT}/dev/sda1 b 8 1
My ProxmoxVE is:
pve-manager/4.3-6/460dfe4c (running kernel: 4.4.21-1-pve)
Hope that this short man will help a few people to save cost and start their own-made SOHO NAS, based on truly free software. This man is not suitable for production and/or commercial use as a NAS Solution.
P.S.
Take my pardon for my English.
Last edited: