Write cache not reboot persistent


Recommended Posts

I recently swapped out old Marvell 88SE9215 SATA controllers and replaced with Supermicro AOC-S3008L-L8E SAS3 (based on Broadcom/LSI SAS 9300-8i / SAS 3008). 

 

I'm seeing much better IO performance overall with the new controller and everything is working, but I have noticed one change in behavior since swapping. I can't seem to get the write cache setting to persist reboots on disks connected to the new controller. I use the hdparm command to make the change successfully, but after a reboot it just goes back to being disabled. 

 

Dec 10 20:16:10 darktower root: Fix Common Problems: Warning: Write Cache is disabled on disk1
Dec 10 20:16:10 darktower root: Fix Common Problems: Warning: Write Cache is disabled on disk2
Dec 10 20:16:10 darktower root: Fix Common Problems: Warning: Write Cache is disabled on disk3
Dec 10 20:16:10 darktower root: Fix Common Problems: Warning: Write Cache is disabled on disk4
Dec 10 20:16:10 darktower root: Fix Common Problems: Warning: Write Cache is disabled on disk5
Dec 10 20:16:10 darktower root: Fix Common Problems: Warning: Write Cache is disabled on cache2

 

Should I add the hdparm commands as a startup script? Seems a bit hacky... 

Do I need to upgrade my controller firmware? I haven't bothered since everything has been working fine. 

 

root@darktower:~# hdparm -W 1 /dev/sdb
/dev/sdb:
 setting drive write-caching to 1 (on)
 write-caching =  1 (on)

 

Thanks! 

Edited by ceddybu
Link to comment
  • 2 months later...

I'm having this exact same issue. but for me (and assume everyone) the device allocation is always changing. Sometime the drive is sdc and then on the next reboot it's sdm.

 

Is there a way to check if the drive has it disabled before enabling it?

 

I only have this issue on mechanical drives, the ssd/nvme's don't have the issue.

 

I just don't want to have the script blindly running for devices that don't exist or on ssd/nvme's

 

Vin

Link to comment
  • 1 year later...
On 2/13/2022 at 12:18 AM, Vinster411 said:

I'm having this exact same issue. but for me (and assume everyone) the device allocation is always changing. Sometime the drive is sdc and then on the next reboot it's sdm.

 

Is there a way to check if the drive has it disabled before enabling it?

 

I only have this issue on mechanical drives, the ssd/nvme's don't have the issue.

 

I just don't want to have the script blindly running for devices that don't exist or on ssd/nvme's

 

Vin


I also had same challenge. Solved it for me, but...

!!! USE AT YOUR OWN RISK !!!

It will check all disks in your system ignoring any USB disk which may happen to be your OS, enabling write-cache. Add to start up scripts as others have mentioned.

 

#!/bin/bash

# The list of devices to check and enable write cache on
devices="/dev/sd[a-z]"

for device in $devices
do
    echo "Checking device $device"
    
    if [ -e $device ]; then
        is_removable=$(lsblk -d -no RM $device)

        if [ $is_removable -eq 1 ]; then
            echo "This is a USB device, possibly the UNRAID OS disk. It is not recommended to enable write cache."
            continue
        fi

        write_cache_status=$(hdparm -W $device | tr '\n' ' ' | awk -F'[()]' '{print $2}')
        echo "Write cache status: $write_cache_status"

        if [ "$write_cache_status" == "off" ]; then
            echo -n "Enabling write cache on $device... "
            hdparm -W1 $device
            if [ $? -ne 0 ]; then
                echo "Failed"
            else
                echo "Done"
            fi
        else
            echo "Write cache already enabled on $device"
        fi
    else
        echo "Device $device does not exist"
    fi
    echo "" # Add an empty line for formatting
done


No responsibility taken for lost data, crashed system etc.

Output if ran manually

Checking device /dev/sda
This is a USB device, possibly the UNRAID OS disk. It is not recommended to enable write cache.
Checking device /dev/sdb
Write cache status: on
Write cache already enabled on /dev/sdb

Checking device /dev/sdc
Write cache status: on
Write cache already enabled on /dev/sdc

Checking device /dev/sdd
Write cache status: on
Write cache already enabled on /dev/sdd

Checking device /dev/sde
Write cache status: on
Write cache already enabled on /dev/sde

 

Edited by brucejobs
output display added
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.