Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Auto-mounting usb hard drives
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
yaman666
Tux's lil' helper
Tux's lil' helper


Joined: 13 Dec 2002
Posts: 117
Location: Chicago, IL

PostPosted: Mon Jun 30, 2008 7:49 pm    Post subject: Auto-mounting usb hard drives Reply with quote

I am trying to set up a rotating hard drive backup system, where a single usb hard drive is plugged into the server. Server would synchronize backups to this hard drive and every day the hard drive would be swapped for another identical hard drive, that way there's always a complete copy that's a day old in case anything happens to both server and the hard drive.

My questions are:

1. What is the simplest way to auto-mount this hard drive, there seems to be so many solutions out there with autofs, ivman, etc
2. Is it possible to auto-unmount the drive, so that I could simply unplug one hard drive, plug the other one in and the server would not care
3. Would I need to set up udev rules to make sure the drives map to the same path all the time? Right now it doesn't look like any nodes are created for it under
Code:
/dev/disk/by-id/
but there is one under
Code:
/dev/disk/by-label/OneTouch4\\x20Mini


Dmesg output just in case

Code:
usb 1-1: new high speed USB device using ehci_hcd and address 2
usb 1-1: configuration #1 chosen from 1 choice
scsi1 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 2
usb-storage: waiting for device to settle before scanning
  Vendor: Maxtor    Model: OneTouch          Rev: 0125
  Type:   Direct-Access                      ANSI SCSI revision: 04
SCSI device sdc: 312581808 512-byte hdwr sectors (160042 MB)
sdc: Write Protect is off
sdc: Mode Sense: 2d 08 00 00
sdc: assuming drive cache: write through
SCSI device sdc: 312581808 512-byte hdwr sectors (160042 MB)
sdc: Write Protect is off
sdc: Mode Sense: 2d 08 00 00
sdc: assuming drive cache: write through
 sdc: sdc1
sd 1:0:0:0: Attached scsi disk sdc
sd 1:0:0:0: Attached scsi generic sg2 type 0
usb-storage: device scan complete


Thanks a lot!
Back to top
View user's profile Send private message
coolsnowmen
Veteran
Veteran


Joined: 30 Jun 2004
Posts: 1479
Location: No.VA

PostPosted: Mon Jun 30, 2008 11:33 pm    Post subject: Re: Auto-mounting usb hard drives Reply with quote

I'm having a hard time understanding why automounting is even necessary. Assuming you backup at a particular time, why not have the backup.sh mount it, if this is already a scripted task?
_________________
emerge: there are no ebuilds to satisfy "moo"
Back to top
View user's profile Send private message
yaman666
Tux's lil' helper
Tux's lil' helper


Joined: 13 Dec 2002
Posts: 117
Location: Chicago, IL

PostPosted: Tue Jul 01, 2008 3:24 am    Post subject: Reply with quote

The point is to be able to simply unplug the hard drive and replug another hard drive without touching the server. This is where question 2 comes in - does it get unmounted automatically?
Back to top
View user's profile Send private message
coolsnowmen
Veteran
Veteran


Joined: 30 Jun 2004
Posts: 1479
Location: No.VA

PostPosted: Tue Jul 01, 2008 5:28 pm    Post subject: Reply with quote

they most certainly won't get unmounted in the traditional sense, I'm going to have to just mount something and pull it from the system to see what happens. This is nonstandard and so may have changed over the years. In the past the system took a while to realize that there was no connection to the device anymore, so the next usb connection *sometimes* had a different device node eg (/dev/sda the first time, but /dev/sdb the second) in the time it took for the system to realize the device was stale.

This might be a problem if you are thinking of having filesystems with the same label. Perhaps a different /dev/disk/by-* will be necessary.

More importantly, you have to be flushing or mounting synchronously if you don't want to lose anything (if i remember there is an option in the middle that could work). That still begs the question, if you are not unmounting it, how do you know it is done? You are writing to this disk, pulling before that process is finished ...

Then again, why can't your backup script unmount the drive when it is done? It could also signal you when it is done in someway, turn a light on, send you an email, play some music.
_________________
emerge: there are no ebuilds to satisfy "moo"
Back to top
View user's profile Send private message
yaman666
Tux's lil' helper
Tux's lil' helper


Joined: 13 Dec 2002
Posts: 117
Location: Chicago, IL

PostPosted: Wed Jul 02, 2008 8:56 pm    Post subject: Reply with quote

