TEXT   50
Disabling the write back cache
Guest on 25th May 2023 01:08:30 AM


  1. Disabling the write back cache.
  2.  
  3.  
  4. For SATA/PATA(IDE):
  5. (although for SATA this only works on a recent kernel with ATA command passthrough):
  6.  
  7. # hdparm -W0 /dev/sda
  8. # hdparm -W0 /dev/hda
  9. # blktool /dev/sda wcache off
  10. # blktool /dev/hda wcache off
  11.  
  12. For SCSI:
  13. Using sginfo(8) which is a little tedious
  14. It takes 3 steps. For example:
  15.  
  16. #sginfo -c /dev/sda
  17.  which gives a list of attribute names and values
  18.  
  19. #sginfo -cX /dev/sda
  20.  which gives an array of cache values which you must match up with from step 1, e.g.
  21.  0 0 0 1 0 1 0 0 0 0 65535 0 65535 65535 1 0 0 0 3 0 0
  22.  
  23. #sginfo -cXR /dev/sda 0 0 0 1 0 0 0 0 0 0 65535 0 65535 65535 1 0 0 0 3 0 0
  24.  allows you to reset the value of the cache attributes.
  25.  
  26.  
  27. This disabling is kept persistent for a SCSI disk. However, for a SATA/PATA
  28. disk this needs to be done after every reset as it will reset back to the
  29. default of the write cache enabled. And a reset can happen after reboot or on
  30. error recovery of the drive. This makes it rather difficult to guarantee that
  31. the write cache is maintained as disabled.

Raw Paste

Login or Register to edit or fork this paste. It's free.