Install new SSD drive and move /opt folder to it

I have a server with two SSDs in RAID1 configuration on a centos 7.9 machine. I am running out of space on the two SSDs, because of the RAID1 configuration and the size of the /opt folder. The RAID1 configuration has its’ benefits.I will install a third SSD and I would like to move the /opt folder to it.

My understanding is that I would need to edit the /etc/fstab file and I think the modification should be something like this.

UUID=abcabcabdabd..abcd /opt ext4 defaults 0 2

and then I would just have to move the folder over

Is the above understanding correct ?

Asked By: stackQA

||

Yes.

  • You attach the SSD to the system.
  • Check in dmesg or using lsblk which device name is used.
  • Then decide if you want to use partitioning. Note that you can use ext4 on a raw block device, without partitioning, as well.
  • After the filesystem is created (mkfs.ext4), you would rename /opt to /oldopt, edit the /etc/fstab file, put in the correct line (get the UUID from blkid). Add ,nofail after defaults to prevent the system from going into maintenance mode when the SSD isn’t present at boot time.
  • Run mount -a, you should see the new and (almost) empty /opt present.
  • Move over everything out of /oldopt to /opt.

If you run into SELinux troubles afterwards, it could be that the extended ACLs weren’t moved over correctly (shouldn’t happen). Then just run restorecon -Rv /opt.

Answered By: Edward
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.