Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[SOLVED] spinup_when_accessed.sh not working with rc12a

Featured Replies

Hello All -

 

I was using Joe L.'s spinup_when_accessed script in conjunction with cache_dirs in v4.7 and it worked flawlessly.  Recently, I upgraded to rc12a and the script no longer works as expected.  It spins up all disks no matter what share is accessed even if the user share exists on one disk.  For example, my Backups share is only on disk12 and is not excluded in cache_dirs.

 

root@Tower:/# find /mnt/ -name "Backups" -type d
/mnt/user/Backups
/mnt/user0/Backups
/mnt/disk12/Backups

 

 

To test, I spin down all disks, and then try to access the share by going to\\tower\Backups\.  The results of inotify are:

 

 

inotifywait -mr /mnt/user
Setting up watches.  Beware: since -r was given, this may take a while!
Watches established.
/mnt/user/ OPEN,ISDIR Backups
/mnt/user/ OPEN,ISDIR Backups
/mnt/user/ OPEN,ISDIR Backups
/mnt/user/ CLOSE_NOWRITE,CLOSE,ISDIR Backups
/mnt/user/ OPEN,ISDIR Backups
/mnt/user/ CLOSE_NOWRITE,CLOSE,ISDIR Backups
/mnt/user/ OPEN,ISDIR Backups
/mnt/user/ CLOSE_NOWRITE,CLOSE,ISDIR Backups

 

 

and all disks are spun up as the log shows:

 

 

