Changing ownership on USB - using chown

anneranch

Active Member
Credits
1,109
I have used the following to change ownership from "root" to "qw"


[email protected]:~$ sudo chown qw: /dev/sdi1

I received no error, however, file manager ( Ubuntu 21.04) still reports the owner as "root" .
What am I doing wrong ?
 


Fanboi

Active Member
Credits
3,751
You're trying to chown a device, not a filesystem. sdi1 represents a partition on sdi (*nix systems use device filsesystems to make access transparent and let you do 1337 stuff. That's not one, though.

Try mounting it to change ownership/perms:
Code:
// TEMP mount (avoid conflict with /mnt)
sudo -i
mkdir -p /tmp/qw/mnt
mount /dev/sdi1 /tmp/qw/mnt
chown -R qw:qw /tmp/qw/mnt/

// When you're ready to umount, use:
umount /tmp/qw/mnt
Assuming the sdi1's filesystem supports perms, ownership, etc. of course.

FYI: You'd do best to setup a proper fstab entry if you're going to be using it permanently. Let us know more as setting it up in fstab is simple and will save you grief if you're using the storage device permanently/regularly.
 

anneranch

Active Member
Credits
1,109
So my error was to try change ownership of device .
The /dev/sdi1 was mounted , but I did not use correct procedure.

Now it works just fine and here is the entry in fstab, I did
not put it there. So it should mount on boot.

Since the reason forr having this USB is to have a storage of documents accessible by any of my multi-boot OS I should be able to change the ownership in each OS as necessary.

Thanks

# /etc/fstab: static file system information.

/swapfile none swap sw 0 0
/dev/disk/by-id/usb-Lexar_USB_Flash_Drive_AADPBC2RCKJ2PVBM-0:0-part1 /mnt/usb-Lexar_USB_Flash_Drive_AADPBC2RCKJ2PVBM-0:0-part1 auto nosuid,nodev,nofail,x-gvfs-show,x-gvfs-name=DISK_B 0 0
 

Fanboi

Active Member
Credits
3,751
You won't have to change ownership per-OS if you're the only user since the default starting user ID is 1000, as is the user's Primary Group. So once the owner is you:yourGroup on one OS, it'll be the same on any other Linux OS (assuming vanilla settings.

I'd suggest creating your mountpoint(s) in /media/<category>/<partition> since /mnt is historically a temporary mount point (I avoid it because my rationale is that /tmp has less potential conflict, is user-accessible, gets erased at reboot, is not for root purpose, etc.)
You may want to consider mounting by LABEL= in the future as this is more portable (supposing you buy a new device you want to use for the same purpose), but that's not an issues so much as an annoyance-preventer.

Well done for taking such initiative! Glad your problem's sorted.
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Members online


Top