0

In my WSL2 Debian distro, I created an image file named VirtDisk.img and set it as a virtual block device:

dd if=/dev/zero of=VirtBlock.img bs=1G count=16                                       
16+0 records in
16+0 records out
17179869184 bytes (17 GB, 16 GiB) copied, 11.204 s, 1.5 GB/s

sudo losetup -f -P VirtDisk.img

And then partitioned it intto three parts as below and make a filesystem to them as marked with []:

sudo fdisk /dev/loop0                                                                 

Command (m for help): p
Disk /dev/loop0: 16 GiB, 17179869184 bytes, 33554432 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x30f503f9

Device       Boot   Start      End  Sectors  Size Id Type
/dev/loop0p1         2048  1050623  1048576  512M ef EFI (FAT-12/16/32)         [FAT32]
/dev/loop0p2      1050624  5244927  4194304    2G 82 Linux swap / Solaris       [swap]
/dev/loop0p3      5244928 33554431 28309504 13.5G 83 Linux                      [EXT4]

Then I mounted the /dev/loop0p1 to ~/mnt dirctory, and use chown to change the owner of the mount dir.

But it get an "Operation not permitted" error although I used sudo as prefix.

sudo mount /dev/loop0p1 mnt

sudo chown colorglass mnt                                                              
chown: changing ownership of 'mnt': Operation not permitted

And when I changed to root to perform the same op, it still gave the same result.

And I the date attribute of the ~/mnt dir became Jan 1 1970.

ll
drwxr-xr-x 2 root       root       4.0K Jan  1  1970 mnt

Did I made any wrong operations?

1
  • Probably the good idea here is to create subfolders under /mnt to mount the fs. We never use /mnt directly.
    – admstg
    Feb 15 at 13:48

1 Answer 1

0

A FAT32 filesystem (as standard on an EFI System Partition) has no way of storing file ownerships or unix-style permissions, so the error message means in this case "what you're asking is impossible".

Since the loop0p1 is mounted to /mnt, your attempted chown is actually targeted to the root directory of the loop0p1 filesystem - the actual /mnt directory of the loop0p3 filesystem is "covered" by it. When a directory is being used as a mount point, it's actual permissions are essentially meaningless and the properties of the root directory of the mounted filesystem will take over. The date attribute was "changed" for the same reason.

The only way to change the ownerships/permissions on any FATxx filesystem is to use mount options - and you can only set one set of permissions for all directories and another for all files in the mounted filesystem. Every file and directory in a FATxx filesystem will have the same owner and group, but you can.use mount options to specify what those will be.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .