3

My home server has a USB hard drive plugged to it. Once in a while, the breakers jump or there are power outages. Since my server is a laptop, it keeps chugging along, but the rest of the hardware (network, periphericals) do a power cycle.

My hard drive is set to auto-mount in fstab, but after a power outage, the drive remains listed, but isn't accessible. I get IO errors when trying to access it, and why I try to unmount it, I get "umount: mount disagrees with the fstab". Calling mount -a or rebooting fixes the problem.

This did not happen with Linux Mint, but it does with this minimal Lubuntu install. How can I solve it?

UUID=bb14889e-70de-45f4-882a-5ef45708d283 /media/external1      ext4    defaults,errors=remount-ro,nobootwait 0       1

2 Answers 2

3

Although I don't understand why there is a difference in Mint and Lubuntu, I recommend you react to power outages with running the command which solves your problem:

mount -a

You can either run this command periodically or poll the battery status:

upower -i /org/freedesktop/UPower/devices/battery_BAT0

NOTE: Your device may be different. You can confirm like so using upower -d:

$ upower -d | grep Devic
Device: /org/freedesktop/UPower/devices/line_power_ADP1
Device: /org/freedesktop/UPower/devices/battery_BAT1

Or simply check if there are errors on the drive:

 #!/bin/bash
 while [[ 1 ]]; do
   ls /mnt/external1
   ret=$?
   sleep 1m
   if [ $ret -neq 0]; then
     mount -a 
   fi
 done

$? is the return value of ls which will be >0 if there were errors.

0

Another solution would be to get your disk mounted by udev rules instead of fstab entry. This way whenever an outrage happens, your laptop will notice that a USB device was unplugged, and unmount the drive. Once the power comes back, it will detect that USB device again, and remount the drive.

Here's an answer dealing with mounting USB drives on connection specifically for lubuntu.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .