How can I change the cache mode of a USB drive

I have installed Ubuntu 16.04 on a 32GB pen drive, because my hard disk stopped working. It runs okay from the pen drive, but it sometimes hangs for a few seconds during write operations (and maybe sometimes read operations too) on the pen drive. This frequently causes applications to become unresponsive for around 5 to 15 seconds (they usually turn grey during this time).

Probably enabling write-back caching will help. Does anyone know how to enable caching so that I don't suffer from occasional extremely high write (and maybe read) times?

I realize that this question is a duplicate ofHow can I change the cache mode of an USB drive?. An answer there says:

You can try remounting the partition with different options, example

sudo mount -o remount,rw,relatime,data=writeback /dev/sda1 /

Another option is to pass the argument via Grub.

Executing the above command gives this error message (in dmesg):

EXT4-fs (sdb1): Cannot change data mode on remount

I don't know how to pass this argument via Grub.

Update:

Here is my /etc/fstab:

# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sdc1 during installation
UUID=75f3da54-9738-4180-8f48-fcef12d8c1ca / ext4 errors=remount-ro 0 1
/dev/disk/by-label/DELLUTILITY /mnt/DELLUTILITY auto nosuid,nodev,nofail,noauto 0 0
/dev/disk/by-label/Recovery /mnt/Recovery auto nosuid,nodev,nofail,noauto 0 0
/dev/disk/by-label/win7 /mnt/win7 auto nosuid,nodev,nofail,noauto 0 0
/dev/disk/by-label/SPARE /mnt/SPARE auto nosuid,nodev,nofail,noauto 0 0
/dev/disk/by-label/GoFlex /mnt/GoFlex auto nosuid,nodev,nofail,noauto,x-gvfs-show,umask=002,uid=1000,gid=1000 0 0
  • /dev/sda is my non-functional hard disk
  • /dev/sdb is my pen drive.
1

1 Answer

If you're using USB 2.0 (I hope you're not) the speed will be much less than that of a typical HDD. Anyway, since you've asked the settings are in /etc/udisks2/IDENTIFIER.conf where IDENTIFIER is the concatenated (and hyphenated) value of disk MODEL and SERIAL.

1. Find the configuration file

You can get the MODEL and SERIAL of your disk by using the command

udisksctl status

It will report something like this

MODEL REVISION SERIAL DEVICE
--------------------------------------------------------------------------
WDC WD1600BEVT-22ZCT0 11.01A11 WD-WXE808S69993 sda
HL-DT-ST DVDRAM GSA-T20N EV02 M2L87NG3612 sr0 

To form the file name, I'll first replace the spaces with - in model. It's now WDC-WD1600BEVT-22ZCT0. And then concatenate the serial with -. The result is WDC-WD1600BEVT-22ZCT0-WD-WXE808S69993. So, in my case the settings file is in /etc/udisks2/WDC-WD1600BEVT-22ZCT0-WD-WXE808S69993.conf

2. Edit configuration file

In that file there should be ini file like entries and Section. Under [ATA] section, create an entry with this key-value WriteCacheEnabled=true.

# See udisks(8) for the format of this file.
[ATA]
WriteCacheEnabled=true

Save the file. The settings should take effect after a reboot.

8

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like