r/linux4noobs • u/GarageDry125 • 3d ago
programs and apps non-root usb formating
Is there a cli utility like udisks2 that allows non-root users to format removable drives without sudo/doas?
UPDATE: m4uri's suggestion gets the closest to what i want, without more intricate modification, so i'll be using it inside a shell wrapper until i work up the motivation to re-work/write udisksctl.
NOTE: busybox's implementations of mkfs are stricter than the gnu ones and don't work with udisks2(udisksctl)/gnome-disks/gparted
Thank You for the help
2
Upvotes
2
u/Elegant-Falcon-1171 3d ago
No, porque justamente tienes que formatearla, pero desde un administrador de discos puedes hacerlo
2
u/Educational_Bee_6245 3d ago
If you have the right udev rules that set appropriate permissions on the device files a non-root user can surely format a drive.
1
u/m4uri 2d ago
udisks2 can do it, udisksctl just doesn't expose formatting. The Format method is there on D-Bus though, and that's what GNOME Disks uses without sudo.
Unmount first, then call it on the partition, e.g. /dev/sdb1 as FAT32:
exfat or ext4 work too, as long as the matching mkfs tool is installed. Whether you get asked for a password is up to polkit. On a local desktop session removable drives usually go through without one, over ssh or from cron it will want auth. For fully promptless use by a certain group you can drop in a small polkit rule for org.freedesktop.udisks2.modify-device.
Check the device with lsblk first, the call won't ask if you're sure.
1
u/TomDuhamel 2d ago
I don't think there is a concept of "removable" at the block level where formatting is executed. I'm pretty sure you need to be root either way.
1
u/AutoModerator 2d ago
✻ Smokey says: always mention your distro, some hardware details, and any error messages, when posting technical queries! :)
Comments, questions or suggestions regarding this autoresponse? Please send them here.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.