I would like to know what would be the best practices to start/stop/switch safely an eSATA disk.
First : i've read this post : Safely removing eSATA disks but the given and accepted answer does not work for me. At first i wanted to ask for clarifications, but i've read this is to be avoided, so my only option was to open another question.
I'm running kUbuntu 13.04. My bios does support AHCI and i have specifically enables hotplug for the SATA port that links to my eSATA bay. My eSATA dock has a power button.
Starting seems easy enough. If i plug a disk in the bay, then power it up, the disk will mount automatically as a "fuseblk" disk (at least for the one i tested, looks like it's how an NTFS disk is reported)
However, i would like to know how i can stop the disk without stoping the computer, possibly to mount another disk, all of this while avoiding data loss and physical disk damage, and preferably in an (semi) automated way so i don't have to open my command line every time.
What i've found so far :
- sdparm doesn't seem to be of any use, even thought it should be the right tool (disk is /dev/sda), but
sdparm -C stopdoes nothing
- hdparm on the other hand does work to put the disk to sleep
sudo hdparm -Y /dev/sdawill have the disk stop spinning. However, the disk is still mounted as reported by mount -l
sudo echo 1 > /sys/block/sda/device/deletewill give me a permission refused error (even though i used sudo)
- there is an "eject" icon if i right click the disk in Dolphin that will unmount the disk, but the disk won't stop spinning (and i sure don't want to physically remove a spinning disk)
So currently, i unmount the disk using the "eject" button, then put the disk to sleep. However, i don't know enough of the HDs management to be sure "sleep" is enough. Is there no real "stop" or "power off" command? When the OS is going to shutdown, does it simply put the drives to sleep and is it enough to allow safe handling.
Also, when following those steps and then switching to another disk, the disk will sometimes appear as /dev/sde rather than /dev/sda, wich leads me to believe there are some resources that are not correctly freed. Maybe this is precisely the point of the
sudo echo 1 > /sys/block/sda/device/delete command, but as i can't run it, even with a sudo, it's not really helpful.
Is there any other command i should be aware of, and add to the sequence?
As for making this automatic, i guess i can make a shell script, but what if i have a multi partition disk. Using umount /dev/sda1 won't unmount other partitions, and i don't think it's possible to unmount using only /dev/sda is it? Would it work with /dev/sda*? Currently the only multi partition disk i have under hand is my system disk, so i can't try to unmount it and see what happens.