Reading Linux

Dec 29, 2006 18:55 # 43775

null wants to know...

Command to detach IDE drives?

On my beloved FreeBSD server, I can type

umount /backup
atacontrol detach ata1

and then physically remove the harddisk(s) on IDE channel 1 from the system while it is still running.

Likewise, plugging a harddisk and commanding

atacontrol attach ata1
mount /backup

will introduce the drive to the system and mount it.

This is great for hot-swapping drives on hardware that doesn't actually support hot-swapping.

My question is, does anybody know of anything similar in Linux?

When life hands you a lemon, that's 40% of your RDA of vitamin C taken care of.

Jan 08, 2007 10:07 # 43796

Magicdead *** replies...

Re: Command to detach IDE drives?

?% | 1

Uhm... Linux got mount and umount as well,

for instance:

umount /dev/hda1

I think you don't even have to do atacontrol or something, you can just remove it when you umount'ed it

and something like:

mount /dev/hda1 /mnt/hda

where /mnt/hda would be the folder the harddisc is mounted to (depending on the distribution, this is /mnt/* or /media/*, at least in most cases)

depending on the sort of filesystem you may need to use options(filesytem,accessrights,...) for the mount command, but usually it will just take the settings from the /etc/fstab file.

The harddisks should be loaded into the /dev/ directory automatically by the kernel

cya Magic

"The wise have always said the same things, and fools have always done the opposite"-Schopenhauer

This post was edited by Magicdead on Jan 08, 2007.

Jan 08, 2007 15:18 # 43798

null replies...

Re: Command to detach IDE drives?

Oh. I probably didn't make that clear, but I'm familiar with the mount command :-)

The magic I'm looking for is really in these atacontrol commands. It actually makes the /dev/ad2* devices disappear (these would be /dev/hdc* on Linux), and usually the drives connected to the detached IDE channel even power down. The umount on the other hand unmounts the file system mounted on /shares but (of course) does not touch the /dev/ad2* devices.
You might understand that I'm a bit reluctant to rip a piece of hardware out of a running machine without first informing the OS. :-) That's what I'm using atacontrol for.
So what I'm looking for is a reliable way to tell the kernel "Hey, forget about /dev/hdc*, 'cause I'm about to remove it" and "Re-check this IDE channel, I've added something to it."

By the way, hello, nice to see you around!

When life hands you a lemon, that's 40% of your RDA of vitamin C taken care of.

Jan 08, 2007 16:44 # 43800

Magicdead *** replies...

Re: Command to detach IDE drives?

?% | 1

Well i think udev does this automatically on linux:

DESCRIPTION
udev provides a dynamic device directory containing only the files for
actually present devices. It creates or removes device node files in
the /dev directory, or it renames network interfaces.

Usually udev runs as udevd(8) and receives uevents directly from the
kernel if a device is added or removed form the system.

If udev receives a device event, it matches its configured rules
against the available device attributes provided in sysfs to identify
the device. Rules that match, may provide additional device information
or specify a device node name and multiple symlink names and instruct
udev to run additional programs as part of the device event handling.

And udev is based on hotplug... and ever since kernel 2.6, hotplug should work for all devices:
(taken from hotplug project homepage)

In the Linux 2.6 kernel, hotplugging has been integrated with the driver model core so that any bus or class can report hotplug events when devices are added or removed. Quite a few subsystems now support hotplugging; the list at this site is not currently exhaustive. There's work afoot to improve the situations for hotplugging many kinds of devices, including things like disks, power supplies (many newer UPSes are usb-programmable), input devices, and even more. In particular, udev builds on hotplug, to help make sure your /dev/... directory matches the devices actually present on your system. Now would be a good time to help integrate support for your favorite devices!

then again the hotplug webpage says it supports removeable IDE devices. So the questions is wether your ata disk is a removeable IDE device or not ;)

you could take a look into the /etc/udev/rules.d directory to see what udev does to remove /dev/ entries (try the "persistent-disk.rules" ), maybe you could also achieve something similar to what you want you want with the hdparm utility (though i'm not exactly sure). hdparm is often mentioned as being an equivalent of atacontrol.

i know this doesn't help you a lot, but it may show you the right direction ;)

And I only know that changeing SATA drives in linux isn't supported, never read that ATA isn't supported.

well, good luck with it ;)

"The wise have always said the same things, and fools have always done the opposite"-Schopenhauer

Jan 08, 2007 18:19 # 43803

null smiles...

Re: Command to detach IDE drives?

Thanks a bunch! I shall look into this.

When life hands you a lemon, that's 40% of your RDA of vitamin C taken care of.

Jan 16, 2007 16:38 # 43837

yoshi314 * replies...

Re: Command to detach IDE drives?

?% | 1

I thought hdparm can do this with ata drives, at least.

-s   set power-up in standby flag (0/1)
 -y   put IDE drive in standby mode
 -Y   put IDE drive to sleep
 -z   re-read partition table

Or maybe i'm wrong here?

"Life is a queue. You come in, hang around for a bit, get some service, then depart."


Small text Large text

Netalive Amp (Skin for Winamp)