LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 03-12-2006, 12:05 PM   #1
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Rep: Reputation: 62
How can I permanently turn off 'Write Cache' ---Debian


I have been working on setting up some POSTGRESQL databases ... Nothing critical yet, but I'm getting ready. Did a dist-upgrade this morning, and POSTGRESQL was one of the programs updated. When it restarted, there was a message:
Quote:
Starting PostgreSQL 7.4 database server: main.
Warning: The following devices contain databases and have write
caching enabled: /dev/hdb
This could destroy the integrity of your databases in the event of power
failure. Consider disabling the write cache with "hdparm -W 0 <device>".
The hdparm command does the job, but after a reboot, 'write caching' is enabled again.

What is the correct way to turn it off permanently?
 
Old 03-13-2006, 06:31 AM   #2
Keruskerfuerst
Senior Member
 
Registered: Oct 2005
Location: Horgau, Germany
Distribution: Manjaro KDE, Win 10
Posts: 2,199

Rep: Reputation: 164Reputation: 164
Write cache is enabled by default in the kernel.
Add a bootscript with the following lines to runlevel 5:
#!/bin/bash
hdparm -W0 /dev/hdb
 
Old 03-13-2006, 09:25 AM   #3
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Original Poster
Rep: Reputation: 62
Quote:
Add a bootscript ... to runlevel 5:
I am aware that such a thing can be done, but vague about just how to go about it. As far as I can tell there are currently no 'bootscripts' on my system apart from the various bashrc files. Just where would this script go, and what would initialize it?
 
Old 03-13-2006, 05:56 PM   #4
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Original Poster
Rep: Reputation: 62
I have searched around a whole lot more for instructions on how to do this ... unsuccessfully. I guess what I really want to know is if there is a 'Debian' way. Even better, is there a system script already out there in which I should just append the line 'hdparm -W0 /dev/hdb'
 
Old 03-13-2006, 07:03 PM   #5
J.W.
LQ Veteran
 
Registered: Mar 2003
Location: Boise, ID
Distribution: Mint
Posts: 6,642

Rep: Reputation: 87
Moved to Distributions - Debian per request
 
Old 03-13-2006, 07:24 PM   #6
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Rep: Reputation: 49
Quote:
Originally Posted by rickh
I am aware that such a thing can be done, but vague about just how to go about it. As far as I can tell there are currently no 'bootscripts' on my system apart from the various bashrc files. Just where would this script go, and what would initialize it?

You can put the hdaprm command in /etc/hdparm.conf file towards the end. So Everytime you reboot your system, it will execute the command and you will be able to disable the write cache.
 
Old 03-13-2006, 07:35 PM   #7
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Original Poster
Rep: Reputation: 62
Ah! That's exactly what I needed. If fact, such a line is already there, I just have to uncomment it. Thanks.
 
Old 03-13-2006, 08:10 PM   #8
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Rep: Reputation: 49
Quote:
Originally Posted by rickh
Ah! That's exactly what I needed. If fact, such a line is already there, I just have to uncomment it. Thanks.
No problems...
 
Old 03-13-2006, 08:21 PM   #9
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Original Poster
Rep: Reputation: 62
...Except, it didn't work. I tried a couple optional methods described in /etc/hdparm.conf:
Code:
/dev/hdb {
       write_cache = off
}
and
Code:
command_line {
        hdparm -W0 /dev/hdb
}
but either way after a reboot:
Quote:
debian:~# hdparm -i /dev/hdb

/dev/hdb:

Model=WDC WD800JB-00JJC0, FwRev=05.01C05, SerialNo=WD-WMAM98691672
Config={ HardSect NotMFM HdSw>15uSec SpinMotCtl Fixed DTR>5Mbs FmtGapReq }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=66
BuffType=unknown, BuffSize=8192kB, MaxMultSect=16, MultSect=off
CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=156301488
IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio3 pio4
DMA modes: mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5
AdvancedPM=no WriteCache=enabled
Drive conforms to: Unspecified: ATA/ATAPI-1 ATA/ATAPI-2 ATA/ATAPI-3 ATA/ATAPI-4 ATA/ATAPI-5 ATA/ATAPI-6

* signifies the current active mode
Evidently that script is not being invoked during the boot?
 
Old 03-13-2006, 08:30 PM   #10
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Rep: Reputation: 49
Quote:
Originally Posted by rickh
...Except, it didn't work. I tried a couple optional methods described in /etc/hdparm.conf:
Code:
/dev/hdb {
       write_cache = off
}
and
Code:
command_line {
        hdparm -W0 /dev/hdb
}
but either way after a reboot:
Evidently that script is not being invoked during the boot?
Well sad to know that. Actually on my system, the script gets invoked everytime I boot my system.

Ah, I just observed that I have script called hdparm in my /etc/init.d directory which is linked to rcN.d directories and that's why it is getting invoked in my case. It was there by default.

Is there any script in your system ??
 
Old 03-13-2006, 09:01 PM   #11
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Original Poster
Rep: Reputation: 62
Yeah. I have such a script, and also I notice that /etc/rcS.d/ includes S07hdparm

Is that where it belongs?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
turning on dma and write back cache on SATA? niverson Linux - Hardware 16 02-15-2006 12:42 AM
How can I turn off File system cache? joxer77 AIX 4 08-04-2005 09:10 AM
webmin troubles - Failed to write to /etc/webmin/module.infos.cache : No space left o coal-fire-ice Linux - Software 1 07-28-2005 10:08 AM
Flash drive write cache ilikejam Linux - Hardware 5 05-22-2004 11:07 AM
How do I turn off DHCP in Debian? t3kn0lu5t Linux - Networking 4 10-01-2003 10:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 04:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration