HowTo build an SHR – Sliced Hybrid Raid
Just in case somebody is interested how to build a Sliced Hybrid Raid. Here is what I did on one of my machines.
What is a Sliced Hybrid Raid (SHR) – and why might you want it ?
A Sliced Hybrid Raid is basically a Raid5 created with disks of different sizes. But instead of using only the size of the smallest disk on all the remaining disks, the advantage of an SHR is, that it uses as much of the available disk space as possible. It does so, by using a combination of partitions, software raid (using mdadm) and logical volumes (using lvm). Fortunately, all those tools are available in OMV, so we can take advantage of it.
Note however, that you still need the largest HDD twice, since you need at least 2 partitions to create a slice. If your largest HDD only exists once, you will “loose” the amount of space, that it is larger than your second largest drive.
Credits
This is not my idea. I’m just documenting, what I did, to create an SHR on my OMV-NAS.
I saw this the first time on my Synology NAS. They even call it “Synology Hybrid Raid”, but it can also be found on several places in the internet, where it is called “Sliced Hybrid Raid”, as I call it here also. I have no idea who came up with this first, but at the end it’s not a new technology, it’s just a (clever?) combination of a few old ones.
Guideline to build an SHR on OMV
Disclaimer
One important warning upfront:
This is no guideline you can just blindly follow. You need and must understand what all those commands do, since you definitely will and must adapt them to your specific environment. So carefully read and understand(!) the whole guideline before following it. If it contains commands, you are not familiar with, go read the man-page or a similar source of information. Only follow this guideline, if you fully understand each and every command. You must be able to detect an error, if you see one – or at least, you need to get suspicious...
The commands used in this guideline can destroy all your data if you do a mistake. Therefor I urgently recommend to have a backup (on a different machine or at least on a disk, that is NOT attached to the machine, where you are going to build the SHR !!) and that you practice those steps in a VM before doing it on your real machine. I shall not be held responsible in case you destroy any of your data using this guideline. You have been warned.
Prerequisites:
Make sure you have installed the OMV Plugins for md and lvm.
In Debian (on the command line) make sure gdisk and lsblk are installed / available. If they aren’t, install using apt-get.
Getting started
In my case I use 6 HDDs; two of size 3 TB, two of size 5 TB and two of size 10 TB. I have deleted all the partitions that were previously on those disks. So, for the start of this guideline, they are empty.
So, this will basically be my setup:
This is what the 6 HDDs look like using lsblk:
root@ts8-nas:~# lsblk -o name,partlabel,parttypename,size /dev/sd[abcdef]
NAME PARTLABEL PARTTYPENAME SIZE
sda 9.1T
sdb 9.1T
sdc 2.7T
sdd 2.7T
sde 4.5T
sdf 4.5T
Hands on – the partitions
I start with the smallest HDD I have. In my case that’s the 3 TB HDD. I create a partition, that fills the whole space of that disk and I create a partition of exactly the same size on all other disks.
root@ts8-nas:~# sgdisk --largest-new=0 /dev/sdc
Creating new GPT entries in memory.
The operation has completed successfully.
Note:
If you don’t get the result “The operation has completed successfully.”, you did something wrong (sgdisk doesn’t show error messages).
The --info command gives me the size in sectors of my newly created partition.
root@ts8-nas:~# sgdisk --info=1 /dev/sdc
Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
Partition unique GUID: C88F36E9-F2EB-4FB6-9F3B-581B96F4E6C5
First sector: 2048 (at 1024.0 KiB)
Last sector: 5860533134 (at 2.7 TiB)
Partition size: 5860531087 sectors (2.7 TiB)
Attribute flags: 0000000000000000
Partition name: ''
I’m using these values in this command sgdisk --new=0:0:+5860531087 /dev/sdx to create a partition of the same size on all other disks:
root@ts8-nas:~# sgdisk --new=0:0:+5860531087 /dev/sdd
Creating new GPT entries in memory.
The operation has completed successfully.
root@ts8-nas:~# sgdisk --new=0:0:+5860531087 /dev/sda
Creating new GPT entries in memory.
The operation has completed successfully.
root@ts8-nas:~# sgdisk --new=0:0:+5860531087 /dev/sdb
Creating new GPT entries in memory.
The operation has completed successfully.
root@ts8-nas:~# sgdisk --new=0:0:+5860531087 /dev/sde
Creating new GPT entries in memory.
The operation has completed successfully.
root@ts8-nas:~# sgdisk --new=0:0:+5860531087 /dev/sdf
Creating new GPT entries in memory.
The operation has completed successfully.
Display More
And that’s the result:
root@ts8-nas:~# lsblk -o name,partlabel,parttypename,size /dev/sd[abcdef]
NAME PARTLABEL PARTTYPENAME SIZE
sda 9.1T
└─sda1 Linux filesystem 2.7T
sdb 9.1T
└─sdb1 Linux filesystem 2.7T
sdc 2.7T
└─sdc1 Linux filesystem 2.7T
sdd 2.7T
└─sdd1 Linux filesystem 2.7T
sde 4.5T
└─sde1 Linux filesystem 2.7T
sdf 4.5T
└─sdf1 Linux filesystem 2.7T
Display More
These are the partitions for the first slice. Now I’m going to create the partitions for the second slice. This works basically similar to the first slice:
root@ts8-nas:~# sgdisk --largest-new=0 /dev/sde
The operation has completed successfully.
root@ts8-nas:~# sgdisk --info=2 /dev/sde
Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
Partition unique GUID: 247F31C5-BE88-4737-92C0-1BA557A8722B
First sector: 5860534272 (at 2.7 TiB)
Last sector: 9767541134 (at 4.5 TiB)
Partition size: 3907006863 sectors (1.8 TiB)
Attribute flags: 0000000000000000
Partition name: ''
root@ts8-nas:~# sgdisk --new=0:0:+3907006863 /dev/sdf
The operation has completed successfully.
root@ts8-nas:~# sgdisk --new=0:0:+3907006863 /dev/sda
The operation has completed successfully.
root@ts8-nas:~# sgdisk --new=0:0:+3907006863 /dev/sdb
The operation has completed successfully.
Display More
And this is the result
root@ts8-nas:~# lsblk -o name,partlabel,parttypename,size /dev/sd[abcdef]
NAME PARTLABEL PARTTYPENAME SIZE
sda 9.1T
├─sda1 Linux filesystem 2.7T
└─sda2 Linux filesystem 1.8T
sdb 9.1T
├─sdb1 Linux filesystem 2.7T
└─sdb2 Linux filesystem 1.8T
sdc 2.7T
└─sdc1 Linux filesystem 2.7T
sdd 2.7T
└─sdd1 Linux filesystem 2.7T
sde 4.5T
├─sde1 Linux filesystem 2.7T
└─sde2 Linux filesystem 1.8T
sdf 4.5T
├─sdf1 Linux filesystem 2.7T
└─sdf2 Linux filesystem 1.8T
Display More
These are the partitions for the second slice. Now I’m going to create the partitions for the third slice:
root@ts8-nas:~# sgdisk --largest-new=0 /dev/sda
The operation has completed successfully.
root@ts8-nas:~# sgdisk --info=3 /dev/sda
Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
Partition unique GUID: 8294920C-5953-4892-B5BE-868CE6E21AE1
First sector: 9767542784 (at 4.5 TiB)
Last sector: 19532873694 (at 9.1 TiB)
Partition size: 9765330911 sectors (4.5 TiB)
Attribute flags: 0000000000000000
Partition name: ''
root@ts8-nas:~# sgdisk --new=0:0:+9765330911 /dev/sdb
The operation has completed successfully.
Display More
And this is the result
root@ts8-nas:~# lsblk -o name,partlabel,parttypename,size /dev/sd[abcdef]
NAME PARTLABEL PARTTYPENAME SIZE
sda 9.1T
├─sda1 Linux filesystem 2.7T
├─sda2 Linux filesystem 1.8T
└─sda3 Linux filesystem 4.5T
sdb 9.1T
├─sdb1 Linux filesystem 2.7T
├─sdb2 Linux filesystem 1.8T
└─sdb3 Linux filesystem 4.5T
sdc 2.7T
└─sdc1 Linux filesystem 2.7T
sdd 2.7T
└─sdd1 Linux filesystem 2.7T
sde 4.5T
├─sde1 Linux filesystem 2.7T
└─sde2 Linux filesystem 1.8T
sdf 4.5T
├─sdf1 Linux filesystem 2.7T
└─sdf2 Linux filesystem 1.8T
Display More
Ok, the first part is now finished. All the needed partitions are created. Now I’m going to create the slices.