LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-19-2009, 06:08 PM   #1
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
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)
 
Old 12-19-2009, 06:11 PM   #2
bret381
Member
 
Registered: Nov 2009
Location: Alabama
Distribution: Arch x86_64
Posts: 650

Rep: Reputation: 78
can you chown the files to root and then chmod?
 
Old 12-19-2009, 06:23 PM   #3
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Original Poster
Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
Code:
# chown -R root:root Pictures/*
Didn't help.
 
Old 12-19-2009, 06:41 PM   #4
bret381
Member
 
Registered: Nov 2009
Location: Alabama
Distribution: Arch x86_64
Posts: 650

Rep: Reputation: 78
I've never had a problem copying from usb drive that came from windows machine. Hmmm, is the file possibly corrupt?
 
Old 12-19-2009, 06:45 PM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
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.

Last edited by jschiwal; 12-19-2009 at 06:47 PM.
 
Old 12-19-2009, 08:14 PM   #6
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Original Poster
Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
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.
 
Old 12-19-2009, 08:24 PM   #7
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Original Poster
Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
I reformatted the drive to ext4 using fdisk and mkfs.ext4.

Now I will be putting my stuff on it.
 
Old 12-19-2009, 08:33 PM   #8
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Original Poster
Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
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.
 
Old 12-19-2009, 10:15 PM   #9
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
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.

Last edited by jschiwal; 12-19-2009 at 10:17 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
setting permissions for a dos/windows drive somae Slackware 5 12-15-2006 05:00 AM
Setting file permissions so Apache can serve my files thomasfingram Linux - Security 6 12-06-2005 06:54 PM
problems with setting permissions for groups of files liontamer13 Linux - Newbie 5 03-10-2005 01:16 AM
Setting permissions to files. lonny Linux - Newbie 1 12-08-2003 08:09 PM
Setting Apache permissions in windows... King Linux - Newbie 0 08-05-2003 08:52 PM


All times are GMT -5. The time now is 05:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration