1

I have installed raid 5 on my Ubuntu server (software controller). I've used a 250G and two 1TB disks for it (I know it's quite a waste of memory). Can I replace the 250 G hard disk with a 1TB hard disk in the future so that I have more memory in the RAID system?

1 Answers1

3

You need to first determine the drive that you're going to remove. First, run a scan to see what the md raids are:

sudo mdadm -D --scan

Should return something like:

~$ sudo mdadm -D --scan
ARRAY /dev/md/swap metadata=1.2 name=Intrepid:swap UUID=2cdfcb03:e5e0c30f:d68d4e20:37b50e41
ARRAY /dev/md0 metadata=1.2 name=Intrepid:root UUID=f9b257fc:d64f97c7:95581e88:004e3a4b
ARRAY /dev/md1 metadata=1.2 name=Intrepid:1 UUID=3bb988cb:d5270497:36e75f46:67a9bc65

I know that mine is /dev/md1 so that is what we are going to use here.

If you don't have it installed, install the smartmontools:

sudo apt install smartmontools

Next, copy and paste the following line to get all the drive model numbers. You should see your 250GB drive as a different model:

sudo mdadm -D /dev/md1 | grep "/dev/sd" | awk '{print $NF}'| sed 's/1$//' | while read drive; do echo "$drive"; sudo smartctl -a $drive | grep -E "Device Model|Serial Number"; done

You should see something similar to the following:

~$ sudo mdadm -D /dev/md1 | grep "/dev/sd" | awk '{print $NF}'| sed 's/1$//' | while read drive; do echo "$drive"; sudo smartctl -a $drive | grep -E "Device Model|Serial Number"; done
/dev/sdf
Device Model:     WDC WD40EFRX-68WT0N0
Serial Number:    WD-WCC4EJPD3EXP
/dev/sdg
Device Model:     WDC WD40EFRX-68WT0N0
Serial Number:    WD-WCC4E5UZUKPY
/dev/sdh
Device Model:     WDC WD40EFRX-68WT0N0
Serial Number:    WD-WCC4E3XCP660
/dev/sdi
Device Model:     WDC WD40EFRX-68WT0N0
Serial Number:    WD-WCC4E7ZRRN8U
/dev/sdj
Device Model:     WDC WD40EFRX-68WT0N0
Serial Number:    WD-WCC4EJXKY26C

Determine which drive the 250GB is and note the /dev/sd that it is.

Next, you are going to fail the drive from the array and remove it. I am just going to use my /dev/sdf drive as an example:

sudo mdadm --manage /dev/md1 --fail /dev/sdf1
sudo mdadm --manage /dev/md1 --remove /dev/sdf1

You will then need to replace the drive in the system with your new one. After it is booted back up, add the new drive back into the array and use the --grow command to grow the array.

You need to create a blank partition on the new drive, use like gparted and match the other drives. More than likely it might be ext4.

Now add the drive to the array:

mdadm --add /dev/md1 /dev/sdf1
mdadm --grow --raid-devices=3 /dev/md1

That last part there can take hours up to even days to do. If you want to monitor its progress, you can run the following in a terminal window:

watch -n .1 cat /proc/mdstat

Hope this helps!

Terrance
  • 43,712