Software & AppsOperating SystemLinux

How To Install Ubuntu 20.04 Desktop with RAID 1 and LVM on UEFI BIOS Machines

Ubuntu 3

In this tutorial, we’ll walk you through the process of installing Ubuntu 20.04 Desktop with RAID 1 and LVM on UEFI BIOS Machines. This setup provides a high level of data redundancy and logical volume management for efficient disk space utilization.

Quick Answer

In this tutorial, we provide a step-by-step guide on how to install Ubuntu 20.04 Desktop with RAID 1 and LVM on UEFI BIOS machines. This setup offers data redundancy and efficient disk space utilization.

Prerequisites

Before we begin, ensure that you have the following:

  • Two physical disks of the same size.
  • A bootable Ubuntu 20.04 Desktop installer. You can download this from the official Ubuntu website.
  • Basic knowledge of Linux commands and disk management.

Step 1: Boot into Ubuntu Live Environment

Insert your bootable Ubuntu installer into your machine and boot into the Ubuntu Live environment. Choose the “Try Ubuntu” option to start the live session.

Step 2: Install Necessary Packages

Open a terminal by pressing Ctrl+Alt+T. We’ll need to install the SSH server for remote access during the installation process. Run the following command:

sudo apt install openssh-server

Set a password for the SSH server using:

sudo passwd

Step 3: Partition the Disks

We’ll be using the sgdisk command to create partitions on our physical disks. Adjust the disk names according to your setup. The -Z option clears all partition data, -n creates a new partition, -t sets the partition type, and -c sets the partition name.

sudo sgdisk -Z /dev/sda
sudo sgdisk -Z /dev/sdb
sudo sgdisk -n 1:0:+512M -t 1:ef00 -c 1:"EFI System" /dev/sda
sudo sgdisk -n 2:0:0 -t 2:fd00 -c 2:"Linux RAID" /dev/sda
sudo sgdisk -n 1:0:+512M -t 1:ef00 -c 1:"EFI System" /dev/sdb
sudo sgdisk -n 2:0:0 -t 2:fd00 -c 2:"Linux RAID" /dev/sdb

Next, create a FAT32 system for the EFI partition on the first drive:

sudo mkfs.fat -F 32 /dev/sda1

Step 4: Install mdadm and Create RAID 1

Install the mdadm package for RAID configuration:

sudo apt-get update
sudo apt-get install mdadm

Create the RAID 1 device using the mdadm command. The --create option initiates the creation of a new RAID device, --bitmap=internal enables write-intent bitmap, --level=1 sets RAID level to 1, and --raid-disks=2 specifies the number of active devices in the array.

sudo mdadm --create /dev/md0 --bitmap=internal --level=1 --raid-disks=2 /dev/sda2 /dev/sdb2

Check the status of the RAID device:

cat /proc/mdstat

Step 5: Create LVM Partitions on RAID

We’ll create a partition on the RAID device for LVM:

sudo sgdisk -Z /dev/md0
sudo sgdisk -n 1:0:0 -t 1:E6D6D379-F507-44C2-A23C-238F2A3DF928 -c 1:"Linux LVM" /dev/md0

Next, create a physical volume, volume group, and logical volumes on the new volume group:

sudo pvcreate /dev/md0p1
sudo vgcreate vg0 /dev/md0p1
sudo lvcreate -Z y -L 25GB --name root vg0
sudo lvcreate -Z y -L 10GB --name tmp vg0
sudo lvcreate -Z y -L 5GB --name var vg0
sudo lvcreate -Z y -L 10GB --name varlib vg0
sudo lvcreate -Z y -L 200GB --name home vg0

Step 6: Run the Ubuntu Installer

Double-click on the “Install Ubuntu” icon on the desktop. Choose the language, keyboard layout, and select “Something else” for the installation type.

Double-click on each partition starting with /dev/mapper/vg0- and set the appropriate mount points and file systems. Select the first device /dev/sda for the boot loader installation. Complete the installation process and select “Continue Testing” when finished.

Step 7: Chroot into the Target System

Mount the unmounted partitions and chroot into the target system:

