How to Disable or Enable Disk Write Caching in Linux

ATA-Based Disks

  1. Check out whether disk caching is enabled on your disk or not:
  1. To disable write caching, you need to edit hdparm.conf using your favorite editor (e.g. gedit, vi).
  1. After making the changes, restart the server/computer and check out the write caching status again to make sure it’s disabled.
    If in case hdparm.conf does not exist in /etc folder, an alternative approach is to use the command below.
  1. To know more about “hdparm”, invoke the manual by typing the following command.

SCSI-Based Disks

  1. Check out whether disk caching is enabled on your disk or not:
  1. Sending an SCSI inquiry command using “sdparm”.
  1. Getting all the parameters for the Caching Mode Page. Refer to the details of this mode page from the SCSI Interface Specification.
  1. Setting write caching or disk caching to enable by running below command.
  1. To get the WCE current value:
  1. To set the WCE current value (WCE=1)
  1. To set the WCE current and saved values (WCE=1)
  1. To clear (disable) the WCE current value (WCE=0)
  1. To clear (disable) the WCE current and saved values (WCE=0)
  1. To know more about “sdparm”, invoke the manual by typing the following command.