|
queeg
|
 |
« Reply #75 on: May 09, 2010, 10:10:02 AM » |
|
What about -prune option? Would that work to exclude sub dirs?
EDIT: Here's an example that I just figured out. It prints everything except the packages directory. find /boot/config \( -name packages -prune \) -o -name "*" -print
And one that prints everything except subdirs ending in "old" or the packages directory. find /boot \( -name "*old" -prune -o -name packages -prune \) -o -name "*" -print
Cool. I'll try to integrate this into it.
|
|
|
|
« Last Edit: May 09, 2010, 10:46:56 AM by queeg »
|
Logged
|
unRAID 4.5.6 on Asus M4A78L-M, 2GB DDR2800, 3-1.5TB 7200.11, 2GB Lexar Firefly, (Monoprice 3581) eSata Sil3132, (Monoprice 2530) Sata Sil3132
|
|
|
|
Joe L.
|
 |
« Reply #76 on: May 09, 2010, 03:36:35 PM » |
|
Actually, the ability to add arguments is built in with the "-a" option.
An example: cache_dirs -a '-noleaf -name Steam -prune -o -print'
Or, if you have more than one directory to exclude: cache_dirs -a '-noleaf \( -name Steam -prune -o -name data -prune \) -o -print'
Your example would be cache_dirs -a '-noleaf \( -name "*old" -prune -o -name packages -prune \) -o -print'
No need to hack at cache_dirs at all. It was designed to be flexible. When using the -a option you need to use the -noleaf at the beginning of the -a option argument, and -print at the end to get correct syntax. The entire -a option argument is enclosed in single quotes as in -a '-noleaf ....... -print' Individual shell wild-cards "*" can be enclosed in double quotes as in the "*old" example above.
Not too difficult...
Joe L.
|
|
|
|
|
Logged
|
|
|
|
|
queeg
|
 |
« Reply #77 on: May 09, 2010, 04:47:31 PM » |
|
Actually, the ability to add arguments is built in with the "-a" option.
An example: cache_dirs -a '-noleaf -name Steam -prune -o -print'
Or, if you have more than one directory to exclude: cache_dirs -a '-noleaf \( -name Steam -prune -o -name data -prune \) -o -print'
Your example would be cache_dirs -a '-noleaf \( -name "*old" -prune -o -name packages -prune \) -o -print'
No need to hack at cache_dirs at all. It was designed to be flexible. When using the -a option you need to use the -noleaf at the beginning of the -a option argument, and -print at the end to get correct syntax. The entire -a option argument is enclosed in single quotes as in -a '-noleaf ....... -print' Individual shell wild-cards "*" can be enclosed in double quotes as in the "*old" example above.
Not too difficult...
Joe L.
That sounds easier. I had added a new -x parameter but trying to put it into all the find's get me tangled up. This is what I'm going to use. /boot/cache_dirs -w -u -d 3 -a '-noleaf \( -name "ftproot" -prune -o -name "lost+found" -prune -o -name "iTunes" -prune \) -o -print'
|
|
|
|
|
Logged
|
unRAID 4.5.6 on Asus M4A78L-M, 2GB DDR2800, 3-1.5TB 7200.11, 2GB Lexar Firefly, (Monoprice 3581) eSata Sil3132, (Monoprice 2530) Sata Sil3132
|
|
|
|
queeg
|
 |
« Reply #78 on: May 10, 2010, 10:30:51 AM » |
|
It doesn't seem to be working. The drive spins up going down the first directory leve.
/boot/cache_dirs -w -u -d 3 -a '-noleaf \( -name "ftproot" -prune -o -name "lost+found" -prune -o -name "iTunes" -prune \) -o -print'
|
|
|
|
|
Logged
|
unRAID 4.5.6 on Asus M4A78L-M, 2GB DDR2800, 3-1.5TB 7200.11, 2GB Lexar Firefly, (Monoprice 3581) eSata Sil3132, (Monoprice 2530) Sata Sil3132
|
|
|
|
BRiT
|
 |
