mount an mdadm raid 1 drive at boot

I was wondering if you guys could help. I am looking to mount my mdadm RAID 1 at boot.

The drive location is /dev/md127 and I would like it to mount to /media/server at boot. It is formatted to ext4. Your help will be truly appreciated.


Solution 1:

You could add an entry to /etc/fstab:

/dev/md127    /media/server    ext4 defaults 0 0 

Make sure that /media/server is present:

sudo mkdir -p /media/server

You could use the UUID of the partition instead of /dev/md127. The UUID of a filesystem is unlikely to change unless you alter it, whereas the partition may change its identifier and be named md0 or md255 or something like that.

Use the blkid or lbslk command to get the UUID, and then replace /dev/md127 with UUID=xxx-xxxxx-xxxxxx-xxx in the above line:

# lsblk -o NAME,UUID
NAME    UUID
sdc     
└─sdc1  8ebc357c-3d93-fd86-0535-cb852bbc7289
  └─md2 5348f582-8a9c-43c3-bf5b-eaabd644035b
sdd     
└─sdd1  8ebc357c-3d93-fd86-0535-cb852bbc7289
  └─md2 5348f582-8a9c-43c3-bf5b-eaabd644035b
# blkid
/dev/sdc1: UUID="8ebc357c-3d93-fd86-0535-cb852bbc7289" UUID_SUB="77e19cfe-ed79-613f-bb18-b56bc30e0858" LABEL="titan:2" TYPE="linux_raid_member" 
/dev/sdd1: UUID="8ebc357c-3d93-fd86-0535-cb852bbc7289" UUID_SUB="e99d0a33-4944-4f1e-4a90-b65fa2e57b56" LABEL="titan:2" TYPE="linux_raid_member" 
/dev/md2: UUID="5348f582-8a9c-43c3-bf5b-eaabd644035b" TYPE="ext4" 

The UUID of /dev/md2 (the RAID array in this case) is 5348f582-8a9c-43c3-bf5b-eaabd644035b, so the entry would look like:

UUID=5348f582-8a9c-43c3-bf5b-eaabd644035b   /media/server   ext4    defaults  0 0