[CentOS] SEcontext setting failure on an external harddisk

Thu Oct 8 21:10:54 UTC 2020
Jonathan Billings <billings at negate.org>

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