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) Set write cache permanently?

Featured Replies

Hi all. When I reboot my server all four of my drives come up with disabled write cache. They're the WD RE 2TB ones. Running 

hdparm -W 1 /dev/sd<value>

fixes the problem but only until the next reboot.

 

Do I just set those lines in the go file? Won't the values change across reboots? How do I get them to enable every time I start up the server? Thanks.

derrickserver-diagnostics-20190521-1151.zip

Edited by Guest

16 minutes ago, BRiT said:

Look into User Scripts plugin, create a new one, and set it to start at Array Startup.

What about the changing values for /dev/sda, /dev/sdb...?

  • Community Expert
15 minutes ago, ideaman924 said:

What about the changing values for /dev/sda, /dev/sdb...?

Instead of using the /dev/sdX way to specify the drive you could instead use the /dev/disk/by-id method as that never changes across boots..   Opening a terminal window and doing 

  ls /dev/disk/by-id/

would allow you to see all the id's - you should be able to identify the one you want by the serial number.

On 5/21/2019 at 8:30 PM, itimpi said:

Instead of using the /dev/sdX way to specify the drive you could instead use the /dev/disk/by-id method as that never changes across boots..   Opening a terminal window and doing 

  ls /dev/disk/by-id/

would allow you to see all the id's - you should be able to identify the one you want by the serial number.

Thank you for the tip! Script works like a charm.

For anyone who needs the script here it is:

 

#!/bin/bash

# Drives
declare -a StringArray=("ata-WDC_WD2003FYYS-70W080_WJUN0123456" "DRIVE2" "DRIVE3" "DRIVE4")

# Show status
echo "Current drive status: "
for drive in ${StringArray[@]}; do
    hdparm -W /dev/disk/by-id/$drive
done

# Enable write caching
for drive in ${StringArray[@]}; do
    hdparm -W 1 /dev/disk/by-id/$drive
done

# Show status again
echo "Finished running, check if the write cache was enabled!"
for drive in ${StringArray[@]}; do
    hdparm -W /dev/disk/by-id/$drive
done

Replace the serial codes in the StringArray and you should be good to go! Pop it in User Scripts.

  • 1 month later...
On 5/23/2019 at 1:58 AM, ideaman924 said:

For anyone who needs the script here it is:

 


#!/bin/bash

# Drives
declare -a StringArray=("ata-WDC_WD2003FYYS-70W080_WJUN0123456" "DRIVE2" "DRIVE3" "DRIVE4")

# Show status
echo "Current drive status: "
for drive in ${StringArray[@]}; do
    hdparm -W /dev/disk/by-id/$drive
done

# Enable write caching
for drive in ${StringArray[@]}; do
    hdparm -W 1 /dev/disk/by-id/$drive
done

# Show status again
echo "Finished running, check if the write cache was enabled!"
for drive in ${StringArray[@]}; do
    hdparm -W /dev/disk/by-id/$drive
done

Replace the serial codes in the StringArray and you should be good to go! Pop it in User Scripts.

Thanks

Enabling write cache manually worked but the changes were not persistent through reboots on AMD server.

 

Working perfectly now.

 

  • 1 month later...

