Help me pick the best location for my MP3s on Linux
November 18, 2006 12:27 PM   Subscribe

Where is the best place to store my MP3 collection on my Linux (Debian) PC?

Hi, Linux noob alert!

I've migrated from Windows XP to Kubuntu (hoorah!) and I'm trying to get to grips with the filesystem, user management etc.

There are 2 users on the system - me and my wife. My MP3s are currently on a USB hard drive and I want to put them on my internal hard drive in a location accessible to all local users and applications like Amarok. I don't want to store the files in either user's home folder, so where's best to put them?

posted by DZ-015 to Computers & Internet (9 answers total) 6 users marked this as a favorite
Back when I rand Debian, I made a /media folder (on a seperate partition, actually), and made the group "media". I then gave all users (myself and a few friends) access to that group.
posted by JMOZ at 12:36 PM on November 18, 2006

open a terminal window
run: sudo mkdir /media
run: sudo chmod 777 /media
do: with the file manager put all the files from your usb disk into /media.

The sudo commands will ask you for the root password.

The 777 permissions allow anybody and everybody on your system to do anything they want with the directory. Typically it's bad security, but since this is a personal box, it doesn't matter.
posted by cschneid at 12:47 PM on November 18, 2006

the Filesystem Hierarchy Standard, which debian attempts to adhere to by policy denotes /srv as a good location for site-specific data which is served by this system, which is what this sounds like to me.

I'd be very wary of advice to chmod 777. That gives write (and delete) access to everything on your system: not just user accounts, but system services, daemons, etc. Better to make the files mode 0664, (directories 0775), group "music", and put the user accounts (you and your wife, from the sounds of things) into group "music".

If your USB disk is located at /foo/bar, and your user account is qux, this would look something like (lines starting with # are comments -- sorry if this shows up double-spaced. i'm not sure why that's happening):
# create the music group
sudo addgroup music
# add yourself to the group
sudo adduser qux music
# gain group privileges (otherwise you'll only get them at your next login)
newgrp music
# create the place you will put the music, and give it the right ownership
sudo mkdir -p /srv/music
sudo chown qux:music /srv/music
# copy the music in, and set its group to the proper group:
cp -r /foo/bar/* /srv/music/
chgrp -R music /srv/music
# make sure the permissions on all the files are the right values:
find /srv/music -type f -exec chmod 0664 '{}' ';'
find /srv/music -type d -exec chmod 0775 '{}' ';'
hope this helps!
posted by dkg at 1:03 PM on November 18, 2006

I generally store it in the /var partition/disk, since I think of my music collection as something of a database that gets written to/retrieved from fairly frequently. It also usually gets its own large disk, whereas the rest of the OS gets a relatively small/fast disk.
posted by devilsbrigade at 3:03 PM on November 18, 2006

"I made a /media folder"

I wouldn't to that today, as /media is used for mounting removable media, such as CD drives, flash drives and so on. On a recent Linux system having /media as a mount point could cause some minor problems. See for more info on /media:

Where I put my MP3's is /mnt/mp3, which used to be a seperate drive. But, over the years of installing new hard drives and upgrading systems is now a symbolic link to another location.

As you own the system you could put the MP3's anywhere, but literally anywhere can be a bad idea! :)

Can you tell us how your system is partitioned? As this may help us tell you where not to put the MP3's.

If your /home is a seperate partition and is big enough you could put them in /home/mp3
posted by zaphod at 4:11 PM on November 18, 2006

If you have /home as a separate slice, and you put your mp3s in /home/mp3s, you can upgrade your system at will without having to back your home directory and mp3s up (just don't format that slice during the install).
posted by cmonkey at 7:24 PM on November 18, 2006

I wrote a long post, and then I realized that all this may be too complex. If you want it very simple, just make a directory, copy in all your files, and do:

sudo chmod -R 777 /srv/music

This is horribly insecure by Unix standards, and it leaves the files open to destruction by any account on the box, but this most resembles how Windows works. If you just want it to be simple and easy, that's the quick way to do it. Rerun the chmod every time you add new files and things will just work. If you want to do it better, here's the original long post:

That's normally how I'll do shared files... put them in a specific directory under /home. My major shared mountpoint from my personal server, in fact, is /home/fileshare. I just put user accounts I want to have access to that in the proper group. I consider music a subset of filesharing in general, so my FLACs are all in /home/fileshare/Music.

I'm not sure if this is really 'proper', exactly, but it works well for me. Having the files under /home means that it's easy to upgrade and fool with the system without damaging anything. If I'm doing something I think is particularly dangerous, I may even unmount /home for the duration.

One permission that the other folks didn't mention is putting 'group sticky' on the directories. This is useful, because any files you create under a group sticky directory is automatically set to that group. This means your wife can add files and you can read them, or you can add files and your wife can read them.

Quick explanation: Unix has three permissions, User, Group, and Other. By default, virtually all Linux distributions have both a group and a user account with the same name. If your user account is 'joe', there will also be a group in the system called 'joe', and all your files will be set to joe:joe. That means your wife, 'susan', can't read any files you create, unless you set Other permissions, or unless you add her to the 'joe' group.

By putting both of your user accounts in a group called 'music', setting the container directory to be group music, and setting the group 'sticky bit', any files you create under music will be set to joe:music. Susan, because you added her to the music group, will be able to read them. Files she adds will be susan:music, and you will be able to read them.

I haven't tested dkg's script above, but assuming his syntax is correct, you can add this line to the end:

find /srv/music -type d -exec chmod g+s '{}' ';'

The g+s is the important part there... it adds group sticky to all directories under /srv/music. Any further directories you make later will inherit the sticky bit automatically.

Advanced feature: you can improve the usability of shared files if you edit /etc/profile. Look for a line that says 'umask 022'. Change that to 'umask 002'. If you do this before you start, and reboot the box (easier than restarting the services, usually), group write permission will be on by default. This means that each user account will be freely able to move and rename files in the music directory that the other account created. If you don't want that feature, just don't mess with /etc/profile.
posted by Malor at 9:11 PM on November 18, 2006

Thanks for all your suggestions. I've created a group called music and put the files in /srv/music as suggested by dkg with myself and my wife in the music group. Everything seems to be fine and Amarok was able to build a collection.
posted by DZ-015 at 11:10 AM on November 19, 2006

If you set the group sticky bit, that will let either of you massage files created by the other. If you want that, see above re: g+s. :)
posted by Malor at 2:41 AM on November 20, 2006

« Older How to handle a phone interview   |   Book of woods Newer »
This thread is closed to new comments.