{"id":513,"date":"2015-11-08T22:21:17","date_gmt":"2015-11-08T21:21:17","guid":{"rendered":"http:\/\/lazic.info\/josip\/?p=513"},"modified":"2016-05-03T15:47:33","modified_gmt":"2016-05-03T14:47:33","slug":"installing-openmediavault-on-raid-device","status":"publish","type":"post","link":"https:\/\/lazic.info\/josip\/post\/installing-openmediavault-on-raid-device\/","title":{"rendered":"Installing OpenMediaVault on RAID-1 array"},"content":{"rendered":"<p>OpenMediaVault is great NAS OS and I prefer it over FreeNAS or other BSD based NAS solutions. I guess that OMV being based on Debian is a major plus with me. But, there is a nasty side of OMV &#8211; they do not support using OS drive for data storage (as noted in <a href=\"http:\/\/wiki.openmediavault.org\/index.php?title=Installation\" title=\"undefined\" target=\"\">OMV installation guide<\/a>) and if you install OMV on a 1TB drive you can say goodbye to the nice 950GB of free space on that device. Recommended solution for this is installing OMV on smaller drive or on USB device. I had no luck using USB devices, every device would die after few weeks or months, and using seperate smaller SATA drive is also a nogo because I have no extra\/free SATA ports in my NAS.<\/p>\n<p>Wouldn&#8217;t it be nice if we could use 2 drives in RAID1 and install OMV on one partition and use rest of the free space for data? We can make this happen with a little magic. Let&#8217;s begin.<\/p>\n<p>I will be using Virtualbox for this, but same principles apply on hardware machines.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lazic.info\/josip\/wp-content\/uploads\/2015\/11\/omv-install-1.png\" alt=\"VirtualBox OMV drives\" width=\"650\" height=\"407\" class=\"aligncenter size-full wp-image-515\" srcset=\"https:\/\/lazic.info\/josip\/wp-content\/uploads\/2015\/11\/omv-install-1.png 650w, https:\/\/lazic.info\/josip\/wp-content\/uploads\/2015\/11\/omv-install-1-300x188.png 300w, https:\/\/lazic.info\/josip\/wp-content\/uploads\/2015\/11\/omv-install-1-479x300.png 479w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/p>\n<p>First install OMV on a USB drive, and boot for the first time. Shut down OMV and insert two drives you actually intend on using, and boot OMV from USB device. Once OMV is up and running, login as root and start SSH service with following command:<\/p>\n<p><code>service ssh start<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lazic.info\/josip\/wp-content\/uploads\/2015\/11\/omv-install-2.png\" alt=\"omv-install-2\" width=\"720\" height=\"401\" class=\"aligncenter size-full wp-image-522\" srcset=\"https:\/\/lazic.info\/josip\/wp-content\/uploads\/2015\/11\/omv-install-2.png 720w, https:\/\/lazic.info\/josip\/wp-content\/uploads\/2015\/11\/omv-install-2-300x167.png 300w, https:\/\/lazic.info\/josip\/wp-content\/uploads\/2015\/11\/omv-install-2-539x300.png 539w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/p>\n<p>this way you can connect to OMV remotely via SSH, it&#8217;s easier to work that way. Now that you are logged in via SSH you need to determine your drives, I use <strong>lsscsi<\/strong> for that, but you can use whatever you want. In my demonstration I have OMV installed on <strong>\/dev\/sda<\/strong>, while <strong>\/dev\/sdb<\/strong> and <strong>\/dev\/sdc<\/strong> are SATA drives.<\/p>\n<p>First we need to create partitions on SATA drives, I will use parted for creating 3 partitions, first for GRUB, second for OMV root, and third for data. <\/p>\n<p><code>parted -a optimal \/dev\/sdb mklabel gpt<br \/>\nparted -a optimal \/dev\/sdb mkpart grub ext2 2048s 12M<br \/>\nparted -a optimal \/dev\/sdb mkpart root ext4 12M 4096M<br \/>\nparted -a optimal \/dev\/sdb mkpart data ext4 4096M 100%<br \/>\nparted -a optimal \/dev\/sdb set 1 bios_grub on<br \/>\nparted -a optimal \/dev\/sdb set 2 boot on<br \/>\n<\/code><\/p>\n<p>You can change sizes of partitions, I&#8217;m using 4G for OMV root partition, in my case that is enough you can change it to better suit your needs. You should end up with something like this:<\/p>\n<p><code>root@openmediavault:~# parted \/dev\/sdb u s p<br \/>\nModel: ATA VBOX HARDDISK (scsi)<br \/>\nDisk \/dev\/sdb: 83886080s<br \/>\nSector size (logical\/physical): 512B\/512B<br \/>\nPartition Table: gpt<\/p>\n<p>Number  Start     End        Size       File system  Name  Flags<br \/>\n 1      2048s     22527s     20480s                  grub  bios_grub<br \/>\n 2      22528s    7999487s   7976960s   ext4         root  boot<br \/>\n 3      7999488s  83884031s  75884544s  ext4         data<br \/>\n<\/code><\/p>\n<p>Now we clone this partition table to second drive <strong>\/dev\/sdc<\/strong> with sgdisk:<\/p>\n<p><code>sgdisk -R=\/dev\/sdc \/dev\/sdb<br \/>\nsgdisk -G \/dev\/sdc<br \/>\n<\/code><\/p>\n<p>Now that we have two drives with identical partition setup we can create mdadm RAID arrays on those partitions. First array will be for OMV root drive on \/dev\/sd(b|c)2 partitions and other array on \/dev\/sd(b|c)3 partitions.<\/p>\n<p><code>mdadm --create \/dev\/md0 --level=1 --raid-devices=2 --metadata=0.90 \/dev\/sdb2 \/dev\/sdc2<br \/>\nmdadm --create \/dev\/md1 --level=1 --raid-devices=2 --metadata=0.90 \/dev\/sdb3 \/dev\/sdc3<\/code><\/p>\n<p>Create ext4 filesystem on \/dev\/md0:<\/p>\n<p><code>mkfs.ext4 \/dev\/md0<\/code><\/p>\n<p>With filesystem on \/dev\/md0 we can mount it on \/mnt\/root and sync OMV to \/dev\/md0.<\/p>\n<p><code>mkdir \/mnt\/root<br \/>\nmount \/dev\/md0 \/mnt\/root\/<br \/>\nrsync -avx \/ \/mnt\/root<br \/>\n<\/code><\/p>\n<p>One more thing, we must add new arrays to the \/mnt\/root\/etc\/mdadm\/mdadm.conf, and change UUID of <strong>\/<\/strong> mountpoint in chrooted OMV instalation. You can add new arrays to mdadm.conf with following command:<\/p>\n<p><code>mdadm --detail --scan >> \/mnt\/root\/etc\/mdadm\/mdadm.conf<\/code><\/p>\n<p>Find UUID of \/dev\/md0 with <strong>blkid<\/strong> command and change UUID for <strong>\/<\/strong> mount point in \/mnt\/root\/etc\/fstab.<\/p>\n<p>Now you are ready to bind mount \/dev \/sys and \/proc to our new root drive and chroot there:<\/p>\n<p><code>mount --bind \/dev \/mnt\/root\/dev<br \/>\nmount --bind \/sys \/mnt\/root\/sys<br \/>\nmount --bind \/proc \/mnt\/root\/proc<br \/>\nchroot \/mnt\/root\/<br \/>\n<\/code><\/p>\n<p>Congrats, you are now in your OMV installation on RAID array, there is only GRUB setup left to do and you are golden. Install GRUB on both new drives, update grub configuration and update initramfs and that is it.<\/p>\n<p><code>grub-install --recheck \/dev\/sdb<br \/>\ngrub-install --recheck \/dev\/sdc<br \/>\ngrub-mkconfig -o \/boot\/grub\/grub.cfg<br \/>\nupdate-initramfs -u<br \/>\n<\/code><\/p>\n<p>Exit chroot with <strong>exit<\/strong> and shutdown OMV. Remove USB device and boot into OMV on RAID1 array, once boot is done login as root via SSH and create filesystem on \/dev\/md1 with<\/p>\n<p><code>mkfs.ext4 -m 1 -L DATA \/dev\/md1<\/code><\/p>\n<p>And this is it, login to web interface, mount \/dev\/md1 and start using OMV installed on RAID1 array.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lazic.info\/josip\/wp-content\/uploads\/2015\/11\/omv-install-3.png\" alt=\"OMV mount points\" width=\"902\" height=\"134\" class=\"aligncenter size-full wp-image-523\" srcset=\"https:\/\/lazic.info\/josip\/wp-content\/uploads\/2015\/11\/omv-install-3.png 902w, https:\/\/lazic.info\/josip\/wp-content\/uploads\/2015\/11\/omv-install-3-300x45.png 300w, https:\/\/lazic.info\/josip\/wp-content\/uploads\/2015\/11\/omv-install-3-800x119.png 800w\" sizes=\"auto, (max-width: 902px) 100vw, 902px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenMediaVault is great NAS OS and I prefer it over FreeNAS or other BSD based NAS solutions. I guess that OMV being based on Debian is a major plus with me. But, there is a nasty side of OMV &#8211; they do not support using OS drive for data storage (as noted in OMV installation [&hellip;]<\/p>\n<div class=\"clearfix text-center more-button\"><a href=\"https:\/\/lazic.info\/josip\/post\/installing-openmediavault-on-raid-device\/\" class=\"btn btn-success\">Continue reading<\/a><\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[16,17],"class_list":["post-513","post","type-post","status-publish","format-standard","hentry","category-linux","tag-nas","tag-openmediavault"],"_links":{"self":[{"href":"https:\/\/lazic.info\/josip\/wp-json\/wp\/v2\/posts\/513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lazic.info\/josip\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lazic.info\/josip\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lazic.info\/josip\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lazic.info\/josip\/wp-json\/wp\/v2\/comments?post=513"}],"version-history":[{"count":0,"href":"https:\/\/lazic.info\/josip\/wp-json\/wp\/v2\/posts\/513\/revisions"}],"wp:attachment":[{"href":"https:\/\/lazic.info\/josip\/wp-json\/wp\/v2\/media?parent=513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lazic.info\/josip\/wp-json\/wp\/v2\/categories?post=513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lazic.info\/josip\/wp-json\/wp\/v2\/tags?post=513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}