Data loss through permissions change?

Posted by charliehorse55 on Server Fault See other posts from Server Fault or by charliehorse55
Published on 2012-07-09T04:31:04Z Indexed on 2012/07/10 3:17 UTC
Read the original article Hit count: 530

I seem to have deleted some files on my media drive, simply by changing the permissions.

The Story

I have many operating systems installed on my computer, and constantly switch between them. I bought a 1TB HD and formatted it as HFS+ (not journaled). It worked well between OSX and all of my linux installations while having much better metadata support than NTFS. I never synced the UIDs for my operating systems so the permissions were always doing funny things. Yesterday I tried to fix the permissions by first changing the UIDs of the other operating systems to match OSX, and then changing the file ownership of all files on the drive to match OSX. About 50% of the files on the drive were originally owned by OSX, the other half were owned by the various linux installations. I started to try and change the file permissions for the folders, and that's when it went south.

The Commands

These commands were run recursively on the one section of the drive.

sudo chflags nouchg
sudo chflags -N
sudo chown myusername
sudo chmod 666
sudo chgrp staff

The Bad

Sometime during the execution of these commands, all of the files belonging to OSX were deleted. If a folder had linux based files it would remain intact but any folder containing exclusively OSX files was erased. If a folder containing linux files also contained a subfolder with only OSX files, the sub folder would remain but is inaccesible and displays a file size of 0 bytes.

Luckily these commands were only run on the videos folder, I also have a music folder with the same issue but I did not execute any of these commands on it. Effectively I have examples of the file permissions for all 3 states - the linux files before and after, and the OSX files before.

OSX File Before

-rw-r--r--@ 1 charliehorse  1000  3634241 15 Nov  2008 /path/to/file
    com.apple.FinderInfo         32 

Linux File before:

-rw-r--r--@ 1 charliehorse  1000  5321776 20 Sep  2002 /path/to/file/
    com.apple.FinderInfo         32 

Linux File After (Read only): (Different file, but I believe the same permissions originally)

-rw-rw-rw-@ 1 charliehorse staff  366982610 17 Jun  2008 /path/to/file
    com.apple.FinderInfo           32 

These files still exist so if there are any other commands to run on them to determine what has happened here, I can do that.

EDIT

Running ls on one of the "empty" deleted OSX folders yields this:

ls: .: Permission denied
ls: ..: Permission denied
ls: subdirA: Permission denied
ls: subdirB: Permission denied
ls: subdirC: Permission denied
ls: subdirD: Permission denied

I believe my files might still be there, but the permissions are screwed.

© Server Fault or respective owner

Related posts about macosx

Related posts about unix