May 29 14:11:21 Tower emhttp: Spinning down all drives...
May 29 14:11:21 Tower kernel: mdcmd (183): spindown 0
May 29 14:11:22 Tower kernel: mdcmd (184): spindown 1
May 29 14:11:22 Tower kernel: mdcmd (185): spindown 2
May 29 14:11:22 Tower kernel: mdcmd (186): spindown 3
May 29 14:11:22 Tower kernel: mdcmd (187): spindown 4
May 29 14:11:22 Tower kernel: mdcmd (188): spindown 5
May 29 14:11:22 Tower kernel: mdcmd (189): spindown 6
May 29 14:11:22 Tower kernel: mdcmd (190): spindown 7
May 29 14:11:22 Tower kernel: mdcmd (191): spindown 8
May 29 14:11:22 Tower kernel: mdcmd (192): spindown 9
May 29 14:11:23 Tower kernel: mdcmd (193): spindown 10
May 29 14:11:23 Tower kernel: mdcmd (194): spindown 11
May 29 14:11:24 Tower kernel: mdcmd (195): spindown 12
May 29 14:11:24 Tower emhttp: shcmd (798): /usr/sbin/hdparm -y /dev/sde &> /dev/null
May 29 14:11:40 Tower spin_disks: =================================================================
May 29 14:11:40 Tower spin_disks: Wed May 29 14:11:40 PDT 2013
May 29 14:11:40 Tower spin_disks: Spin up disks  1 2 3 4 5 6 7 8 9 10 11 12 on shares for files/directories:
May 29 14:11:40 Tower spin_disks: COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF           NODE NAME
May 29 14:11:40 Tower spin_disks: smbd    30727 nobody   26r   DIR   0,13      536 17592186071455 /mnt/user/Backups
May 29 14:11:40 Tower spin_disks: smbd    30727 nobody   31r   DIR   0,13      536 17592186071455 /mnt/user/Backups
May 29 14:11:40 Tower spin_disks: disk  1 not currently spinning
May 29 14:11:40 Tower kernel: mdcmd (196): spinup 1
May 29 14:11:40 Tower kernel: 
May 29 14:11:40 Tower spin_disks: disk  2 not currently spinning
May 29 14:11:40 Tower kernel: mdcmd (197): spinup 2
May 29 14:11:40 Tower kernel: 
May 29 14:11:40 Tower spin_disks: disk  3 not currently spinning
May 29 14:11:40 Tower kernel: mdcmd (198): spinup 3
May 29 14:11:40 Tower kernel: 
May 29 14:11:40 Tower spin_disks: disk  4 not currently spinning
May 29 14:11:40 Tower kernel: mdcmd (199): spinup 4
May 29 14:11:40 Tower kernel: 
May 29 14:11:40 Tower spin_disks: disk  5 not currently spinning
May 29 14:11:40 Tower kernel: mdcmd (200): spinup 5
May 29 14:11:40 Tower kernel: 
May 29 14:11:40 Tower spin_disks: disk  6 not currently spinning
May 29 14:11:40 Tower kernel: mdcmd (201): spinup 6
May 29 14:11:40 Tower kernel: 
May 29 14:11:40 Tower spin_disks: disk  7 not currently spinning
May 29 14:11:40 Tower kernel: mdcmd (202): spinup 7
May 29 14:11:40 Tower kernel: 
May 29 14:11:40 Tower spin_disks: disk  8 not currently spinning
May 29 14:11:40 Tower kernel: mdcmd (203): spinup 8
May 29 14:11:40 Tower kernel: 
May 29 14:11:40 Tower spin_disks: disk  9 not currently spinning
May 29 14:11:40 Tower kernel: mdcmd (204): spinup 9
May 29 14:11:40 Tower kernel: 
May 29 14:11:40 Tower spin_disks: disk 10 not currently spinning
May 29 14:11:40 Tower kernel: mdcmd (205): spinup 10
May 29 14:11:40 Tower kernel: 
May 29 14:11:40 Tower spin_disks: disk 11 not currently spinning
May 29 14:11:40 Tower kernel: mdcmd (206): spinup 11
May 29 14:11:40 Tower kernel: 
May 29 14:11:40 Tower spin_disks: disk 12 not currently spinning
May 29 14:11:40 Tower kernel: mdcmd (207): spinup 12
May 29 14:11:40 Tower kernel: 
May 29 14:11:42 Tower spin_disks: disk(s)   1  2  3  4  5  6  7  8  9 10 11 12 spun up
May 29 14:11:42 Tower spin_disks: =================================================================
May 29 14:11:42 Tower spin_disks: 
May 29 14:11:54 Tower spin_disks: =================================================================
May 29 14:11:54 Tower spin_disks: Wed May 29 14:11:54 PDT 2013
May 29 14:11:54 Tower spin_disks: Spin up disks  12 on shares for files/directories:
May 29 14:11:54 Tower spin_disks: COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF           NODE NAME
May 29 14:11:54 Tower spin_disks: smbd    30727 root   26r   DIR   0,13      536 17592186071455 /mnt/user/Backups
May 29 14:11:54 Tower spin_disks: smbd    30727 root   31r   DIR   0,13      536 17592186071455 /mnt/user/Backups
May 29 14:11:54 Tower spin_disks: disk 12 = 14 seconds since last I/O
May 29 14:11:56 Tower spin_disks: disk(s)  12 currently spinning
May 29 14:11:56 Tower spin_disks: =================================================================
May 29 14:11:56 Tower spin_disks: 
May 29 14:20:48 Tower spin_disks: =================================================================
May 29 14:20:48 Tower spin_disks: Wed May 29 14:20:48 PDT 2013
May 29 14:20:48 Tower spin_disks: Spin up disks  1 2 3 4 5 6 7 8 9 10 11 12 on shares for files/directories:
May 29 14:20:48 Tower spin_disks: COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF           NODE NAME
May 29 14:20:48 Tower spin_disks: smbd    30727 nobody  cwd    DIR   0,13      536 17592186071455 /mnt/user/Backups
May 29 14:20:48 Tower spin_disks: smbd    30727 nobody   26r   DIR   0,13      536 17592186071455 /mnt/user/Backups
May 29 14:20:48 Tower spin_disks: smbd    30727 nobody   31r   DIR   0,13      536 17592186071455 /mnt/user/Backups
May 29 14:20:48 Tower spin_disks: disk  1 = 9 minutes, 8 seconds since last I/O
May 29 14:20:48 Tower spin_disks: disk  2 = 9 minutes, 8 seconds since last I/O
May 29 14:20:48 Tower spin_disks: disk  3 = 9 minutes, 8 seconds since last I/O
May 29 14:20:48 Tower spin_disks: disk  4 = 9 minutes, 8 seconds since last I/O
May 29 14:20:48 Tower spin_disks: disk  5 = 9 minutes, 8 seconds since last I/O
May 29 14:20:48 Tower spin_disks: disk  6 = 9 minutes, 8 seconds since last I/O
May 29 14:20:48 Tower spin_disks: disk  7 = 9 minutes, 8 seconds since last I/O
May 29 14:20:48 Tower spin_disks: disk  8 = 9 minutes, 8 seconds since last I/O
May 29 14:20:48 Tower spin_disks: disk  9 = 9 minutes, 8 seconds since last I/O
May 29 14:20:48 Tower spin_disks: disk 10 = 9 minutes, 8 seconds since last I/O
May 29 14:20:48 Tower spin_disks: disk 11 = 9 minutes, 8 seconds since last I/O
May 29 14:20:48 Tower spin_disks: disk 12 = 9 minutes, 8 seconds since last I/O
May 29 14:20:50 Tower spin_disks: disk(s)   1  2  3  4  5  6  7  8  9 10 11 12 currently spinning
May 29 14:20:50 Tower spin_disks: =================================================================
May 29 14:20:50 Tower spin_disks: 

 

 

