On 03/01/2014 01:02, Chris Stankevitz wrote: > Hello, > > Please consider a USB "stick" that is unformatted but is to be used by > multiple people/machines. Ideally your instructions will work for all > people/os/WM, but if necessary please assume that everyone is running > gnome under linux > > 1. How should I prepare this device so that it can be plugged into any > machine and will be writable by anyone? I suspect the answer will > involve words like fdisk, mkfs.xxx, mkdir/mount, chmod/chown. I'm > most interested in the chmod/chown part. > > 2. How can I prepare the device so that files/directories added by > people in the future will continue to be writable by anyone? > > 3. How can I ensure that all files will appear to have the same owner; > or, if this is not important, can you explain why it should not be a > problem. > > And of course if you can refer me to a document that explains this I'm > happy to read it.
Just go with FAT and automounting by the DE. It's a removeable stick, the user has it in their hands so the entire concept of security is instantly null and void right there. Forget all about /etc/fstab, mount options user and user, mount options mask, fmask and dmask. Instead, put each user that needs to use it in the plugdev or disk group as appropriate and let the DE do the heavy lifting; and remove from fstab anything and everything related to removeable USB sticks. If you let the DE do the automounting for you, you get a filemanager window (dolphin, nautilus and friends) and the contents of the stick are visible right there, ready to use, all set up correctly. DO NOT USE NTFS ON A STICK. The driver has been reverse-engineered and there is no guarantee that writing to it under anything that isn't Windows will work. FAT is a published standard and we all know how it works. tl;dr You don't need chown/chmod at all. FAT has no concept of owner and permissions, so the kernel fudges these. Basically, when mounting the stick it pretends every file on it is owned by the user that mounted it and everything has permissions 777, regardless of who plugged it in. Considering the nature of a USB stick, this is almost always what you want. Don't bother partitioning the stick either, Windows treats them as one huge floppy and so should you. You will normally only ever have one partition anyway, so why have any at all? The code supports this. To format it in Linux, do this: mkfs.vfat -I /dev/<whatever> Stay far away from /etc/fstab. That file was designed ages ago for permanent mounts, like / and /usr and /home. To work properly, you must be able to uniquely identify any device and never get it confused. You just can't do that with sticks, not even with fs labels, and you certainly don't want to hand-edit UUIDs. And you still have to deal with users having different uids on each machine. Ugh. The DE just makes all this hassle go away. If your sticks are larger than 32G, you might want to use exFAT instead of FAT - think of it as FAT that can deal with huge disks properly: emerge sys-fs/fuse-exfat you will need FUSE support in your kernel for this. -- Alan McKinnon [email protected]