« Reply #79 on: May 10, 2010, 10:42:41 AM » |
|
The first time the script runs, the drive has to be spun up to get the directory listings.
If you mean the drive spuns up after the script is running and the drive has idled out to sping down, how are you browsing the files? If you're using Windows Explorer, make sure it's not trying to read the content of the files to display thumbnails.
|
|
|
|
|
Logged
|
|
|
|
|
queeg
|
 |
« Reply #80 on: May 10, 2010, 10:48:58 AM » |
|
What I meant to say was I spun up the drives, ran the cache_dirs command, allowed the drives to spin down (actually just came back 7 hours later) and from windows I explored the directories while also watching the drives on the unRAID menu. After browsing down past the first directory the drive spun up. So I don't think cache_dirs with those parameters is working.
|
|
|
|
|
Logged
|
unRAID 4.5.6 on Asus M4A78L-M, 2GB DDR2800, 3-1.5TB 7200.11, 2GB Lexar Firefly, (Monoprice 3581) eSata Sil3132, (Monoprice 2530) Sata Sil3132
|
|
|
|
Joe L.
|
 |
« Reply #81 on: May 10, 2010, 11:04:11 AM » |
|
What I meant to say was I spun up the drives, ran the cache_dirs command, allowed the drives to spin down (actually just came back 7 hours later) and from windows I explored the directories while also watching the drives on the unRAID menu. After browsing down past the first directory the drive spun up. So I don't think cache_dirs with those parameters is working.
As already said, it depends on what you are browsing... If you have thumbnail views enabled, windows is looking at file contents, not just directory listings.
|
|
|
|
|
Logged
|
|
|
|
|
queeg
|
 |
« Reply #82 on: May 10, 2010, 11:13:13 AM » |
|
The (Win7) explorer is set to Titles which is the default I think.
Edit: Tiles (not Titles)
|
|
|
|
« Last Edit: May 10, 2010, 11:24:14 AM by queeg »
|
Logged
|
unRAID 4.5.6 on Asus M4A78L-M, 2GB DDR2800, 3-1.5TB 7200.11, 2GB Lexar Firefly, (Monoprice 3581) eSata Sil3132, (Monoprice 2530) Sata Sil3132
|
|
|
|
Joe L.
|
 |
« Reply #83 on: May 10, 2010, 11:36:45 AM » |
|
The (Win7) explorer is set to Titles which is the default I think.
Edit: Tiles (not Titles)
Yes, "tiles" will show you small images of jpg files, and images of documents. It will be examining file content, not just directory data. cache_dirs is not opening every file to read them... Solution, change the view you are using to a file listing mode. Joe L.
|
|
|
|
|
Logged
|
|
|
|
|
queeg
|
 |
« Reply #84 on: May 10, 2010, 11:43:31 AM » |
|
A little testing and here is what I see. It seems that even though explorer defaults to Tile it actually does request file info unless you manually set it to Tile.
Open explorer browse top level folder: works browse any subdir: spins up drive.
Open explorer Change view from Tiles to List browse top level folder: works browse any subdir: works change view from List back to Tiles browse other subdirs: continues to work.
In any case, cache_dirs is working correctly with the added -a parameter so I'm happy and thanks Joe.
|
|
|
|
« Last Edit: May 10, 2010, 11:46:24 AM by queeg »
|
Logged
|
unRAID 4.5.6 on Asus M4A78L-M, 2GB DDR2800, 3-1.5TB 7200.11, 2GB Lexar Firefly, (Monoprice 3581) eSata Sil3132, (Monoprice 2530) Sata Sil3132
|
|
|
|
Joe L.
|
 |
