Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Past experience has taught me never to test out unfamiliar media players on my existing media library, lest nosy "convenience" functions automatically rearrange, re-tag, sloppily import into, or otherwise alter my carefully-curated data.

How can I expose my music to such a player in a read-only fashion?

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

I will show two methods that do not require to alter the files in the media library.

Accessing data from another user

Create a new (non administrative) user otheruser, add it to your group:

sudo gpasswd -a otheruser $USER

Modify your home to grant read and execute permissions for the group members (this is required if you have an encrypted home partition):

chmod g+rx $HOME

Then switch to otheruser, that should have now read access to all your data.

I should point out that, if you have an encrypted home partition, the other user could access your data as long as you are logged in. So you should login then switch user without loggin out from the first user.

Pretend to modify permissions

The package bindfs allow to mount a given directory with altered permissions, so the steps could be:

Install the package

sudo apt-get install bindfs

Create a mount point and assign it to your user

sudo mkdir /media/home-altered
sudo chown $USER:$USER /media/home-altered

Mount the real home to the mount point without write permissions:

sudo bindfs -p a-w $HOME /media/home-altered

Now, in /media/home-altered you will see your home directory with altered permissions, and accessing data through that path prevent to modify the data.

EDIT

Almost the same effect of the second method can be obtained with a bind mount and a read-only remount:

sudo mkdir /media/$USER
sudo mount --bind /home/$USER /media/$USER
sudo mount -o remount,ro /media/$USER
share|improve this answer
    
I doubt that any one will be willing to logon as a different user just for trying/using a media player. –  binW May 23 '11 at 14:40
1  
@binW: it is for testing purposes, not a definitive solution. This is what ask the user, if I understand correctly. –  enzotib May 23 '11 at 14:45
    
@binW: I added a second method that do not require to switch user. –  enzotib May 23 '11 at 15:13
    
Thanks, a bind mount is just what I needed. I ended up using the kernel's built-in bind mounts: mount --bind olddir newdir && mount -o remount,ro newdir –  ændrük May 24 '11 at 15:01
add comment

Ok this is far-fetched but I sometimes do this when I really want to preserve/protect a file as it is.

So would you bother setting all of your music files to immutable even temporarily? Even root can't edit when the immutable bit is enabled.

chattr +i FILENAME

Oh but sadly it's only limited to EXT file systems. And I totally relate to your predicament. One time I accidentally deleted 2/3s of my music files because I executed a command that purged everything that ended with .mp3.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.