[CentOS] SEcontext setting failure on an external harddisk

Fri Oct 9 14:53:34 UTC 2020
H <agents at meddatainc.com>

On 10/08/2020 11:10 PM, Jonathan Billings wrote:
> On Oct 8, 2020, at 15:22, H <agents at meddatainc.com> wrote:
>> I tried moving a PosgreSQL database to an external harddisk due to lack of space on the main harddisks. Not the ideal solution of course but it should work. However, on CentOS 7 the external harddisk is mounted under /run/media and the user. I copied the postgresql database directory and made sure it is owned recursively by postgres, changed the necessary settings in both the systemd unit and the conf file.
> I don’t believe that the volume will be mounted on boot in /run/media, that is for storage mounted by a user logged at the console. 
> It would make more sense to set up a systemd .mount and .automount unit for the device and mount point (someplace outside of /run, such as /srv/mountpointname). Then set up the labels correctly. 
> You need to use a file system that supports extended attribute if you want it to work with selinux, so XFS or ext4.
> --
> Jonathan Billings
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> https://lists.centos.org/mailman/listinfo/centos

You are correct, I mounted the external harddisk as a user. The harddisk is formatted xfs so it supports labels.

However, I was not planning to automount this disk every time which of course would mean postgresql would fail without the harddisk. It might be better to use the smaller existing space on the existing harddisk until I buy a larger internal harddisk which would automount and then move postgresql to that.

Thank you for your reply.