LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Setting permissions for files from Windows (https://www.linuxquestions.org/questions/linux-newbie-8/setting-permissions-for-files-from-windows-776943/)

MTK358 12-19-2009 05:08 PM

Setting permissions for files from Windows
 
I have a flash drive formatted as FAT32 with my data on it. I copied all my photos from it but realized that the permissions are totally garbled: the flags say "????????" and some of them even say "Permission Denied". Because there is no owner specified, I cannot run chmod.

How to fix this?

(and I am really considering to reformat the flash drive to a Linux filesystem now)

bret381 12-19-2009 05:11 PM

can you chown the files to root and then chmod?

MTK358 12-19-2009 05:23 PM

Code:

# chown -R root:root Pictures/*
Didn't help.

bret381 12-19-2009 05:41 PM

I've never had a problem copying from usb drive that came from windows machine. Hmmm, is the file possibly corrupt?

jschiwal 12-19-2009 05:45 PM

It does sound like the filesystem is damaged. By the way, you can't use chmod or chown for fat32, but you can for files you copied to a linux partition.

First eject the flash drive and then reinsert it. Maybe it will mount properly.

You can also attempt a repair.
I'd recommend using dd or ddrescue to create an image file of the flashdrive. Then run "/sbin/fsck.vfat <imagefile>" to try to repair it. You might want to create a copy of the image file and work on the copy. That way, if you cause damage to the file, you can delete it and make another copy.

If this doesn't work, you could use "testdisk" to try to recover files from the image.

MTK358 12-19-2009 07:14 PM

It worked this time.

I actually first copied them when I just installed Fedora a few weeks ago.

And I still want to format the flash drive with something like ext3/ext4, because losing all your file permissions is still a big pain.

MTK358 12-19-2009 07:24 PM

I reformatted the drive to ext4 using fdisk and mkfs.ext4.

Now I will be putting my stuff on it.

MTK358 12-19-2009 07:33 PM

I noticed that even the successfully copied files got corrupted by running chmod -R!!!

Thankfully I had another flash drive with the same data on it just in case. I was hoping to remove the executable permission from my pictures.

jschiwal 12-19-2009 09:15 PM

FYI. For a vfat filesystem, you can use the fmask options when mounting the drive. This sets the permissions of all of the files on the (mounted) filesystem. You are correct that you loose linux ownership, groups & permissions when copying files to a fat32 filesystem. You can use tar to backup your pictures on a fat32 filesystem. Then when restoring them onto a Linux filesystem, you will restore the permissions as well.

If you still see question marks after formatting the flash drive, your drive is bad and should be replaced.

For a flash drive, you may want to mount it using the "noatime" option to reduce the number of writes.


All times are GMT -5. The time now is 07:18 PM.