LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 12-06-2009, 12:57 PM   #1
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545
Hot Swapping SATA Drives


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 .)

Thanks again.

Last edited by Woodsman; 12-06-2009 at 02:14 PM.
 
Old 12-06-2009, 03:35 PM   #2
janoszen
Member
 
Registered: Oct 2009
Location: Budapest
Distribution: Mostly Gentoo, sometimes Debian/(K)Ubuntu
Posts: 143

Rep: Reputation: 22
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.
 
1 members found this post helpful.
Old 12-06-2009, 06:19 PM   #3
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Original Poster
Rep: Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545
Quote:
It depends on if the controller supports hot swap.
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.
 
Old 12-07-2009, 12:30 AM   #4
janoszen
Member
 
Registered: Oct 2009
Location: Budapest
Distribution: Mostly Gentoo, sometimes Debian/(K)Ubuntu
Posts: 143

Rep: Reputation: 22
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.
 
Old 12-07-2009, 04:15 AM   #5
imitheos
Member
 
Registered: May 2005
Location: Greece
Posts: 433

Rep: Reputation: 115Reputation: 115
Quote:
Originally Posted by Woodsman View Post
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".
 
Old 12-07-2009, 01:18 PM   #6
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Original Poster
Rep: Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545
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:

rescan-scsi-bus --remove --hosts=$HOSTS --channels=$CHANNELS --ids=$IDS --luns=$LUNS

Yet that command no longer has any effect.

In my "removal" script I instead added this:

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.
 
Old 09-01-2011, 07:12 PM   #7
lpallard
Member
 
Registered: Nov 2008
Posts: 987

Rep: Reputation: Disabled
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?

6-And normally I would turn the tray off...
 
Old 09-02-2011, 02:37 AM   #8
cendryon
Member
 
Registered: Aug 2005
Location: France
Distribution: Slackware64 current
Posts: 82

Rep: Reputation: 30
Lightbulb 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
  1. 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
  2. create or edit a udev rule in /etc/udev/rules.d/ (I named mine 99-esata.rules)
  3. add a line in the rules for each SATA header you want to be seen as an external drive
    Code:
    DEVPATH=="/devices/pci0000:00/0000:00:1f.2/host4/*" ENV{UDISKS_SYSTEM_INTERNAL}="0"
    Notice the final udisks env variable is named differently than in Lamarque's patch.
  4. 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.

Finally, if you don't have/want udisks, Lamarque wrote a post using HAL :
http://lamarque-lvs.blogspot.com/201...and-solid.html

Hope it helps
 
Old 09-02-2011, 08:22 AM   #9
cendryon
Member
 
Registered: Aug 2005
Location: France
Distribution: Slackware64 current
Posts: 82

Rep: Reputation: 30
Quote:
Originally Posted by lpallard View Post
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.
 
Old 09-02-2011, 11:45 AM   #10
SeRi@lDiE
Member
 
Registered: Jun 2006
Location: /dev/null
Distribution: Slackware 13.1, Slackware 13.37, aptosid, rhel
Posts: 545
Blog Entries: 7

Rep: Reputation: 55
Woodsman,

I was searching around google your specific board models and they seem to have issues with hot swap.

http://www.google.com/search?sourcei...w=1920&bih=965
 
Old 09-02-2011, 12:10 PM   #11
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Original Poster
Rep: Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545
Quote:
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.
 
Old 09-02-2011, 12:43 PM   #12
SeRi@lDiE
Member
 
Registered: Jun 2006
Location: /dev/null
Distribution: Slackware 13.1, Slackware 13.37, aptosid, rhel
Posts: 545
Blog Entries: 7

Rep: Reputation: 55
Woodsman,

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

Take care.
 
Old 09-02-2011, 02:45 PM   #13
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Original Poster
Rep: Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545
Hmm. I now realize I am the original poster of this thread. I never tagged the thread as solved, which I should have long ago. Done.

The more recent posts were started by lpallard. So I am no longer the one seeking help, but him.
 
Old 09-04-2011, 09:54 AM   #14
lpallard
Member
 
Registered: Nov 2008
Posts: 987

Rep: Reputation: Disabled
Thanks woodsman!

I have a lot to try on this thread . Today it's raining like crazy outside so I think I'll get busy with this and post back..
 
Old 09-20-2011, 03:57 PM   #15
lpallard
Member
 
Registered: Nov 2008
Posts: 987

Rep: Reputation: Disabled
Quote:
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?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Properly removing SATA hard drives(hot-swap) galapogos Linux - Hardware 3 08-26-2009 02:40 AM
Does IDE/SATA/SCSI drives support hot-swapping ? exceed1 Linux - Hardware 10 10-19-2008 09:33 PM
Hot-swappable SATA Drives in RAID 5 on Linux? Synesthesia Linux - Hardware 11 01-06-2006 06:14 PM
hot swap for adding random hard drives? PATA, SATA, SCSI? Oo.et.oO Linux - General 1 11-05-2005 10:38 AM
Hot swapping? gauge73 Linux - Hardware 3 08-10-2005 12:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration