Festplatte auswerfen (Hot-Swap|eSata)

Um USB Sticks auszuwerfen gibt es das eject-Kommando. Möchte man aber eine Festplatte z.B. per Hot-Swap oder am eSata Quick-Port auswerfen kann man folgendes machen:

# echo "1" >/sys/block/sda/device/delete

Wobei die Angabe sda die Platte angibt die ausgeworfen werden soll. Ein kleine Bash-Funktion mit entsprechenden Sicherheitsabfragen läßt sich z.B. leicht in der .bash_aliases unterbringen:

function ejectHD()
    [ -z $1 ] && echo "Usage: ejectHD BLOCK_DEV_NODE (eg: sda, sdb, ...)" && return 1
    [ ! -e "/sys/block/$1" ] && echo "Device node not ejectable." && return 2
    read -s -n1 -p ">> Attention! Ejecting '$1'! Sure? (y|N) "
    [[ $REPLY =~ (y|Y) ]] && echo "1" >/sys/block/$1/device/delete && echo "... done" && return 0         
    echo "... aborted."

Zuvor sollte man allerdings sicherstellen das man alle Dateisysteme per unmount abgerissen hat sonst kann es schnell zu Datenunfällen kommen.


I'm a computer kid of the 80', not born but raised in good old' germany, playin' games, makin' music & lovin' the blues. My career started at an age of 10 in a shopping mall where they sold computers too. It was the first time ever i've seen such an electronic monster and was fascinated instantly. Later on i've learned my first programming skills (Basic) with a friend's Sinclair ZX 81. Yes, that one with the strange plastics keyboard. After that i got some experience with a Schneider CPC464 and the Commodore C64 until i fell in love with the Commodore Amiga, a machine with 4096 different colors which sounds nowadays to most like black'n'white tv's sounded to me at that time. We played a lot of games like Decathlon, The Last V8, Impossible Mission, Elite, Mega'lo'Mania, Xenon, Speedball or Chaos Engine and ruined a lot of those Competition Pro Joysticks. My favourites were mostly games by Sensible Software, Bitmap Brothers or Rainbow Arts. What i liked the most about that machine was it's AmigaOS, it's operating system was ahead of it's time. On this machine i learned my first assembler language (m68k) and the hardware internas. I watched the decline of Commodore with a tear in my eye and at some point i went over to usual business and my first PC and learned it's beastly manners.

вяоӣсо wrote 19 posts

Post navigation

Leave a Reply