Gentoo Archives: gentoo-user

From: Alan McKinnon <alan.mckinnon@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Preparing a shared USB stick
Date: Fri, 03 Jan 2014 06:46:25
Message-Id: 52C65C99.5080208@gmail.com
In Reply to: [gentoo-user] Preparing a shared USB stick by Chris Stankevitz
1 On 03/01/2014 01:02, Chris Stankevitz wrote:
2 > Hello,
3 >
4 > Please consider a USB "stick" that is unformatted but is to be used by
5 > multiple people/machines. Ideally your instructions will work for all
6 > people/os/WM, but if necessary please assume that everyone is running
7 > gnome under linux
8 >
9 > 1. How should I prepare this device so that it can be plugged into any
10 > machine and will be writable by anyone? I suspect the answer will
11 > involve words like fdisk, mkfs.xxx, mkdir/mount, chmod/chown. I'm
12 > most interested in the chmod/chown part.
13 >
14 > 2. How can I prepare the device so that files/directories added by
15 > people in the future will continue to be writable by anyone?
16 >
17 > 3. How can I ensure that all files will appear to have the same owner;
18 > or, if this is not important, can you explain why it should not be a
19 > problem.
20 >
21 > And of course if you can refer me to a document that explains this I'm
22 > happy to read it.
23
24
25
26 Just go with FAT and automounting by the DE.
27
28 It's a removeable stick, the user has it in their hands so the entire
29 concept of security is instantly null and void right there. Forget all
30 about /etc/fstab, mount options user and user, mount options mask, fmask
31 and dmask. Instead, put each user that needs to use it in the plugdev or
32 disk group as appropriate and let the DE do the heavy lifting; and
33 remove from fstab anything and everything related to removeable USB sticks.
34
35 If you let the DE do the automounting for you, you get a filemanager
36 window (dolphin, nautilus and friends) and the contents of the stick are
37 visible right there, ready to use, all set up correctly.
38
39 DO NOT USE NTFS ON A STICK. The driver has been reverse-engineered and
40 there is no guarantee that writing to it under anything that isn't
41 Windows will work. FAT is a published standard and we all know how it works.
42
43 tl;dr
44
45 You don't need chown/chmod at all. FAT has no concept of owner and
46 permissions, so the kernel fudges these. Basically, when mounting the
47 stick it pretends every file on it is owned by the user that mounted it
48 and everything has permissions 777, regardless of who plugged it in.
49 Considering the nature of a USB stick, this is almost always what you want.
50
51 Don't bother partitioning the stick either, Windows treats them as one
52 huge floppy and so should you. You will normally only ever have one
53 partition anyway, so why have any at all? The code supports this. To
54 format it in Linux, do this:
55
56 mkfs.vfat -I /dev/<whatever>
57
58 Stay far away from /etc/fstab. That file was designed ages ago for
59 permanent mounts, like / and /usr and /home. To work properly, you must
60 be able to uniquely identify any device and never get it confused. You
61 just can't do that with sticks, not even with fs labels, and you
62 certainly don't want to hand-edit UUIDs. And you still have to deal with
63 users having different uids on each machine. Ugh. The DE just makes all
64 this hassle go away.
65
66 If your sticks are larger than 32G, you might want to use exFAT instead
67 of FAT - think of it as FAT that can deal with huge disks properly:
68
69 emerge sys-fs/fuse-exfat
70
71 you will need FUSE support in your kernel for this.
72
73
74 --
75 Alan McKinnon
76 alan.mckinnon@×××××.com

Replies

Subject Author
[gentoo-user] Re: Preparing a shared USB stick James <wireless@×××××××××××.com>
Re: [gentoo-user] Preparing a shared USB stick Chris Stankevitz <chrisstankevitz@×××××.com>