« Reply #85 on: May 10, 2010, 11:57:52 AM » |
|
A little testing and here is what I see. It seems that even though explorer defaults to Tile it actually does request file info unless you manually set it to Tile.
Open explorer browse top level folder: works browse any subdir: spins up drive.
Open explorer Change view from Tiles to List browse top level folder: works browse any subdir: works change view from List back to Tiles browse other subdirs: continues to work.
In any case, cache_dirs is working correctly with the added -a parameter so I'm happy and thanks Joe.
Don't be fooled by your test. Once a "file" is read, it is in the cache until it is replaced by something else needing the cache. To perform your test properly, you'll need to empty the cache between tests. To do that, type this in between each test: sync; echo 3 > /proc/sys/vm/drop_caches
|
|
|
|
|
Logged
|
|
|
|
paperclip
Newbie

Posts: 35
|
 |
« Reply #86 on: May 29, 2010, 06:08:20 PM » |
|
Joe L., thanks for your great script.
I do have a questions about the -d (max depth) parameter. Does the numbering start at 0 or 1?
So if I had a "Music" share with the following structure: Music/The Eagles/Hotel California/Track01.mp3
What would be the appropriate max depth value?
Does it even matter? I mean, if my folder structure didn't have a max depth exceeding 3, but I set cache_dirs to look 5 folders deep, would there be a performance hit?
Thanks.
|
|
|
|
|
Logged
|
|
|
|
|
Joe L.
|
 |
« Reply #87 on: May 29, 2010, 06:53:14 PM » |
|
Joe L., thanks for your great script.
I do have a questions about the -d (max depth) parameter. Does the numbering start at 0 or 1?
So if I had a "Music" share with the following structure: Music/The Eagles/Hotel California/Track01.mp3
What would be the appropriate max depth value?
The argument is passed to the "find" command. Its manual page says -maxdepth levels Descend at most levels (a non-negative integer) levels of direc- tories below the command line arguments. `-maxdepth 0' means only apply the tests and actions to the command line arguments.
You can experiment by changing the number and testing with this sample "find" command and see what it prints: find /mnt/disk*/Music -maxdepth 1The depth is relative to the starting path, so a maxdepth of 0 would only cache the /mnt/disk*/Music folders and nothing in them or below them. To cache the hierarchy you described you would need at least a depth of 3. Does it even matter? I mean, if my folder structure didn't have a max depth exceeding 3, but I set cache_dirs to look 5 folders deep, would there be a performance hit?
Thanks.
Since you have no really deep hierarchies, there is no reason to specify any -d option. There is no penalty of using 5, or using the default of 999. Edit: fixed directory name in example
|
|
|
|
« Last Edit: May 30, 2010, 03:36:06 AM by Joe L. »
|
Logged
|
|
|
|
paperclip
Newbie

Posts: 35
|
 |
« Reply #88 on: May 29, 2010, 07:14:55 PM » |
|
You can experiment by changing the number and testing with this sample "find" command and see what it prints: find /mnt/disk*/Mp3 -maxdepth 1
The depth is relative to the starting path, so a maxdepth of 0 would only cache the /mnt/disk*/Music folders and nothing in them or below them. To cache the hierarchy you described you would need at least a depth of 3.
Since you have no really deep hierarchies, there is no reason to specify any -d option. There is no penalty of using the default of 999. Joe L., thanks for this information.
|
|
|
|
|
Logged
|
|
|
|
|
starcat
|
 |
« Reply #89 on: June 02, 2010, 06:30:38 AM » |
|
Now, if your "browsing" of the directory is writing to them (MAC OS writes ._DS files) or opening files to show thumbnail views (windows will do this) then yes, the disks will spin up, since the file contents are not cached.
Writing of .DS_Store files on network shares can be prevented by running these: defaults write /Library/Preferences/com.apple.desktopservices DSDontWriteNetworkStores true defaults write com.apple.desktopservices DSDontWriteNetworkStores true
see this for details: http://www.macosxhints.com/article.php?story=20051130083652119
|
|
|
|
« Last Edit: June 06, 2010, 01:55:20 PM by starcat »
|
Logged
|
|
|
|
|