The media path stored in Preferences is stored with the database. If you had more than one database, each could have its own unique path.
Without a stored path, the path field of each media record will be the full directory pointing to the file.
The ideal, and easiest to backup etc, is to store all your media files for a database in the same media folder. I am on Win10 and my media path is C:\Users\daves\Genealogy\Media. Under the Media folder, I have a number of folders… Birth, Marriage, Death, Census, Church, Military, etc to store the actual files. Other users use a folder system by family name.
When adding a new media record, there is a check box… Convert to a relative path. This has Gramps only store the subfolders and file name in the record’s path field. Gramps knows the base path.
There is the Media Verify addon tool that will use the base media path and the stored checksum for each media file to fix issues.
My Census folder was getting too large so I broke it down into sub-folders by country and state and for the U.S. federal census by year. I moved the records to their knew folders and where appropriate, renamed the files. The file name did not need 1940 when it was now in the 1940 folder. Media verify, using the checksums and the base path found all of the moved and renamed files. It was a simple fix to update all of their path’s in their Gramps record.
I like the idea, however I fear it is too late for me for that now since I have approx. over 100 documents that are attached to all people in one family tree.
It would have been nice if I would have had this information earlier.
I would suggest experimenting with this tool before using it on your main tree. I would personally backup the entire database with media, and then restore it into a different tree. This will duplicate all your media, so that you can freely experiment with moving the media around with your testing tree. Of course there are other ways to do this too.
flatpak specific
Specifically for the flatpak, the Gramps flatpak has full home directory access. It has no root directory access, which includes removable media drives. If you want to access a removable drive (or not recommended due to speed–a network drive) in the flatpak, the easiest method is to install an app named flatseal. Flatseal can change the permissions for any flatpak. https://flathub.org/en/apps/com.github.tchx84.Flatseal
It is never too late!! (Famous last Words!) But this is why Backups are important!!
You can enter the base media path in Preferences.
Install the Media Verify tool and run the Generate option. This ensures that the checksum of the raw media file agrees with its record in Gramps. This is important because if you ever edited the raw file (resized, cropped, etc) after creating its Gramps record, the checksums will be different.
Now you can create a set of sub-folders and move the files into their new folders.
Now run the MV tool again this time using the Verify option. The tool will find the files in their new folders and present you with a list of the old information and the new information it wants to modify. Use the Fix option to make the changes.
All the changes that would be made are in the media records. Nothing changes to the media record attached to Aunt Mary.
In the earlier post I mentioned doing this with my census records. Currently I have more than 7000 census records and MV handled it with ease.