0

I have a Raspberry Pi running Raspbian Jessie Lite (the headless version) and I've been using as a file dump and a git server for a little while. I plugged an external USB hard drive into it for it to use, but it seems to have some trouble with it.

For seemingly no reason at all, the system renames my drive from /dev/sda1 to /dev/sdb1 to /dev/sdc1 and so on every few days. This causes the git and SFTP servers to fail to find the files in the directory this drive is supposed to mount to.

Upon running fdisk -l, I can see the drive has been renamed.

Device     Boot Start        End    Sectors  Size Id Type
/dev/sdb1  *     2048 3907029166 3907027119  1.8T  7 HPFS/NTFS/exFAT

However, df still has the old drive name.

Filesystem      1K-blocks    Used  Available Use% Mounted on
/dev/sda1      1831250820   10976 1733547784   1% /media/USBHDD1

When trying to access /media/USBHDD1 after this change:

# ls /media/USBHDD1/
ls: reading directory /media/USBHDD1/: Input/output error

I modified /etc/fstab to used the drive's UUID so running mount -a temporarily solves the problem and the Pi no longer goes into kernel panic on boot. This, however, is annoying. Work halts until I can SSH into it and fix it every few days and it has become unacceptable.

What would cause the renaming, and how can I either stop it or get df to remember the UUID and not that label?

1 Answer 1

1

It is possible your issue is connected with power saving: the disk spins itself down, the share becomes unaccessible, when the disk reappears it is assigned a different device name (sdb), and the share does not work.

There are two distinct ways to deal with this, you may try them in turn:

  1. Bring power saving under control with hdparm: from the ever helpful Arch Linux wiki, you check current values of power saving parameters with

    hdparm -B /dev/sda
    hdparm -S /dev/sda
    

    where

    -B Set the Advanced Power Management feature. Possible values are between 1 and 255, low values mean more aggressive power management and higher values mean better performance. Values from 1 to 127 permit spin-down, whereas values from 128 to 254 do not. A value of 255 completely disables the feature.

    -S Set the standby (spindown) timeout for the drive. The timeout specifies how long to wait in idle (with no disk activity) before turning off the motor to save power. The value of 0 disables spindown, the values from 1 to 240 specify multiples of 5 seconds and values from 241 to 251 specify multiples of 30 minutes.

    Then you specify, if needed

    hdparm -B 255 /dev/sda
    hdparm -S 0   /dev/sda
    

    and see whether the same issue resurfaces.

  2. The second possibility is to write a udev rule to force udev to assign always the same letter to your disk: add the following rule to the file /etc/udev/rules.d/10-local.rules (if you do not have the file, create it)

    ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", SYMLINK+="sda"
    

    (the Vendor and Product codes refer to a USB stick of mine, you will have to substitute your own values, which you obtain with lsusb).

    You can then check that this works by means of

    udevadm info -a -p  $(udevadm info -q path -n /dev/sda)
    

You must log in to answer this question.

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