🔍 See Original Answer on Ask Ubuntu 🔗
External hard drive keeps powering down
June 30, 2018
November 24, 2022
Copy to clipboard: false
Not only with large downloads, but also with copying large files from HDD to external HDD there is a bug almost five years old: Ubuntu slows down and hangs while copying file from/to USB.
The solutions posted by many users is to check your write back cache:
$ cat /proc/vmstat | egrep "dirty|writeback" nr_dirty 15 nr_writeback 0 nr_writeback_temp 0 nr_dirty_threshold 261131 nr_dirty_background_threshold 130406
The accepted answer (with 66 up-votes) here: stackexchange.com - Why is my pc freezing while I’m copying a file to a pendrive?
echo $((16*1024*1024)) > /proc/sys/vm/dirty_background_bytes echo $((48*1024*1024)) > /proc/sys/vm/dirty_bytes
The accepted answer is using indirect math to set 16 MiB for dirty background bytes and 48 MiB for dirty bytes.
From the first link (bug report) though, comment #83 recommends a more aggressive value of 200 MB for dirty bytes. To make settings permanent edit
/etc/sysctl.conf and add this line:
vm.dirty_bytes = 200000000
systctl -p or reboot.
There are many other suggestions in the first link and you might have to try other ones if this common solution doesn’t work.
BTW dirty doesn’t mean anything nefarious. It means data held in RAM waiting to be written to disk. So while your download is running the information is being held in RAM and not written to your external hard drive. Inactivity could be why it is powering down.
Also as I mentioned in comments
blkid reveals nothing in Ubuntu 18.04 but
lsblk reveals everything including external drives.