sudo mount /dev/mapper/vg0-home /target/home
sudo mount /dev/mapper/vg0-tmp /target/tmp
sudo mount /dev/mapper/vg0-var /target/var
sudo mount /dev/mapper/vg0-varlib /target/var/lib
sudo mount --bind /dev /target/dev
sudo mount --bind /proc /target/proc
sudo mount --bind /sys /target/sys
sudo chroot /target

Step 8: Install mdadm in the Target System

Install mdadm in the target system:

apt install mdadm

Update the configuration file /etc/mdadm/mdadm.conf and remove the name=... part from the array entry. Update the module list for the kernel to load at boot:

echo raid1 >> /etc/modules
update-initramfs -u

Exit the chroot environment and unmount the partitions:

exit
sudo umount /target/{home,tmp,var,var/lib,dev,proc,sys}

Step 9: Clone the EFI Partition and Update Boot Chain

Clone the EFI partition from one drive to the other:

sudo dd if=/dev/sda1 of=/dev/sdb1 bs=4096

Use efibootmgr to insert the EFI partition of the second disk into the boot chain:

sudo apt install efibootmgr
sudo efibootmgr -c -d /dev/sdb -p 1 -L "ubuntu2" -l '\EFI\ubuntu\shimx64.efi'

Step 10: Reboot and Verify

Reboot the system and check the status of the RAID device:

cat /proc/mdstat

Congratulations! You have successfully installed Ubuntu 20.04 Desktop with RAID 1 and LVM on a UEFI BIOS machine.

Remember, this setup requires careful maintenance. Regularly check the status of your RAID array and replace failed drives as soon as possible to maintain data redundancy.

Conclusion

This tutorial provided a comprehensive guide for installing Ubuntu 20.04 Desktop with RAID 1 and LVM on UEFI BIOS machines. This setup offers a robust solution for data redundancy and efficient disk space utilization. As always, ensure you have a good backup strategy in place to protect your data. Happy computing!

Can I use this tutorial for installing Ubuntu on a non-UEFI BIOS machine?

No, this tutorial is specifically for UEFI BIOS machines. The steps and commands mentioned here may not be applicable for non-UEFI systems.

Can I use different-sized disks for RAID 1?

It is recommended to use disks of the same size for RAID 1. While it is possible to use different-sized disks, the RAID array will only utilize the amount of disk space equal to the size of the smallest disk.

Can I use more than two disks for RAID 1?

Yes, it is possible to use more than two disks for RAID 1. However, this tutorial covers the configuration for a two-disk RAID 1 setup.

Can I modify the sizes of the logical volumes in Step 5?

Yes, you can modify the sizes of the logical volumes according to your requirements. Just make sure to adjust the sizes in the lvcreate commands accordingly.

Do I need to regularly monitor the status of the RAID array?

Yes, it is recommended to regularly check the status of the RAID array using the cat /proc/mdstat command. This will help you identify any issues or failed drives that need attention.

Can I add more logical volumes after the installation?

Yes, you can add more logical volumes after the installation by using the appropriate LVM commands. However, make sure to understand the impact on your existing data and carefully plan the changes before proceeding.

Is it possible to use a different Linux distribution instead of Ubuntu?

Yes, the general steps for setting up RAID 1 and LVM on UEFI BIOS machines are applicable to other Linux distributions as well. However, some specific commands or package names may vary. Make sure to refer to the documentation of your chosen distribution for any differences.

Can I use software RAID instead of mdadm for RAID configuration?

Yes, you can use other software RAID solutions like dmraid instead of mdadm. However, this tutorial specifically covers the usage of mdadm for RAID setup.

Is it possible to configure RAID 1 and LVM during the Ubuntu installation process?

Yes, it is possible to configure RAID 1 and LVM during the Ubuntu installation process. However, this tutorial provides a manual setup process for more control and flexibility.

How can I replace a failed disk in the RAID array?

If a disk in the RAID array fails, you will need to replace it with a new disk of the same size. You can then use the mdadm command to add the new disk to the RAID array and let it rebuild the data. Consult the mdadm documentation or other resources for detailed instructions on replacing failed disks.

Leave a Comment

Your email address will not be published. Required fields are marked *