SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How are you folks hot swapping SATA drives in Slackware?
Specifically, what is the correct removal procedure to ensure the disk cache is flushed properly and the head parked before turning the power switch to off?
I'm using 12.2. An Asus M2NPV-VM motherboard. I have a removable drive bay for SATA drives for backups and other sneaker-net tasks. The tray connects the drive to an internal motherboard SATA connector.
My system recognizes the new drive on power-up.
The question is the proper procedure for power down and removal.
Once upon a time I think had this working, but now the removal script I wrote does not seem to properly flush the cache or remove the device from the lsscsi list.
I have updated the /sbin/rescan-scsi-bus script from 13.0. I try to remove a device like this:
Code:
$> lsscsi
[0:0:0:0] disk ATA WDC WD3200AAKS-0 12.0 /dev/sda
[1:0:0:0] disk ATA WDC WD6400AAKS-7 01.0 /dev/sdd
[4:0:0:0] disk Generic STORAGE DEVICE 9325 /dev/sdb
[4:0:0:1] disk Generic STORAGE DEVICE 9325 /dev/sdc
$> rescan-scsi-bus --remove --hosts=1 --channels=0 --ids=0 --luns=0
The report from rescan-scsi-bus is no device removed, as witnessed by again running the lsscsi command. (The device is not mounted .)
Distribution: Mostly Gentoo, sometimes Debian/(K)Ubuntu
Posts: 143
Rep:
Controller
It depends on if the controller supports hot swap. HP Proliant G4p DL 360 for example had a note on them stating that hot swap is not supported with SATA drives.
Distribution: Mostly Gentoo, sometimes Debian/(K)Ubuntu
Posts: 143
Rep:
FC
I recall removing FC drives by unmounting, removing and afterwards letting Linux discover the changes but that was quite a while ago and I'm not sure about the details. The software used in Linux distros (udev, multipath, etc) seems to be in disarray. Incompatible changes in minor version jumps and so on.
I have two modern motherboards that support SATA II:
Asus M2NPV-VM, Nvidia NForce 430 (MCP51) chip set
Asus M3N78-EM, Nvidia GeForce 8300 (MCP78S) chip set
Hot swapping should work.
I don't think the rescan-scsi-bus script is working correctly or perhaps I am not using the correct syntax with the remove option.
I usually do:
a)unmount
b)sync (unmount takes care of this but it doesn't hurt to run it)
c)echo 1 > /sys/blah/delete (exactly the same that rescan-scsi-bus does)
d)dmesg to check that the drive is stopped (i hear the disk spinning
down but again just to be sure)
e) pull the drive out.
But as janoszen said, the controller (and libata) must support it.
For example, my motherboard has 2 controllers. The one provided by the
southbridge ICH9R and a Jmicron one. Both controllers support hot plug
only in AHCI mode.
If the BIOS in your motherboards give you a AHCI mode option, try it.
The libata status webpage shows which controllers support which features
but when i tried it, i get "the domain is parked".
Update: Yesterday, after some additional testing and research I am concluding that the rescan-scsi-bus script is broken with respect to removing devices from the list. I tested version 1.25 (the version included in 12.2), 1.29 (the version included in 13.0), and the latest 1.35 (direct from the maintainer's web site).
Originally in my "removal" script I ran this command:
echo "Synchronizing..."
/bin/sync # just to be safe
echo "Stopping (spinning-down) $DEVICE..."
/usr/bin/sg_start -i -v --stop $DEVICE
echo "scsi remove-single-device $HOSTS $CHANNELS $IDS $LUNS" >/proc/scsi/scsi
That approach worked as expected.
I have the sg3_utils package installed, which includes the sg_start command. That command nicely spins down the drive. I hear the drive spin down too. That was one of my concerns because unless I kept the drive installed and then performed a box power-down, I was afraid that merely turning the power key on the tray was forcing the drive into some kind of emergency parking procedure.
The "scsi remove-single-device" command removes the device from the lsscsi list.
The rescan-scsi-bus script contains a similar command but for whatever reason, fails to function correctly. The command is located in the dolunscan() section.
I'll try to contact the maintainer but confirmation from others of this failure would be nice before I do.
Quote:
d)dmesg to check that the drive is stopped (i hear the disk spinning down but again just to be sure)
Yes, in my "removal" script I think I'll grep my logs to provide confirmation. Thanks for the idea.
OK I am trying the exact same thing but with limited success.
Basically:
1-I turn the HDD on by turning the key on the tray;
Problem 1: the drive gets a random assignment (/dev/sdX) which makes later mounting difficult
2-Mount the drive somewhere;
3-Backup...
4-Unmount the drive;
5-"stop" the drive using /usr/bin/sg_start -i -v --stop /dev/sdX
Problem 2: the drive spins down, the tray light goes off, then the drive spins back up and the light turns on... Looks like the tray is forcing a restart... DO you have this problem?
quick howto to have SATA drives seen as removable with udisks and udev
Hi
When I was looking for the convenience of managing my eSATA external HDD like a USB HDD, I found this post : http://lamarque-lvs.blogspot.com/201...and-solid.html
I was looking for a udev-based solution, as HAL is phasing out.
By default, udisks considers all SATA drives as "SYSTEM INTERNAL" disks (thus not removable), as opposed to USB drives considered "NON SYSTEM INTERNAL" (external, aka removable) by default.
Prerequisites
be sure your hardware (HDD, enclosure, motherboard) is hot-swap capable AND aware: for instance, set the SATA mode to AHCI and enable hot-swap support in the BIOS
udisks at least 1.0.3: it includes the necessary patch. As I'm running Slackware64-current with AlienBob's KDE 4.6.5, I had udisks 1.0.2 as a dependency. I just bumped the version in Eric's SlackBuild
Steps
plug your drive, use dmesg to know the letter (such as /dev/sdX), and find the udev path of the SATA header it is plugged in
Code:
udevadm info --query=path --name=sdX
/devices/pci0000:00/0000:00:1f.2/host4/target2:0:0/2:0:0:0/block/sdX
create or edit a udev rule in /etc/udev/rules.d/ (I named mine 99-esata.rules)
add a line in the rules for each SATA header you want to be seen as an external drive
Notice the final udisks env variable is named differently than in Lamarque's patch.
reload udev rules
Code:
udevadm control --reload-rules
Thus, your removable drive will be treated the same way that a USB drive, FUSE-mounted in /media and umounted through the KDE applet : Slackware will take the same steps for you to properly readying the drive to be unplugged.
For a eSATA external drive, I plug in the data cable first then the power cable, and I unplug in reverse order the power cable first then the data cable.
I don't use XFCE, but I think XFCE 4.8 relies on udisks too. Maybe those who test and use Robby's packages can share if it works in XFCE too.
Problem 2: the drive spins down, the tray light goes off, then the drive spins back up and the light turns on... Looks like the tray is forcing a restart... DO you have this problem?
Check if your HDD have a jumper setting for that : on my WD drive, without the jumper the disk spin up as soon as it is powered on, while with the jumper in place the disk wait for the START command.
Problem 1: the drive gets a random assignment (/dev/sdX) which makes later mounting difficult
I use a blunt method. Nothing clever or ingenious. I use the lsscsi command and grep for the drive. As my swappable drives are different from the drives installed inside the case, this works good enough for me. Not a universal remedy, I admit.
A possible lazy universal remedy would be to run the lsscsi command and save the data as a variable. Power on the swappable drive, run the lsscsi command inside a while loop until the lsscsi output is different from the original results. Grab the difference to determine the drive device node. Likely there is a more slick and cool way to do the same thing.
Quote:
Problem 2: the drive spins down, the tray light goes off, then the drive spins back up and the light turns on... Looks like the tray is forcing a restart... DO you have this problem?
I never had that problem. cendryon might have an answer with checking jumpers.
Quote:
I was searching around google your specific board models and they seem to have issues with hot swap.
I am able to hot swap SATA drives without issues. Possibly the Asus M2NPV-VM motherboard has such issues. I don't know. If that is true, then I am somehow working around that. Or possibly the problem is BIOS related.
Dont take my word for it... I was just trying to do some research on your specific issue to see if I could be helpful... and during the google search I found a lot of people complaining about the ability of hot swap on the board Asus M2NPV-VM. Didnt find issues with the Asus M3N78-EM
Check if your HDD have a jumper setting for that : on my WD drive, without the jumper the disk spin up as soon as it is powered on, while with the jumper in place the disk wait for the START command.
OK I've adapted Woodsman scripts to my personal requirements and my server and I must admit, it works well! The only "problem" left is the powering off at the end of the backup. I use a Vantec EZ-SWAP SATA enclosure with a Seagate ST31500541AS (1.5TB Barracuda LP) HDD, and at the end of the script, when the rsnapshot is complete, the script asks if I want to remove the disk from the SCSI list. Here' the output:
Code:
Do you want to remove the backup drive from the SCSI list? (y/n): y
Continuing.
Attempting to remove ST31500541AS from the SCSI list.
[1:0:0:0] disk ATA ST31500541AS CC34 /dev/sdg
DEVICE=/dev/sdg
HOSTS=1
CHANNELS=0
IDS=0
LUNS=0
Removing ST31500541AS (/dev/sdg) from SCSI list...
Continue? (y/n): y
Continuing.
Checking mount status...
Oops! Found ST31500541AS mounted at /dev/sdg6. Unmounting...
/dev/md1 on / type reiserfs (rw,relatime)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/md0 on /boot type reiserfs (rw)
/dev/md2 on /var type reiserfs (rw)
/dev/md3 on /tmp type reiserfs (rw)
/dev/md4 on /home type reiserfs (rw)
/dev/md5 on /mnt/files-vault type reiserfs (rw)
/dev/md6 on /mnt/media-storage type reiserfs (rw)
/dev/sdc5 on /mnt/it-maintenance type reiserfs (rw)
/dev/sdd5 on /mnt/mass-storage type reiserfs (rw)
nfsd on /proc/fs/nfs type nfsd (rw)
This might take a few seconds...
Tue Sep 20 16:42:22 EDT 2011
Synchronizing disk cache.
Stopping (spinning-down) /dev/sdg.
Start stop unit command: 1b 01 00 00 00 00
[4:0:0:0] disk ATA ST3320620AS 3.AA /dev/sda
[5:0:0:0] disk ATA WDC WD3200AAKS-7 12.0 /dev/sdb
[6:0:0:0] disk ATA WDC WD10EADS-00L 01.0 /dev/sdc
[7:0:0:0] disk ATA WDC WD7500AYPS-0 02.0 /dev/sdd
[8:0:0:0] disk ATA Hitachi HDS5C302 ML6O /dev/sde
[9:0:0:0] disk ATA ST32000542AS CC34 /dev/sdf
The ST31500541AS may be powered off.
The device cannot be restored to the scsi list without cycling power.
Done.
At the line in bold above, I hear a "click" in the enclosure but the enclosure light stays on. I am not sure the HDD has really been powered down or properly spin down. I imagine so because from that point on, it is not listed by lsscsi (as shown above) or fdisk...
I've looked on the HDD, there is no jumpers at all... The enclosure has only a Master/Slave jumper in the back.
How to make sure it is safe to turn off the enclosure therefore unpowering the HDD?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.