Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
udev rule for hd specifc disconnect
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5909

PostPosted: Thu Apr 18, 2013 10:09 am    Post subject: udev rule for hd specifc disconnect Reply with quote

hello all,

I have a hd case with an 3 tb hd. it is connected to my computer in an esata cable.
as I don't have an esata port, I've got these sata to esata converters and it seems to be working.

now I want to run an command if the connection is terminated (connecting it when the machine is running doens't finds the hd, I assume that is because I didn't configured sata hotswap, not sure how to do that thought), thing is I want to preform it only if that specific drive gets disconnected. I have the uuid of the drive.

what is the right way to address this?

Thanks.
_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
Back to top
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6095
Location: Dallas area

PostPosted: Thu Apr 18, 2013 11:03 am    Post subject: Reply with quote

To get hotswap (in general) the bios needs to be set to ahci mode (sometimes it is part of raid mode on the motherboard)
_________________
PRIME x570-pro, 3700x, 6.1 zen kernel
gcc 13, profile 17.0 (custom bare multilib), openrc, wayland
Back to top
View user's profile Send private message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5909

PostPosted: Thu Apr 18, 2013 11:53 am    Post subject: Reply with quote

Anon-E-moose wrote:
To get hotswap (in general) the bios needs to be set to ahci mode (sometimes it is part of raid mode on the motherboard)


I'm already work in ahci mode in the bios. on the other hand I've disabled raid in the bios and using the raid in te kernel.
_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
Back to top
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6095
Location: Dallas area

PostPosted: Thu Apr 18, 2013 2:25 pm    Post subject: Reply with quote

I have one disk that I connect to the esata port once a week for offline backup.

I unmount the disk then disconnect it with
Code:
#!/bin/bash

if [ $# -eq 0 ]
 then
  echo Usage: $0 device
  echo  device sde, sdf, etc
  exit 0
fi

# root check
if [ `id -u` -ne 0 ]
 then
  1>&2 echo error, must be run as root, exiting...
  exit 0
fi

sdparm -C sync /dev/$1
sdparm -r -C stop /dev/$1
echo 1 > /sys/block/$1/device/delete


Then I turn off power to the drive.

I know there is a way to tie scripts to udev rules, but I don't use udev rules for things like this.

If this isn't what you are getting at then I'm sorry for the confusion.
_________________
PRIME x570-pro, 3700x, 6.1 zen kernel
gcc 13, profile 17.0 (custom bare multilib), openrc, wayland
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Thu Apr 18, 2013 3:39 pm    Post subject: Re: udev rule for hd specifc disconnect Reply with quote

DaggyStyle wrote:
what is the right way to address this?

With a custom rule file in /etc/udev/rules.d/, containing e.g.:
Code:
ACTION=="remove", KERNEL=="sd[a-z]*", ATTRS{model}=="MODELNUMBERHERE", RUN+="yourexe"


To find good identifying fields, use e.g.:
Code:
udevadm info -a --name /dev/sdb
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum