user folder on sd card with user ownership

when I create an extra user on the 'native' Yun memory the adder user dir automatically gets the correct ownerships.

e.g.

useradd -b /home -m -c "another test" -s /bin/ash test2

creates the user and the folder has following properties:

drwxr-xr-x    2 test2    test2            0 Nov  2 11:53 test2

However if I create a user in the same way, but with the dir on the SD card, the user dir gets root ownership:

drwxr-xr-x    2 root     root         32768 Nov  2 11:35 testuser

Even as root I am not able to change the ownership of this directory.

Any idea what is happening?

Ok, so it seems FAT or NTFS do not support this :frowning:

Most probably the filesystem on the card is a (win)dos one.

You can check this issuing the 'mount' command (it should be the one of 'vfat' type).

In order to have extended attributes like owner, permissions, etc, you have to format the partition to a linux/unix filesystem, so after having unmounted it and installed the relative utilities with:

opkg install e2fsprogs

just run something like:

mkfs.ext4 /dev/sda1

and mount it back.

cheers,
nic

Thanks! I will give this a try!

FAT does not support permissions, NTFS does but I'm not sure it works with linux.
If you really need permissions you need to use some ext (ext4, ext3) filesystems or whatever other posix compliant one
Beware: your windows/mac may not read the sd card any more

that's absolutely right!

mind the above 'mkfs' command, it will wipe the sdcard content.

One "issue" I had with unmounting - formatting - mounting is that I was unable to mount the SD card again.
It complained that the to be mounted stuff was not present in /etc/fstab ?

When I turned off and on the power of the Yun, it did mount automatically again, so it was not a big issue.

Did you umount before formatting? If you didn't, chances are kernel didn't update its "in memory" partition table for the device, that would also justify why it worked after reboot

I did succesfully umount before the formatting.

it could happen sometimes (i.e. under heavy load) that while unmounting the filesystem, the corresponding record isn't deleted from the /etc/mtab (nowadays a link to an entry in the /proc filesystem).

consequently, filesystem related utilities are puzzled and misreporting, as in your case.

it's just a minor issue, as the really important point is to correctly close files, detach the filesystem from the directory tree and mark some flags on the partition indicating that everything went fine to subsequent mount operations.

possible workarounds are manually deleting the offending record, using 'umount' with some options or mounting and then unmounting the filesystem.

cheers,
nic