how to give local user on windows machine "full control" to CIFS share?

Status
Not open for further replies.

vibe666

Dabbler
Joined
Oct 28, 2011
Messages
10
I have a windows share at /mnt/data which contains everything (about 5tb of data) from my old (Thecus) NAS.

my problem is, that when i copied everything over, although the files all came over with their timestamps intact, all the folders were given a last modified timestamp of the time they were created on the freeNAS share.

the problem is, that I have a critical folder within the share which has about 1700 subfolders (all at the same level) sorted by "last modified" which is now completely messed up.

I've actually found the solution in the form of a powershell script which will change the last modified timestamp on each folder to the last modified timestamp of the newest file in the folder, which would be perfect, freeNAS won't give my local user account sufficient access to change the folder properties as for some reason and during the copy (or possibly afterwards) they have all (only the folder, not the files) been set as read only and i can' change them so i get "access denied" whenever i try and run the powershell script to fix the issue. :(

i'll put my hands up right now and confess that i don't have much of a clue about how the permissions work in freenas, but i have created a user account for myself called "chris" and i have added that account to the "wheel" group (as i saw the root account was in the same group) and added chris as the user owner and the wheel group as the group owner of the /mnt/data share and that gave me the permissions i needed to copy all the files from NAS to NAS initially, so i thought it was okay until i ran into this problem. :(

i'm not overly concerned about restricting access rights as the NAS is on a home network and it doesn't have any kind of remote access set up, so my main concern is giving my account sufficient access to change the folder timestamps with this powershell script, so if anyone can give me any help at all in doing that, i would be very grateful. :)

P.S. sorry for babbling, i do that a lot. :o
 

ProtoSD

MVP
Joined
Jul 1, 2011
Messages
3,348
Hi Chris,

There are a couple of things you can do from the command prompt at the console. If you cd to the top level folder of where you want to change permission you can do these three things, change the ownership of all the files to 'chris' and make all the folders & files RW so your script doesn't fail.

chown -R chris * (Changes the owner of everything in & below current folder to 'chris')

find . -type f -exec chmod 660 {} \; (Sets all the files read-write for owner and group)

find . -type d -exec chmod 770 {} \; (Sets all the folders read-write for owner and group)


Hope that gets you back on track!
 

vibe666

Dabbler
Joined
Oct 28, 2011
Messages
10
thanks for the help, fingers crossed this should have me sorted.

i'm running the chown command now, but i'm guessing each command is going to take a while on >5tb of data? :)
 

vibe666

Dabbler
Joined
Oct 28, 2011
Messages
10
wow, all done and it didn't take forever to complete which is good. :)

if anyone else is having similar problems (when i was investigating the issue, it seems like robocopy, richcopy and allway sync all do this by default), the powershell script i used to fix the folder modified timestamps is the following:

Code:
 Get-ChildItem $root | Where-Object {$_.PSIsContainer} | Foreach-Object{

# get the oldest file for the current directory object
$oldest = Get-ChildItem $_.FullName | Sort-Object -Descending LastWriteTime | Select-Object LastWriteTime -Last 1

if($oldest)
{
# oldest object found, set current directory LastWriteTime
$_ | Set-ItemProperty -Name LastWriteTime -Value $oldest.LastWriteTime
}
else
{
# current directory is empty, directory LastWriteTime is left unchanged
Write-Warning "Directory '$($_.FullName)' is empty, skiping..."
}
}


it's not 100% perfect as it only works on the level below the folder you run it, not subfolders and requires that there is at least one file inside each folder to work off so any folders with only subfolders in them without a file in the root folder will be ignored.

its fine aside from that though and fixed almost all of the 1700+ folders i ran it on in about 10 minutes, thanks to protosd's help, so thanks again. :)

i should also probably mention that i have no prior powershell experience, i just found some info on the issue online and that was a suggested solution, so i just did a little more googling and 5 minutes reading the basics of powershell and that was all it took, once i had the permissions fixed. :)
 

Visseroth

Guru
Joined
Nov 4, 2011
Messages
546
youtube linux permissions. There is lots of good information and will teach you how to use chmod, chgrp, chown and ls -l
 
Status
Not open for further replies.
Top