msgbartop
MAC OS X, Linux, Windows and other IT Tips and Tricks
msgbarbottom

08 Apr 19 Creating new Software RAID Disks

Assumptions:

Lets say you rented a server in Hetzner and it offers the wappy 4 x 10TB disks. You want the following disks configuration:

Disks: 1 and 2 (in RAID 1) total 10TB in Mirrored RAID 1 mode
Disks: 3 and 4 (In RAID 1) total 10TB in Mirrored RAID 1 mode

HOWTO:
1 – During the configuration of the Hetzner Linux Image you disable(comment out ‘#’) the disk3 and disk 4 from the configuration and set the RAIDLEVEL to 1. You can also decide what kind of partitions the first RAID disks will be setup here (in the section which starts with ‘PART’ lines)but this HOWTO doesn’t cover that.

2 – Save and let the system be built.

3 – After reboot run the following command:
lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT

Example Output:

<PRE>NAME SIZE FSTYPE TYPE MOUNTPOINT
sda 9.1T disk
|-sda1 8G linux_raid_member part
| -md0 8G swap raid1 [SWAP] |-sda2 512M linux_raid_member part |-md1 511.4M ext3 raid1 /boot
|-sda3 9.1T linux_raid_member part
| -md2 9.1T ext4 raid1 / -sda4 1M part
sdb 9.1T disk
|-sdb1 8G linux_raid_member part
| -md0 8G swap raid1 [SWAP] |-sdb2 512M linux_raid_member part |-md1 511.4M ext3 raid1 /boot
|-sdb3 9.1T linux_raid_member part
| -md2 9.1T ext4 raid1 / -sdb4 1M part
sdc 9.1T disk
sdd 9.1T disk
</PRE>

You can see that the first partitions have been set under md0, md1 and md2 disks partitions BUT the drives sdc and sdd are not assigned to any RAID group. We will assign them to md3 with the command:

mdadm --create --verbose /dev/md3 --level=1 --raid-devices=2 /dev/sdc /dev/sdd

Result:

mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store '/boot' on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=0.90
mdadm: size set to 9766305792K
mdadm: automatically enabling write-intent bitmap on large array
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md3 started.

To verify we run the command:

lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT

Output:

<PRE>NAME SIZE FSTYPE TYPE MOUNTPOINT
sda 9.1T disk
|-sda1 8G linux_raid_member part
| -md0 8G swap raid1 [SWAP] |-sda2 512M linux_raid_member part |-md1 511.4M ext3 raid1 /boot
|-sda3 9.1T linux_raid_member part
| -md2 9.1T ext4 raid1 / -sda4 1M part
sdb 9.1T disk
|-sdb1 8G linux_raid_member part
| -md0 8G swap raid1 [SWAP] |-sdb2 512M linux_raid_member part |-md1 511.4M ext3 raid1 /boot
|-sdb3 9.1T linux_raid_member part
| -md2 9.1T ext4 raid1 / -sdb4 1M part
sdc 9.1T linux_raid_member disk
-md3 9.1T raid1 sdd 9.1T linux_raid_member disk -md3 9.1T raid1</PRE>
Now we can start formatting the md3 disk array to ext4 format:
mkfs.ext4 /dev/md3

Create a mountpoint in the filesystem:
mkdir /DATA

Configure the /etc/fstab for mounting it at boot time:

mcedit /etc/fstab

Content:

proc /proc proc defaults 0 0
/dev/md/0 none swap sw 0 0
/dev/md/1 /boot ext3 defaults 0 0
/dev/md/2 / ext4 defaults 0 0
/dev/md3 /DATA ext4 defaults 0 0

Mount all existing drives set in /etc/fstab

mount -a

Verify the space in system:
df -h

Result:

Filesystem Size Used Avail Use% Mounted on
udev 16G 0 16G 0% /dev
tmpfs 3.2G 588K 3.2G 1% /run
/dev/md2 9.1T 1.1G 8.6T 1% /
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/md1 488M 40M 423M 9% /boot
tmpfs 3.2G 0 3.2G 0% /run/user/0
/dev/md3 9.1T 80M 8.6T 1% /DATA

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: