{"id":2896,"date":"2014-01-23T06:23:38","date_gmt":"2014-01-23T06:23:38","guid":{"rendered":"http:\/\/ubuntuhandbook.org\/?p=2896"},"modified":"2014-01-23T06:23:38","modified_gmt":"2014-01-23T06:23:38","slug":"disable-disk-caching-prevent-data-loss","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2014\/01\/disable-disk-caching-prevent-data-loss\/","title":{"rendered":"How to Disable Disk Write Caching in Ubuntu To Prevent Data Loss"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2014\/01\/prevent-data-loss.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2014\/01\/prevent-data-loss.jpg\" alt=\"Ubuntu Prevent Data Loss\" width=\"250\" height=\"225\" class=\"aligncenter size-full wp-image-2897\" \/><\/a><br \/>\n&nbsp;<br \/>\nThis simple tutorial is going to show you how to <b>disable disk write caching<\/b> in Ubuntu to <b>prevent data loss<\/b> when you may experience <b>power failure<\/b>.<\/p>\n<p>Enable write caching improves disk performance, but a power outage or equipment failure might result in data loss or corruption. It&#8217;s recommended only for disks with a backup power supply.<\/p>\n<p>Some third-party programs require disk write caching to be enabled or disabled. If your disk are used for Event Store databases, it&#8217;s highly recommended to disable disk caching to help ensure that data is durable when the machine might experience a power, device or system failure.<\/p>\n<p>In Ubuntu, it&#8217;s easy to check out whether disk caching is enabled on your disk or not by running below command:<\/p>\n<pre style=\"border:none;\">sudo hdparm -i \/dev\/sda<\/pre>\n<p>Replace \/dev\/sda with your device and you&#8217;ll see below similar outputs:<\/p>\n<blockquote><p>Model=WDC WD3200BPVT-22JJ5T0, FwRev=01.01A01, SerialNo=WD-WX61EC1KZK99<br \/>\n Config={ HardSect NotMFM HdSw>15uSec SpinMotCtl Fixed DTR>5Mbs FmtGapReq }<br \/>\n RawCHS=16383\/16\/63, TrkSize=0, SectSize=0, ECCbytes=50<br \/>\n BuffType=unknown, BuffSize=8192kB, MaxMultSect=16, MultSect=off<br \/>\n CurCHS=16383\/16\/63, CurSects=16514064, LBA=yes, LBAsects=625142448<br \/>\n IORDY=on\/off, tPIO={min:120,w\/IORDY:120}, tDMA={min:120,rec:120}<br \/>\n PIO modes:  pio0 pio3 pio4<br \/>\n DMA modes:  mdma0 mdma1 mdma2<br \/>\n UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6<br \/>\n AdvancedPM=yes: unknown setting <span style=\"color:red;\">WriteCache=enabled<\/span><br \/>\n Drive conforms to: Unspecified:  ATA\/ATAPI-1,2,3,4,5,6,7<\/p>\n<p> * signifies the current active mode<\/p><\/blockquote>\n<p>The words in red, WriteCache=enabled, means caching is enabled! To disable it, edit the &#8220;\/etc\/hdparm.conf&#8221; with your favorite editor, here I use vi as example:<\/p>\n<pre style=\"border:none;\">sudo vi \/etc\/hdparm.conf<\/pre>\n<p>Uncomment the line <b>&#8220;#write_cache = off&#8221;<\/b> (without quotes) by removing the <b>#<\/b> at its beginning. So it looks like:<\/p>\n<blockquote><p># -W Disable\/enable the IDE drive&#8217;s write-caching feature<br \/>\nwrite_cache = off<\/p><\/blockquote>\n<p>After that, restart your computer and check out the write caching status again to make sure it&#8217;s disabled.<\/p>","protected":false},"excerpt":{"rendered":"<p>&nbsp; This simple tutorial is going to show you how to disable disk write caching in Ubuntu to prevent data loss when you may experience power failure. Enable write caching improves disk performance, but a power outage or equipment failure might result in data loss or corruption. It&#8217;s recommended only for disks with a backup [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[1001,1000],"class_list":["post-2896","post","type-post","status-publish","format-standard","hentry","category-howtos","tag-disable-disk-caching","tag-ubuntu-data-loss-prevention"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/2896","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=2896"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/2896\/revisions"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=2896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=2896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=2896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}