I always thought unprivileged users couldn't format a USB drive, only root user could, so I used to mess up with gparted or fdisk.

After years or daily Linux usage I just discovered that gnome-disk-utility allows a user to format a USB drive without admin privileges.

I guess the user needs to belong the same group that allows mounting/unmounting (plugdev on Debian) and the permissions are managed the same way (you can't unmount or partition system partitions, for instance).

What is the recommended way to format a USB drive?

Almost every suggestion I find on the Internet involves fdisk or gparted, therefore being root. But even if you can log as root on your system, it is bad practice to be root when not necessary.

From this perspective, gnome-disk-utility comes as a blessing.

Is there a CLI equivalent to gnome-disk-utility ? Not-gnome graphical equivalents?

  • I think gnome-disks also requires root privileges through polkit. – Pandya Jan 26 '16 at 9:38

All applications ran by normal user need extra permission to access /dev/* (that is owned by root, and other users need to be added to groups, like You said, to be able to manipulate files there according to group permissions)

To answer Your question mkfs is utility for formatting from commandline, for example mkfs.exfat (with arguments)

to allow users to run it without password You might for example add following entry to the bottom of /etc/sudoers

%sudo ALL = (root) NOPASSWD: /sbin/mkfs

yet, I dont think You would want that (any user could format any drive...). And actually, gnome-disks asks user for a password when formatting, at least it does in my case.

  • OK then I shall check but I'm pretty sure it asked for a password when I tried to mess up with / (as a test) but not to format my USB stick. Obviously, if this assertion is false, my question is of little interest. – Jérôme Jan 26 '16 at 10:22
  • I'd disagree about question being of little interest. Actually I find GNU/Linux permissions quite broad - cgroups, groups, selinux, sudo, setuid's, not to mention all polkit and other GUI settings, so there might be some other items influencing/modifying default behaviour, which might be confusing, maybe not for You, but to some users. – JustMe Jan 26 '16 at 10:27
  • I just checked and I confirm that gnome-disk-utility allows me to format my USB drive as user without entering any password. I didn't find any option to partition it differently. I can just format the existing partition. My groups are jerome cdrom floppy audio dip video plugdev netdev lpadmin scanner bluetooth. I suspect the mechanism is similar if not the same as the one that allows members of plugdev to mount a USB drive partition. – Jérôme Jan 26 '16 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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