How to compile and install Openmediavault(OMV)

Openmediavault, known as OMV, could be the best choice among different open-source NAS solutions. Based on the great flexibility of Debian, together with its low consumption, OMV can work well on different hardware environments. Even my obsolete Intel Celeron D can still run well.

Even though OMV is easy to use, it lacks documents, as the development team are all recommending to use their ready-to-use images, which is not so friendly with senior users. What’s more, guides to compile from scratch is just an empty paper, and you must guess what to do by yourself!

After falling into plenty of traps, I won’t allow such an empty paper to hurt any beginners! So here comes my guide.

Preparations

  • System: Debian 10 Buster, basic edition without any desktop environments
  • Architecture: OMV’s official-recommended ‘AMD64, ARM, ARM64, and i386
    • Develop team doesn’t release i386 ISO images. But we can still install it on Debian x86 machines.
  • Free disk space: At least 2GB (because of a large amount of dependencies)
  • Memory: At least 512MB. I recommend you to use more than 1GB of memory.

Inform:

  • For easier usage, all those commands above will be run under user root.

    • If you run Debian locally: use either sudo -i or sudo su to switch to root.
    • If you login with SSH, you can directly login with user root.
  • You can fetch a Debian base image form HUST’s mirror, my university: http://mirrors.hust.edu.cn/debian-cd/current/

The Essence of OMV

OMV itself, is a large web server application based on Nginx, PHP, Python and more, which is similar to The Baota Platform. No binary and source code is included in OMV. Instead, every available code is written in interpreting language PHP, and this makes OMV born with cross-platform. On theory, once target architecture supports Debian, Dpkg, and OMV’s dependencies, you can run OMV on any possible architectures.

OMV is based on Debian. When you successfully compile OMV, you will get a cross-platform, noarch Deb package. The compilation won’t invoke compilers to generate dedicated binary files. So you can install OMV on every Debian instance.

Note: Debian-family systems using Dpkg can install, on theory. For example, Ubuntu. But it’s untested.

Clone Source Code

Download

OMV team deploys their code on GitHub. We clone it into directory omv.

1
2
3
4
# Install Git and Pip
apt install git python3-pip
# Clone source code, and put it under directory omv
git clone https://github.com/openmediavault/openmediavault.git omv

Enter source directory

OMV’s core source code is under subdirectory deb:

1
cd omv/deb

Compilation

The compilation of OMV is a land of traps. It lacks documents. And the more terrible trap is that OMV’s Makefiled doesn’t follow common routines. Once you don’t read carefully, you won’t be able to find out the real build target. Thanksfully, you can easily build it.

Install build tools

1
make install

Start compilation

1
make binary

After compilation, it will generate several Deb packages under omv/dev, just like:

1
2
3
4
5
6
7
8
9
10
11
12
13
$ ls *.deb
openmediavault-clamav_5.0-1_all.deb
openmediavault-diskstats_5.0-1_all.deb
openmediavault-forkeddaapd_5.0-1_all.deb
openmediavault-keyring_1.0_all.deb
openmediavault-ldap_4.0.6-1_all.deb
openmediavault-lvm2_5.0.1-1_all.deb
openmediavault-nut_5.0-1_all.deb
openmediavault-shairport_5.0-1_all.deb
openmediavault-snmp_5.0-1_all.deb
openmediavault-tftp_5.0-1_all.deb
openmediavault-usbbackup_5.0.1-1_all.deb
openmediavault_5.0.11_all.deb

Trap: About the default build target

