NCRLinuxU2 Software RAID (UEFI)

The following procedure incorporates software RAID into an NCR supported terminal running NCRLinuxU2 distribution. The software RAID configuration is set to RAID1 mode.

Note

The succeeding screenshots are from a CX8 terminal with two 120GB SATA solid state drives:

  • sda—disk 1
  • sdb—disk 2

The four partitions are as follows:

  • 1—boot/efi
  • 2—boot
  • 3— swap
  • 4—root

The procedure may need to be modified for use in other OS, when using NVMe drives, or using a different terminal. It is also assumed that two drives of the same type are used. At all times, it is assumed that the commands are run as a root user.

  1. Determine the terminal’s current OS partitions. In this case, the current OS is on /dev/sda and its partitions are:
    • /dev/sda1
    • /dev/sda2
    • /dev/sda3
    • /dev/sda4

  2. Create the same partitions for the second disk (/dev/sdb).
    1. Run the following command:
      Copy
      sfdisk -d /dev/sda | sfdisk --force /dev/sdb

    2. Verify the copied partitions for the second disk (/dev/sdb). Run the following command:
      Copy
      fdisk -l
       

  3. Change the partition types on the second disk (/dev/sdb) to Linux RAID.
    1. Run the following commands:
      Copy
      sfdisk --part-type /dev/sdb 3 A19D880F-05FC-4D3B-A006-743F0F84911E
      Copy
      sfdisk --part-type /dev/sdb 4 A19D880F-05FC-4D3B-A006-743F0F84911E
    2. Verify the partitions are now Linux RAID. Run the following command:
      Copy
      fdisk -l

  4. Create the RAID arrays.
    1. Run the following commands:
      Copy
      mdadm --create /dev/md3 --run --level=1 --metadata=1.0 --raid-devices=2 missing /dev/sdb3
      Copy
      mdadm --create /dev/md4 --run --level=1 --metadata=1.0 --raid-devices=2 missing /dev/sdb4
    2. Verify the created RAID arrays. Run the following command:
      Copy
      cat /proc/mdstat

  5. Format the RAID arrays with the same file systems as the current OS partitions. Run the following commands:
    Copy
    mkswap -L "SWAP" /dev/md3
    Copy
    mkfs.ext4 -L "ROOT" /dev/md4
     

  6. Edit the /etc/grub.d/40_custom file and add a RAID boot entry.
    Copy
    menuentry 'RAID - NCRLinuxU2' {
            load_video
            set gfxpayload=keep
            insmod gzio
            insmod part_gpt
            insmod mdraid1x
            insmod ext2
            set root='(hd0,gpt2)'
            echo 'Loading Linux 5.15.0-73-generic raid ...'
            linux /vmlinuz-5.15.0-73-generic root=/dev/md4 noresume splash=silent mitigations=auto quiet
    net.ifnames=0 8250.nr_uarts=2 i915.invert_brightness=-1 tpm_tis.interrupts=0
            echo 'Loading initial ramdisk raid...'
            initrd /initrd.img-5.15.0-73-generic
    }
    Note
    • '(hd0,gpt2)' should be the partition where your /boot is located

    Example

    Before

    After

  7. Create the RAID configuration file. Run the following command:
    Copy
    mdadm --detail --scan >> /etc/mdadm/mdadm.conf
  8. Update boot configurations. Run the following commands:
    Copy
    update-initramfs -u
    Copy
    update-grub
    Copy
    grub-install /dev/sda

  9. Mount the RAID arrays (except the Swap array) to a temporary mount point. In this case, run the following commands:
    Copy
    mkdir /mnt/md4
    Copy
    mount /dev/md4 /mnt/md4

  10. Copy the current EFI and OS partition data to the mounted RAID arrays. In this case, run the following command:
    Copy
    cp -dpRx / /mnt/md4

  11. Edit the /etc/fstab file in the RAID array and replace necessary partitions to its equivalent RAID arrays. At this point, the file is located at /mnt/md4/etc/fstab.

    Example

    Before

    After

  12. Chroot to the mounted RAID array that contains the OS data and update the boot configurations. Run the following commands:
    Copy
    cd /mnt/md4
    Copy
    mount /dev/sda2 boot
    Copy
    mount /dev/sda1 boot/efi
    Copy
    mount --bind /dev dev
    Copy
    mount --bind /sys sys
    Copy
    mount --bind /proc proc
    Copy
    chroot .
    Copy
    update-initramfs -u
    Copy
    update-grub
    Copy
    grub-install --modules=mdraid1x.mod /dev/sda
    Copy
    exit
    Copy
    umount boot/efi boot dev sys proc

  13. Reboot the terminal and choose the RAID - NCRLinuxU2 boot entry.
    Note
    • Remove any bootable usb/flash drive at this point.

    • EFI boot manager will reset the default boot options. Wait for this operation to finish.

    • A start job for dev-md*.device is expected. Wait for this operation to finish.

    At this point, the terminal should be able to boot the RAID configuration. To verify this, run the following command:

    Copy
    df -h

  14. Change the partition types of the current OS that are on /dev/sda to Linux RAID.
    1. Run the following commands:
      Copy
      sfdisk --part-type /dev/sda 3 A19D880F-05FC-4D3B-A006-743F0F84911E
      Copy
      sfdisk --part-type /dev/sda 4 A19D880F-05FC-4D3B-A006-743F0F84911E
    2. Verify that the partitions are now Linux RAID. Run the following command:
      Copy
      fdisk -l

  15. Add the partitions from the preceding step (current OS) to the RAID arrays accordingly. Run the following commands:
    Copy
    mdadm --manage /dev/md3 --add /dev/sda3
    Copy
    mdadm --manage /dev/md4 --add /dev/sda4

  16. Wait for RAID to sync the disks. Run the following commands:
    • To view progress:
      Copy
      watch cat /proc/mdstat
    • To quit watching the progress:
      Copy
      Ctrl+C

  17. Edit the /etc/grub.d/40_custom file and remove the RAID boot entry.
  18. Edit the /etc/default/grub file and do the following:
    1. Replace:
      Copy
      rootp=$(blkid -L ROOT)
    2. In the line GRUB_CMDLINE_LINUX_DEFAULT, remove the string root=LABEL=root.
    3. Replace the string following resume= with /dev/md3.
    Example

    Before

    After

  19. Update the boot configurations of the two disks. In this case, /dev/sda and /dev/sdb. Run the following commands:
    Copy
    update-initramfs -u
    Copy
    update-grub
    Copy
    grub-install --modules=mdraid1x.mod /dev/sda
    Copy
    grub-install --modules=mdraid1x.mod /dev/sdb

  20. Copy the boot and EFI partitions from /dev/sda to /dev/sdb. Run the following commands:
    Copy
    dd if=/dev/sda1 of=/dev/sdb1
    Copy
    dd if=/dev/sda2 of=/dev/sdb2

  21. Reboot the terminal and expect that there is no RAID boot entry. The terminal should now boot on RAID1 configuration.
    Note

    It is possible to test if RAID1 is working by shutting down and removing one of the drives, the system should still boot as normal. When that happens, one of the drives may be disconnected from the RAID1 array. Add the drive back to the array using the following commands:

    Copy
    mdadm /dev/md3 -a /dev/sdb3
    Copy
    mdadm /dev/md4 -a /dev/sdb4