(SOLVED) Set write cache permanently?


Guest

Recommended Posts

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
Link to comment
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...?

Link to comment
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.

  • Like 1
Link to comment
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.

Link to comment

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.

Link to comment
  • 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.

 

Link to comment
  • 1 month later...

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

Link to comment
  • 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?

Link to comment

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.

Link to comment
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

Link to comment
  • 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

Link to comment
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.

Link to comment

@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

Link to comment
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.

Link to comment

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.