Thanks in advance.

 

 

What do you see when you type:

ls  -ld  /mnt/disk*/Backups

  • Author

What do you see when you type:

ls  -ld  /mnt/disk*/Backups

 

drwxrwxrwx 11 nobody users 536 2013-05-06 03:42 /mnt/disk12/Backups/

What do you see when you type:

ls  -ld  /mnt/disk*/Backups

 

drwxrwxrwx 11 nobody users 536 2013-05-06 03:42 /mnt/disk12/Backups/

That is exactly as expected...

I'm trying to identify what the difference might be.  (you are correct though, it is not working properly on your server)

Now, one more command to try for me, while the file is being accessed:

lsof /mnt/user 2>/dev/null | grep -v "PID USER"

  • Author

That is exactly as expected...

I'm trying to identify what the difference might be.  (you are correct though, it is not working properly on your server)

Now, one more command to try for me, while the file is being accessed:

lsof /mnt/user 2>/dev/null | grep -v "PID USER"

 

root@Tower:~# lsof /mnt/user 2>/dev/null | grep -v "PID USER" | more
COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF           NODE NAME
smbd     5139 nobody  cwd    DIR   0,13      536 17592186071455 /mnt/user/Backups
smbd     5139 nobody   26r   DIR   0,13      536 17592186071455 /mnt/user/Backups
smbd     5139 nobody   32r   DIR   0,13      536 17592186071455 /mnt/user/Backups
smbd     5139 nobody   34r   REG   0,13 74695784 17592186046319 /mnt/user/Backups/irefield100.ts

That is exactly as expected...

I'm trying to identify what the difference might be.  (you are correct though, it is not working properly on your server)

Now, one more command to try for me, while the file is being accessed:

lsof /mnt/user 2>/dev/null | grep -v "PID USER"

 

root@Tower:~# lsof /mnt/user 2>/dev/null | grep -v "PID USER" | more
COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF           NODE NAME
smbd     5139 nobody  cwd    DIR   0,13      536 17592186071455 /mnt/user/Backups
smbd     5139 nobody   26r   DIR   0,13      536 17592186071455 /mnt/user/Backups
smbd     5139 nobody   32r   DIR   0,13      536 17592186071455 /mnt/user/Backups
smbd     5139 nobody   34r   REG   0,13 74695784 17592186046319 /mnt/user/Backups/irefield100.ts

Thank you.  I think I see the issue.

 

Around line 307 is this:

    # Get the list of logical disks affiliated with the user-share being accessed

    lsof /mnt/user 2>/dev/null | grep -v "PID USER" | while read a b c d e f g h i

 

I changed it to this:

    # Get the list of logical disks affiliated with the user-share being accessed

    lsof /mnt/user 2>/dev/null | grep "/mnt" | while read a b c d e f g h i

 

The idea was to get rid of the column headings.  Originally, with "root" as the only user, the pattern matched as PID and USER were separated by one space.  With the user "nobody" the two column headings have several spaces between them, so the "grep -v" did not exclude the heading.

Instead, now I just look for the lines with /mnt.  (same end effect, but does not depend on spacing in header between PID and USER)

 

An updated version of the script is attached.  See if it works for you.

 

Joe L.

spinup_when_accessed.zip

  • Author

Thanks Joe for the diligent troubleshooting!  I will give it a shot tomorrow after the parity check completes (running a second) and report back.

Thanks Joe for the diligent troubleshooting!

I should thank you for providing the clues I needed to figure out what was happening.
I will give it a shot tomorrow after the parity check completes (running a second) and report back.

I'll look forward to the report.
  • Author

Awesome.  All works as expected now the latest script!  Thanks again!  :D

So is the updated script valid for all versions of unraid from 4.7 and up? I think so, but want confirmation from Joe.

So is the updated script valid for all versions of unraid from 4.7 and up? I think so, but want confirmation from Joe.

yes, it will work for any version of unRAID from 4.5-final onward. 

(The rdevLastIO parameter it needs and the spinup commands were added to unRAID in the 4.5-final version)

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.