Why do my files only appear when the drive is unmounted?

Background

I’d like to store music on /dev/sda1, which is a physically separate drive. The /etc/fstab contains:

# grep "music" /etc/fstab
UUID=10...92 /mnt/music ext4 defaults,user,rw 0 2

Problem

When the system restarts, the files disappear:

# ls /mnt/music/
lost+found

When unmounting the drive, the files reappear:

# umount /mnt/music
# ls /mnt/music
archives  jazz  logs  scripts

In both cases, the directory /mnt/music is owned by the user account, not the root account.

I’ve also tried changing the /etc/fstab entry to:

UUID=10...92 /mnt/music ext4 rw,nosuid,nodev,noexec,relatime,user=USERNAME 0 2

Question

How do you mount a drive in Arch Linux such that it is read-write for a specific user at startup (without having to unmount the drive)?

Asked By: Dave Jarvis

||

Your problem is that you wrote the files to the wrong filesystem (the one containing the /mnt/music directory, rather than the on on /dev/sda1).

To fix this, get the admin to move the mount elsewhere, and move the files from /mnt/music into the mounted filesystem.

user-only version
Alternatively, as an ordinary user, umount the filesystem and cd into /mnt/music.
Then mount the filesystem. Now, /mnt/music is your filesystem and . is the underlying (shadowed) directory – confirm that, e.g. using ls.
Now put the files where you wanted them: mv * /mnt/music.

sync for good luck, and you’re done.

To ensure that the filesystem gets mounted at boot time, get auto added to its mount options in /etc/fstab.

Answered By: Toby Speight