[HOW-TO] Install OMV on a mirrored pair of disks (RAID 1)

  • Hi all,

    Similar installation instructions can be found in vl1969 's post : [HOW-TO] Convert OMV install to system RAID-1 install

    But since it's old, I decided to write a new one here, for anyone to read and suggest changes.


    First of all I should explain the main purpose of this try. It is to have an OMV installation with :

    - using the hole space of the installation media for storage

    - have system redundancy


    ***

    Sure there is a more sophisticated system backup method documented in this forum, via the OMV Backup plugin e.g.

    But since in my work place there is a "difficulty" in buying stuff like usb flash drives ( :( ) and on the other hand there are plenty of unused 160GB hard drives, I chose to give it a try with RAID.

    ***


    ** The installation process I followed was based in a post by Josip Lazić, found here : Installing OpenMediaVault on RAID-1 array



    1. OMV installation

    At first I installed the latest OMV on a 160GB hard disk, following the official OMV documentation.

    This disk is going to act like the installation prototype (lets say so !! ).

    Shutdown the machine and connect two other 160GB hard disk drives. These are going to be the installation media of my new system.

    The following procedure can be applied via ssh connection.


    2. Listing the connected disks

    Listing `openmediavault` connected disks we see:

    Code
    root@omv:~# lsblk
    NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
    sda      8:0    0 149.1G  0 disk
    ├─sda1   8:1    0 148.1G  0 part /
    ├─sda2   8:2    0     1K  0 part
    └─sda5   8:5    0   976M  0 part [SWAP]
    sdb      8:16   0 149.1G  0 disk
    sdc      8:32   0 149.1G  0 disk

    where `sda` is the initial disk ("prototype") and `sdb` and `sdc` are the disks going to form the RAID array.


    ** I intent to create 4 partitions in both two OMV system disks, `sdb` and `sdc`:

    - 1st: grub / 12MB ??

    - 2nd: swap / 32GB

    - 3rd: system / 28GB

    - 4th: data / 100GB (the rest of the disk)


    3. Create partitions on the first drive `/dev/sdb`


    4. Clone partition table to the second drive `/dev/sdc`

    To replicate partition table to `/dev/sdc` I run:

    Code
    root@omv:~# sgdisk -R=/dev/sdc /dev/sdb
    Warning: The kernel is still using the old partition table.
    The new table will be used at the next reboot or after you
    run partprobe(8) or kpartx(8)
    The operation has completed successfully.


    5. Randomize the GUID on the disk `/dev/sdc` and all it's partitions (because the above "cloning" command clones GUID's also!)

    Code
    root@omv:~# sgdisk -G /dev/sdc
    Warning: The kernel is still using the old partition table.
    The new table will be used at the next reboot or after you
    run partprobe(8) or kpartx(8)
    The operation has completed successfully.


    ** checking the partitions, now both `sdb` and `sdc` seems like :


    6. Create mdadm RAID array for swap partitions

    Code
    root@omv:~# mdadm --create /dev/md0 --level=1 --raid-devices=2 --metadata=0.90 /dev/sdb2 /dev/sdc2
    mdadm: array /dev/md0 started.


    7. Create mdadm RAID array for root partitions

    Code
    root@omv:~# mdadm --create /dev/md1 --level=1 --raid-devices=2 --metadata=0.90 /dev/sdb3 /dev/sdc3
    mdadm: array /dev/md1 started.


    8. Create mdadm RAID array for data partitions

    Code
    root@omv:~# mdadm --create /dev/md2 --level=1 --raid-devices=2 --metadata=0.90 /dev/sdb4 /dev/sdc4
    mdadm: array /dev/md2 started.


    9. Create swap filesystem on `/dev/md0`

    Code
    root@omv:~# mkswap /dev/md0
    Setting up swapspace version 1, size = 29.8 GiB (31988838400 bytes)
    no label, UUID=d2691e45-c941-4c2a-b0fe-c5de59128ed6


    .... to be continued

  • 10. Create root filesystem on `/dev/md1`



    11. Create filesystem on `/dev/md2` (data partition)


    ** check the new partitions for `sdb` and `sdc` again :

    also


    12. Mount root filesystem (`/dev/md1`) on `/mnt/root` and sync OMV to it

    Code
    mkdir /mnt/root
    mount /dev/md1 /mnt/root/
    rsync -avx / /mnt/root


    13. Add new arrays to the `/mnt/root/etc/mdadm/mdadm.conf`

    Code
    mdadm --detail --scan >> /mnt/root/etc/mdadm/mdadm.conf

    so it will be:

    Code
    root@omv:~# cat /etc/mdadm/mdadm.conf
    ARRAY /dev/md0 metadata=0.90 UUID=d535f129:b1cb7949:3da012a4:b1a46ad8
    ARRAY /dev/md1 metadata=0.90 UUID=1f6178a1:153dba8d:3da012a4:b1a46ad8
    ARRAY /dev/md2 metadata=0.90 UUID=f8f938b3:bf39a006:3da012a4:b1a46ad8


    14. MUST change UUID of / mountpoint in chrooted OMV instalation

    * find UUID of `/dev/md1` with `blkid` command and change UUID for `/` mount point in `/mnt/root/etc/fstab`

    * find UUID of `/dev/md0` with `blkid` command and change UUID for `swap` mount point in `/mnt/root/etc/fstab`

    Code
    root@omv:~# blkid | grep md1
    /dev/md1: UUID="dc51ecf5-9a91-476c-8202-7b322e115a4a" BLOCK_SIZE="4096" TYPE="ext4"
    root@omv:~# blkid | grep md0
    /dev/md0: UUID="d2691e45-c941-4c2a-b0fe-c5de59128ed6" TYPE="swap"
    root@omv:~# nano /mnt/root/etc/fstab


    15. Bind mount `/dev`, `/sys` and `/proc` to our new root drive (`/mnt/root/`) and chroot there

    Code
    mount --bind /dev /mnt/root/dev
    mount --bind /sys /mnt/root/sys
    mount --bind /proc /mnt/root/proc
    chroot /mnt/root/


    .... to be continued

  • 16. Install GRUB on both new drives, update grub configuration and update initramfs


    17. Exit `chroot` and shutdown the system. Remove the original disk and boot on new OMV on RAID !!


    18. Create filesystem on `/dev/md2` (data)


    ** At the end of this installation and setup procedure it should be like this :


    And finally the system is ready !

  • votdev

    Approved the thread.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!