Gutted didnt work for me, still showing as disabled when I run it!, crazy thing is, copying between the same drives outside of the array speeds hit max, within...40mb :(:(:(

Ok, googlefu...changed the NCQ of the array drives from 1 to 31 and speed has increased dramatically, doing a clear on 2 drives, gone from 38mb/s to 130mb/s as soon as I made the change, I am a happy camper!, I was about to hit the go button on another HBA controller!

 

Command to change your NCQ level is echo 31 > /sys/block/sdX/device/queue_depth  sdX is your device, echo XX is the level you want to change to

  • 7 months later...
On 5/22/2019 at 7:58 PM, ideaman924 said:

For anyone who needs the script here it is:

 


#!/bin/bash

# Drives
declare -a StringArray=("ata-WDC_WD2003FYYS-70W080_WJUN0123456" "DRIVE2" "DRIVE3" "DRIVE4")

# Show status
echo "Current drive status: "
for drive in ${StringArray[@]}; do
    hdparm -W /dev/disk/by-id/$drive
done

# Enable write caching
for drive in ${StringArray[@]}; do
    hdparm -W 1 /dev/disk/by-id/$drive
done

# Show status again
echo "Finished running, check if the write cache was enabled!"
for drive in ${StringArray[@]}; do
    hdparm -W /dev/disk/by-id/$drive
done

Replace the serial codes in the StringArray and you should be good to go! Pop it in User Scripts.

This still valid?

Hey All,

 

I'm having the same issue as others that i have 8 total drives - 3 Are new drives with write caching enabled, 5 are previously used in a windows adaptec controller environment that wont enable write caching. I've tried numerous hdparm ways and the script that was provided above, but i'm still unable to get it to set to be enabled at all. 

 

Just keeps showing 

setting drive write-caching to 1 (on)

write-caching = 0 (off)


Then i hdparm -W on the drive and shows
write-caching = 0 (off)

 

I've also contacted WD Support as these are WD Red/White drives and they're unable to assist as they only support Windows/MacOS, so not entirely sure as to what to do/try now. Any assistance would be greatly appreciated on this.

22 hours ago, scubieman said:

This still valid?

Yes, I'm still using it on my server and it works perfectly :)

 

19 hours ago, Synthez542 said:

Hey All,

 

I'm having the same issue as others that i have 8 total drives - 3 Are new drives with write caching enabled, 5 are previously used in a windows adaptec controller environment that wont enable write caching. I've tried numerous hdparm ways and the script that was provided above, but i'm still unable to get it to set to be enabled at all. 

 

Just keeps showing 

setting drive write-caching to 1 (on)

write-caching = 0 (off)


Then i hdparm -W on the drive and shows
write-caching = 0 (off)

 

I've also contacted WD Support as these are WD Red/White drives and they're unable to assist as they only support Windows/MacOS, so not entirely sure as to what to do/try now. Any assistance would be greatly appreciated on this.

Maybe the drives do not support write caching under Linux? Wild guess

  • 4 months later...

My settings in user scripts:

 

#!/bin/bash


# Show status
echo "Current drive status: "
    hdparm -W /dev/sd[b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q]

# Enable write caching
    hdparm -W 1 /dev/sd[b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q]

# Show status again
echo "Finished running, check if the write cache was enabled!"
    hdparm -W /dev/sd[b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q]

 

The letter for hdd.

Hdd's :

WD red and white in a netapp disk shelf

Work for me

 

Greets

7 hours ago, Tigerherz said:

My settings in user scripts:

 

#!/bin/bash


# Show status
echo "Current drive status: "
    hdparm -W /dev/sd[b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q]

# Enable write caching
    hdparm -W 1 /dev/sd[b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q]

# Show status again
echo "Finished running, check if the write cache was enabled!"
    hdparm -W /dev/sd[b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q]

 

The letter for hdd.

Hdd's :

WD red and white in a netapp disk shelf

Work for me

 

Greets

I don't recommend this because drive mappings could change across reboots. It's best to use the serial identifier of the drive to set the write cache bit.

@ideaman924

you're right, if you have 2 or 3 or more hdd's which lose the write cache it's better with serial identifer.

In my server all hdd lost write cache at the new start.

i'm not a scripter but

declare -a StringArray=("ata-WDC_WD2003FYYS-70W080_WJUN0123456" "DRIVE2" "DRIVE3" "DRIVE4")

will not work.

I am new in linux. Must ata before each serial id? I've tried it but it doesn't work.

 

Greets from Germany

9 hours ago, Tigerherz said:

...

declare -a StringArray=("ata-WDC_WD2003FYYS-70W080_WJUN0123456" "DRIVE2" "DRIVE3" "DRIVE4")

will not work.

...

Sorry, the identifiers I put here are placeholders because I didn't want to post my drive serial #s. So it would look something like this

declare -a StringArray=("serial#1" "serial#2" "serial#3" "serial#4")

To get your own drive serial #s you run the following command:

On 5/21/2019 at 9:30 PM, itimpi said:

Instead of using the /dev/sdX way to specify the drive you could instead use the /dev/disk/by-id method as that never changes across boots..   Opening a terminal window and doing 

  ls /dev/disk/by-id/

would allow you to see all the id's - you should be able to identify the one you want by the serial number.

This should show you all the drives attached to your server. Find the ones you want to enable the write cache for and them replace them in the line above. Hope this helps.

  • 3 years later...

thanks for the above this got me really close on the drives I had.  (ex data center ULTRASTAR's)

 

But I had to run ""smartctl -s wcache-sct,ata,p /dev/sdX""  first to be able to update the cache setting. The command to enable cache hdparm would always return cache status disabled. 

 

Adding into script was easy. thanks all. 

 

Addition was: 

 

# Smart adjust
for drive in ${StringArray[@]}; do
    smartctl -s wcache-sct,ata,p /dev/disk/by-id/$drive
done

 

 

 

 

......

 

 

Whole script was: 

 

#!/bin/bash

# Drives
declare -a StringArray=("ata-WUH721816ALE6L4_REDACTED" "ata-WUH721816ALE6L4_REDACTED")

# SMART CTL -s
for drive in ${StringArray[@]}; do
    smartctl -s wcache-sct,ata,p /dev/disk/by-id/$drive

# Show status
echo "Current drive status: "
for drive in ${StringArray[@]}; do
    hdparm -W /dev/disk/by-id/$drive
done

# Enable write caching
for drive in ${StringArray[@]}; do
    hdparm -W 1 /dev/disk/by-id/$drive
done

# Show status again
echo "Finished running, check if the write cache was enabled!"
for drive in ${StringArray[@]}; do
    hdparm -W /dev/disk/by-id/$drive
done

 

Make sure to add "ata-" before drive ID

 

Cheers!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

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.