OMV’s default build target, aka. run make without arguments, is NOT compiling Deb packages. Instead, it just simply cleans subdirectories! Be careful, ‘cause I don’t wanna Tukkomi any more ε=(´ο`*)))…

Install OMV

Add OMV official repository

Few dependencies of OMV is not available in Debian’s official repository. So OMV repository is required.

Firstly, append this code to the end of /etc/apt/sources.list:

1
2
# Openmediavault official repository
deb http://packages.openmediavault.org/public usul main

Secondly, install OMV repo keyring:

1
2
3
4
5
6
7
# Install this revision compiled by ourselves:
cd omv/deb
dpkg -i openmediavault-keyring_1.0_all.deb

# And of course, you can install it online:
wget http://packages.openmediavault.org/public/pool/main/o/openmediavault-keyring/openmediavault-keyring_1.0_all.deb
dpkg -i openmediavault-keyring_1.0_all.deb

Then, update repositories:

1
apt update

Install basic dependencies

1
2
3
4
5
# Packages provided by Debian 10
apt install php-fpm php-json php-cgi php-cli php-mbstring ethtool python3-dialog acl xfsprogs jfsutils ntfs-3g sdparm postfix bsd-mailx cpufrequtils smartmontools uuid nfs-kernel-server proftpd-basic sshpass samba samba-common-bin rsync avahi-daemon libnss-mdns beep php-bcmath gdisk rrdtool collectd anacron cron-apt quota php-xml quotatool lvm2 watchdog libjson-perl liblocale-po-perl proftpd-mod-vroot libjavascript-minifier-xs-perl xmlstarlet socat rrdcached nginx wpasupplicant btrfs-progs samba-vfs-modules python3-pyudev python3-natsort jq chrony python3-netifaces python3-lxml salt-minion php-yaml python-click python3-click

# Packages not provided by Debian 10. They are provided by OMV
apt install monit php-pam libjs-extjs6 wsdd

Here will be depedency errors. Continue with:

1
apt --fix-broken install

Then rerun the apt install commands above so that it can continue properly.

Install OMV main package

To install OMV with convenience, OMV developers bundled every installtion process into a meta-package, so that you won’t need to install plenty of packages.

You can install either the official edition or our compiled version.

Install the official edition

You can directly install OMV via official repo:

1
apt install postfix openmediavault

Your screen will be filled with logs. Just wait in patience until it succeeds. Bear in mind that once an error occurs, you won’t be able to use OMV!

Install our own version

1
2
3
4
5
# Re-enter the source directory
cd omv/deb
# Then, start installing
dpkg -i openmediavault-keyring_1.0_all.deb # Keyring
dpkg -i openmediavault_5.0.11_all.deb # Meta-package

Fill the trap: Solve Unit file is masked

On some machines like VPS, you may encounter the error Unit file is masked when installing OMV manually. It’s critical, often interrupts installtion.

1
2
3
4
5
6
7
Failed to preset unit: Unit file /etc/systemd/system/openmediavault-cleanup-php.service is masked.
/usr/bin/deb-systemd-helper: error: systemctl preset failed on openmediavault-cleanup-php.service: No such file or directory
dpkg: error processing package openmediavault (--configure):
installed openmediavault package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
openmediavault
E: Sub-process /usr/bin/dpkg returned an error code (1)

Actually, once you know how systemd manages services, you will know that the so-called mask is a state, means that a service is getting “blocked”. So solution could be extremely easy: once you find a service masked, simply run the following commands to unmask, then reinstall until it can continue properly:

1
2
# systemctl unmask <SERVICE NAME REPORTED MASKED>, for instance:
systemctl unmask openmediavault-cleanup-php.service

Launch OMV

Run the following command to launch OMV. Actually, newer versions of OMV had been configured into auto-start system services.

1
omv-run

Type host’s IP address to open OMV’s login page. Default admin account is:

Field Value
Default username admin
Default password openmediavault

Add OMVExtras Plugin Repository

OMVExtras is a plugin repository provided by OMV official. I recommend you to add it so that you can make use of more powerful plugins.

The developer has a one-key installtion method:

1
wget -O - http://omv-extras.org/install | bash

Once you cannot fetch the script, save the following shell code as install.sh, chmod 755, and run:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash

declare -i version

url="https://github.com/OpenMediaVault-Plugin-Developers/packages/raw/master/"

version=$(dpkg -l openmediavault | awk '$2 == "openmediavault" { print substr($3,1,1) }')

echo ${version}

if [ ${version} -eq 5 ]; then
echo "Downloading omv-extras.org plugin for openmediavault 5.x ..."
file="openmediavault-omvextrasorg_latest_all5.deb"
elif [ ${version} -eq 4 ]; then
echo "Downloading omv-extras.org plugin for openmediavault 4.x ..."
file="openmediavault-omvextrasorg_latest_all4.deb"
elif [ ${version} -eq 3 ]; then
echo "Downloading omv-extras.org plugin for openmediavault 3.x ..."
file="openmediavault-omvextrasorg_latest_all3.deb"
elif [ ${version} -eq 2 ]; then
echo "Downloading omv-extras.org plugin for openmediavault 2.x ..."
file="openmediavault-omvextrasorg_latest_all.deb"
else
echo "Unsupported version of openmediavault"
exit 0
fi

if [ -f "${file}" ]; then
rm ${file}
fi
wget --no-check-certificate ${url}/${file}
if [ -f "${file}" ]; then
dpkg -i ${file}

if [ $? -gt 0 ]; then
echo "Installing other dependencies ..."
apt-get -f install
fi

echo "Updating repos ..."
apt-get update
else
echo "There was a problem downloading the package."
fi

exit 0

After installtion, refresh your browser, then you’ll see a new OMV-Extras entry on the side panel.

References