Solved this using autofs. It allows you to auto-mount only when access is needed and then auto-unmount when idle for X seconds. So when I unplug/replug, it'll just remount the new hard drive since they both seem to map to /dev/sdc

coolsnowmen wrote:

More importantly, you have to be flushing or mounting synchronously if you don't want to lose anything (if i remember there is an option in the middle that could work). That still raises the question, if you are not unmounting it, how do you know it is done? You are writing to this disk, pulling before that process is finished ...


This is not a concern since backups will be done at night, so by morning it should hopefully be done or run out of hard drive space. :-)

Quote:
Then again, why can't your backup script unmount the drive when it is done? It could also signal you when it is done in someway, turn a light on, send you an email, play some music.


LOL! I'm going to have to find some sort of USB light dongle that would light up via a shell command... ;-) There are no speakers on the server, I don't even know if it has a video card, but in either case a sound in the middle of the night to alert that backup finished won't help anyone.
Back to top
View user's profile Send private message
coolsnowmen
Veteran
Veteran


Joined: 30 Jun 2004
Posts: 1479
Location: No.VA

PostPosted: Thu Jul 03, 2008 12:18 am    Post subject: Reply with quote

I'm glad autofs does what you need. Its been years since I used it.

I used to use parallel ports to turn lights on and off. If you get a parallel port cable and chop it in half, and set up a simple circuit with an led+resistor in it, you can turn them on/off using standard linux libraries (paraport if memory serves)

I'm not even suggesting you do this, with a couple tests you should know the basic amount of time for a backup, but it would be cool if you had the time.

But for important headless systems in gerneral (if you are doing rotating-daily backups, I'm assuming it is important), developing a way (over the network?) of telling you if there is an error is worth the time. And if you are doing that then writing a "backup complete `date`" file would be good enough.

What are you spending on hard drives? if you were spending enough it might be worth getting a terastation and crossover cabling to it, and doing alternating rsyncs to it.
_________________
emerge: there are no ebuilds to satisfy "moo"
Back to top
View user's profile Send private message
baeksu
l33t
l33t


Joined: 26 Sep 2004
Posts: 609
Location: Seoul, Korea

PostPosted: Thu Jul 03, 2008 12:53 am    Post subject: Reply with quote

yaman666 wrote:
Solved this using autofs. It allows you to auto-mount only when access is needed and then auto-unmount when idle for X seconds. So when I unplug/replug, it'll just remount the new hard drive since they both seem to map to /dev/sdc

Maybe it's a good idea to add 'sync' to the mount options in autofs, if you don't mind the performance hit.

It might alleviate file corruption issues, in case the drive didn't unmount automatically.
_________________
Gnome:
1. A legendary being.
2. A never ending quest to make unix friendly to people who don't want unix and excruciating for those that do.
Back to top
View user's profile Send private message
coolsnowmen
Veteran
Veteran


Joined: 30 Jun 2004
Posts: 1479
Location: No.VA

PostPosted: Thu Jul 03, 2008 2:07 am    Post subject: Reply with quote

it might not be necessary to actually mount it sync, especially If io performance hurts the overall performance needs of your system.

If you have a massive backup going, it won't just cache everything. Linux will actually write to the drive eventually. It is true that you can't trust a copy has actually occurred just by virtue of the face that the "cp" process ended. But unmounting or simply executing the "sync" command at the end of any backup would be sufficient.
_________________
emerge: there are no ebuilds to satisfy "moo"
Back to top
View user's profile Send private message
yaman666
Tux's lil' helper
Tux's lil' helper


Joined: 13 Dec 2002
Posts: 117
Location: Chicago, IL

PostPosted: Thu Jul 03, 2008 4:31 am    Post subject: Reply with quote

I'd love to do something like an LED alert, but I'm afraid my electrical skills are somewhat lacking and I don't have enough time to research this. May be later as a pet project. :-)

Thanks for all the suggestions, guys! I actually didn't realize you could do an autofs with sync option. I'll give it a try and see how big of a performance hit it takes compared to simply syncing in the end of a cp.

As far as the drives, they're just cheap maxtor one touch minis 160Gb - around $70/piece. And I'm doing regular tarballs of everything, but I'm starting to look into bacula, amanda, etc - for a more flexible backup policy in the future, considering that the number of servers keeps increasing and doing complete daily dumps is starting to eat into the bandwidth cost.
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