Manage the filesystem

It is a good idea to have redundancy for important data and fast access for scratch work. Software RAID is an idea solution. On Ubuntu, my preference is to use mdadm.

I had to set up an old computer with 5 potentially failing hard drives with various sizes. (0.5,1.0,1.5, 2.0,2.0 TB) This example should be basic enough to follow with minimum linux knowledge and flexible enough to extend.

My strategy is as follows:

  1. install Ubuntu on the smallest drive 500 GB
  2. make fresh partition tables on the rest of the drives for RAID
  3. RAID0 the smaller drives for scratch space
  4. RAID1 the larger drives for archive
  5. Edit fstab to mount partitions at boot time

Step 1: Install (just install Ubuntu, please)

Step 2: Make fresh partition tables

For context, the drives look like
ls /dev | grep sd
sda
sdb
sdc
sdd
sde

sudo gdisk /dev/sda then p will show the partition table for the disk, which includes the size of the disk. For me the sizes for sda-e are 1.0,0.5,2.0,1.5,2.0 TB, respectively.

To make a fresh partition for disk a, for example:
sudo gdisk /dev/sda then d until all existing partitions are gone, then n to create new partition, finally w to save changes. Use defaults for everything as we will use the entire disk for RAID. Repeat for disks c,d,e.

Step 3: Create stripping RAID0

sudo mdadm --create --verbose /dev/md0 --level=0 --raid-devices=2 /dev/sda1 /dev/sdd1

wait until RAID array finishes assembling (cat /proc/mdstat)

check if successful sudo mdadm --detail /dev/md0

make file system sudo mkfs.ext4 /dev/md0

Step 4: Create mirroring RAID1

sudo mdadm --create --verbose /dev/md1 --level=1 --raid-devices=2 /dev/sdc1 /dev/sde1

wait until RAID array finishes assembling (cat /proc/mdstat)

check if successful sudo mdadm --detail /dev/md1

make file system sudo mkfs.ext4 /dev/md1

Step 5: Edit fstab

Use sudo blkid | grep md to see UUID of RAID arrays. Add them as extra disks to fstab
tail -n 4 /etc/fstab
# 2 * 2TB in RAID1 configuration for storage
UUID=072d5c92-9f98-4262-abe2-ec93709060df /archive ext4 defaults 0 2
# 1.0 + 1.5 TB in RAID0 configuration for scratch work
UUID=696126eb-50f4-4ec3-8ae1-22d4b8794a76 /home ext4 defaults 0 2

Notice I wanted my home folder to be the scratch folder, so I actually had to move all the current content of my home folder somewhere else first, mount disk, and then move them back.