Disk Write Caching

Here you will find information that will save you time and frustration.

Moderator: Founder

Disk Write Caching

PostPosted by natemaia » Sat Jun 10, 2017 1:38 pm

ArchLabs includes hdparm a very usefull utility to manage storage media, but does not enable write caching to our storage drives by default. The arch way, we as useres must take it upon ourselves to optimize our system to our liking. Write Caching is used by most modern storage devices to improve write speeds but not on removable storage as they get hotplugged, removing the need to first unmount the drive.

The main downside to enabling write caching is "By enabling write caching, file system corruption and/or data loss could occur if the machine experiences a power, device or system failure and cannot be shutdown properly."
Gnome-disk-utility:
Performance is increased by enabling write caching, but leaves the system susceptible to data loss in the event of a power failure

Personally I prefer to have it enabled

To turn it on:
Code: Select all
sudo /sbin/hdparm -W 1 /dev/<your drive>

To turn it off:
Code: Select all
sudo /sbin/hdparm -W 0 /dev/<your drive>

You can get your device name by running (omit the partition numbers as they don't matter eg. /dev/sdc1 => /dev/sdc)
Code: Select all
blkid -o list

In my case i ran: sudo /sbin/hdparm -W 1 /dev/sda

After this you should get a small output telling you of the outcome
/dev/sda:
setting drive write-caching to 1 (on)
write-caching = 1 (on)

Profit :D
Last edited by natemaia on Sat Jun 10, 2017 4:16 pm, edited 1 time in total.
User avatar
natemaia
ArchLabs Guru
ArchLabs Guru
 
Posts: 75
Joined: Thu Mar 16, 2017 10:14 pm
Location: Canada - British Columbia
Running Release: 5.0

Re: Disk Write Caching

PostPosted by Dobbie03 » Sat Jun 10, 2017 2:36 pm

Thanks for this. Do you need to run this for every drive connected?
I like my Metal like my coffee.......black
User avatar
Dobbie03
Founder
Founder
 
Posts: 558
Joined: Sat Feb 18, 2017 2:51 pm
Location: New Zealand
Running Release: DobbieBang

Re: Disk Write Caching

PostPosted by natemaia » Sat Jun 10, 2017 4:12 pm

You can if you wish, I run it on every drive that I have mounted via fstab
User avatar
natemaia
ArchLabs Guru
ArchLabs Guru
 
Posts: 75
Joined: Thu Mar 16, 2017 10:14 pm
Location: Canada - British Columbia
Running Release: 5.0

Re: Disk Write Caching

PostPosted by erikdubois » Sat Jun 10, 2017 5:35 pm

Done on my clonezilla ssd
How can we test that it has improved?
Living to learn, learning to live.
Linux fits well in my life's motto.
More info on http://erikdubois.be
Archlabs support articles are on https://goo.gl/AaYI0b
Archlabs support youtube channel is on https://goo.gl/Lovquv
User avatar
erikdubois
Site Admin
Site Admin
 
Posts: 333
Joined: Sun Mar 05, 2017 5:42 am
Location: Belgium

Re: Disk Write Caching

PostPosted by natemaia » Sat Jun 10, 2017 7:29 pm

Read speeds you can run this a few times before and after and take the average of the values
Code: Select all
sudo hdparm -Tt /dev/<your drive>
For Writes it's a bit more complex we need to use dd, make an empty folder on the drive you want to test. cd into it and run (again do it a couple of times before and after taking the averages)
Code: Select all
dd if=/dev/zero of=tempfile bs=1M count=1024 conv=fdatasync,notrunc status=progress

The above is preffered but you can install gnome-disk-utility and run a disk benchmark through the GUI. This cant do write benchmarks on mounted drives so your main drive is out of the question :geek:
All of this will vary depending on what the drive is doing so try to shutdown all running programs before doing this!!
User avatar
natemaia
ArchLabs Guru
ArchLabs Guru
 
Posts: 75
Joined: Thu Mar 16, 2017 10:14 pm
Location: Canada - British Columbia
Running Release: 5.0


Return to Tips and Tricks

Who is online

Users browsing this forum: No registered users and 0 guests

cron