LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-30-2004, 01:41 PM   #1
dgermann
Member
 
Registered: Aug 2004
Distribution: Ubuntu 8.04.1 desk; Red Hat 9.0 server
Posts: 331

Rep: Reputation: 30
Question Identical removable HDDs


Hi--

OK, I have gotten as far as getting a second removable HDD so I can swap these as my backups, taking one offsite.

I have two identical drives (Western Digital 200Gb) on my Red Hat 9.0 system.

Here's what I did:

1. The first is installed and partitioned as /dev/sda1 and sda2.

2. I plugged in the second and ran fdisk to make identical partitions.

3. Ran /sbin/mkfs -t ext3 /dev/sdb1 and sdb2

4. Ran e2label /dev/sdb1 label1 and sdb2 label2

5. Shut off power to HDD2, then HDD1, then powered up HDD2--it still sees it as sdb instead of sda.

6. Thinking I should start over, I removed partitions via fdisk from sdb, then, with only HDD2 powered up and plugged in (usb2 port), tried to run fdisk on it as sda--fdisk complained that "unable to read /dev/sda"

I want to be able to swap these out from day to day, so I want the cron files to see these as the same drive.

Suggestions?
 
Old 08-30-2004, 11:24 PM   #2
dgermann
Member
 
Registered: Aug 2004
Distribution: Ubuntu 8.04.1 desk; Red Hat 9.0 server
Posts: 331

Original Poster
Rep: Reputation: 30
OK, folks, here's an update, that might give us some clues:

I powered off the 1st HDD.

Then I powered on the 2nd HDD.

Then I rebooted the machine.

Voila! the 2d HDD was now recognized as sda1 and sda2, and the drives mounted OK.

So that leaves this question for you gurus :

How can I get it to allow me to swap these two backup drives without having to reboot? (This is a file server, and 5 computers might have to re-login if I rebooted, and files might be lost if someone was in the middle of work).

Is it an option to the mount command?

I notice in /var/log/messages a lot of references to devlabel--is there perhaps something I should do with that?

And would it be better to post this question in another category?
 
Old 08-31-2004, 05:29 AM   #3
nukkel
Member
 
Registered: Mar 2003
Location: Belgium
Distribution: Hardened gentoo
Posts: 323

Rep: Reputation: 30
Hi,

Well what happens is, the first removable storage device that you attach after a (re)boot -- be it an usb flash keychain, or a digital camera, or an external harddrive, ... -- is always assigned to sda. Then the second sdb and so on, even if the first device was removed in the meantime. This is your problem and it goes rather deep I'm afraid... It would require kernel programming to alter this behaviour.

What I think you could do in your case is to make a script of some kind that you run instead of mounting the drive, and that:
1 - Checks which drive is there (sda or sdb)
2 - Mounts whichever drive it finds to a fixed mount point, so that the partition(s) is/are mounted at the same mount point, regardless of it being on sda or sdb.

Please feel free to ask for clarification -- I'm a bit concise here 'cos I don't know your level of experience
nukkel
 
Old 08-31-2004, 12:04 PM   #4
dgermann
Member
 
Registered: Aug 2004
Distribution: Ubuntu 8.04.1 desk; Red Hat 9.0 server
Posts: 331

Original Poster
Rep: Reputation: 30
nukkel--

Thanks for the help!

As you guessed, I am still a real novice. I got the general drift of what you have said, and I do see that something is going on in the kernel to tell it where sda and sdb are. But beyond that, it is all greek (maybe I could say it is all linux ) to me!

For one thing, I do not understand anything about fixed mount points.

Here is the script I use now.

=====
#!/bin/bash
echo "Run this as su"
/sbin/e2label /dev/sda1 /backups2
/sbin/e2label /dev/sda2 /extra
mount -L /backups2
mount -L /extra
df -h
=====

If I recall correctly, once one of them has been mounted, then a simple umount followed by powering down the one and powering up the second, followed by running this script again, does not work.

So what would the script you have in mind look like?

Thanks, nukkel, for befriending this lost linux soul!
 
Old 08-31-2004, 12:22 PM   #5
scuzzman
Senior Member
 
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
maybe instead of having the system them as the same device, simply have them linked to the same mount point. ie:
Code:
#!/bin/bash

# script-name: swapdrive
# lets assume the mountpoint is going to be
# /backup
# if this directory has yet to be created, create it 
# sudo mkdir /backup

# Note: this script is not correct, and thus not fully useable yet
# what's not useable will be in italics
# the conditional here is what you're needing
# something along the lines of detecting whether
# a particular device is already mounted ie: 

if (/dev/sda1 is already mounted) {
umount /dev/sda1
mount /dev/sda2 /backup # mount the second drive to /backup
}
else { # if the first one isnt mounted, umount sda2 and mount sda1
umount /dev/sda2
mount /dev/sda1 /backup # mount the first drive
}

exit
#EOF
 
Old 08-31-2004, 03:18 PM   #6
Coldburn
LQ Newbie
 
Registered: Aug 2004
Location: Texas, USA
Distribution: FD3
Posts: 7

Rep: Reputation: 0
why not raid these drives?

why dont you mirror (raid 1) these drives? Use mdadm to create the mirror and you can shut down either of the two drives and hot-swap them provided your hardware will allow it. You wouldnt have the /sda /sdb problem either since the raid set would use /dev/md?

http://www.linuxdevcenter.com/pub/a/...2/05/RAID.html
 
Old 08-31-2004, 03:28 PM   #7
nukkel
Member
 
Registered: Mar 2003
Location: Belgium
Distribution: Hardened gentoo
Posts: 323

Rep: Reputation: 30
Hi Doug,

You're welcome! Sorry, I must have missed the fact that you used e2label, which is actually a good move. A you sure that you have set the labels on both HDD's? I.e. plug both in, and then

/sbin/e2label /dev/sda1 backups2
/sbin/e2label /dev/sda2 extra
/sbin/e2label /dev/sdb1 backups2
/sbin/e2label /dev/sdb2 extra

so they look identical. (also note, it's not necessary to put a / in the label.) Then when only one of the HDD's are plugged in it should work by simply doing "mount -L /extras". There's no need to re-run e2label every time -- the label is preserved until changed.

Again, I could have told you this before, I just missed it :s

Could you try this? putting the labels on both drives and then mounting by just doing "mount -L ..."? See if they can be swapped OK...

If that don't work, I'll get back to you on that script -- to look where the attached drive "went" (sda? sdb?) and then mount it accordingly etc...

Good luck!
nukkel
 
Old 08-31-2004, 03:32 PM   #8
nukkel
Member
 
Registered: Mar 2003
Location: Belgium
Distribution: Hardened gentoo
Posts: 323

Rep: Reputation: 30
Coldburn: nice suggestion, however I wonder... If your 2 drives differ because e.g. you put sth. on one of them from another computer... What will then be considered the "correct" one?
 
Old 08-31-2004, 09:12 PM   #9
dgermann
Member
 
Registered: Aug 2004
Distribution: Ubuntu 8.04.1 desk; Red Hat 9.0 server
Posts: 331

Original Poster
Rep: Reputation: 30
Wow! You guyr are terrific!

John, nukkel, Coldburn--

Wow! You guys are terrific! I think you have given me much more than I could have expected. An overrunning cup, as it were....

Everyone--

I seem to be up and running with my original script. nukkel, you answered the remaining question I had on the script, whether I could just comment out the two e2label lines. I will do that.

I simply umounted the #2 HDD, powered down, powered up #1 HDD, and ran the script.

I think I tried that before and took its complaints about e2 label not working meaning the whole thing failed. But this time it did mount the #1 HDD.

(The error message reads:
/sbin/e2label: Attempt to read block from file system resulted in short read while trying to open /dev/sda1
Couldn't find valid filesystem superblock.
I/O error: dev 08:02, sector 0)

John--

Thanks for all the work on this one! Wow!

It looks like your script does much the same as mine, in the sense that it mounts the one after checking which drive is actually present. Mine is a dumber script, not doing any checking, just clumping through with jack boots and mounting whether it is sda or sdb....

Let's say I add a 3rd, 4th and maybe even 5th HDD for more backups. Any reason I'd need to have a step-above script like yours in place of mine (now simplified)?

Coldburn--

Thanks for bringing up this idea. I wondered just this morning how this might be like raid, and how that might be set up.

You have given me the entry point to see how it is done.

Does raid allow me to take one or more drives off site for safety?

nukkel--

Thank you for sticking with me on this. You have given me some real confidence!
 
Old 08-31-2004, 09:24 PM   #10
dgermann
Member
 
Registered: Aug 2004
Distribution: Ubuntu 8.04.1 desk; Red Hat 9.0 server
Posts: 331

Original Poster
Rep: Reputation: 30
OK folks, I commented out the 2 e2label lines. When it runs the script now, I get these error messages:

I/O error: dev 08:01, sector 312464000
I/O error: dev 08:02, sector 78252416

It does seem to mount the drive OK, though.

Not to worry? Or a problem?
 
Old 09-01-2004, 10:10 AM   #11
nukkel
Member
 
Registered: Mar 2003
Location: Belgium
Distribution: Hardened gentoo
Posts: 323

Rep: Reputation: 30
I guess this is, since the mount is done using labels, it is looking around for a drive which has a partition with that label, so it makes some "wrong guesses", tries to read but there's nothing there. Result, I/O error... It shouldn't be a problem.

However, don't forget to un-mount the partitions before unplugging a drive (using the umount command, or in the GUI), otherwise there may still be data in RAM cache that should have been written to disk. This would also give these I/O errors, when the drive has been unplugged without unmounting.

As for using even more disks... I guess just labeling all of them in the same way would work OK...

P.S. Keep up this state of mind, and you won't be a novice for much longer Never give up experimenting!
 
Old 09-01-2004, 07:04 PM   #12
dgermann
Member
 
Registered: Aug 2004
Distribution: Ubuntu 8.04.1 desk; Red Hat 9.0 server
Posts: 331

Original Poster
Rep: Reputation: 30
nukkel--

Thanks for the compliments!

What I did was make a small script file:

===
#!/bin/bash
echo "run this as su"
umount /backups2
umount /extra
echo "OK to power down first HDD"
echo ""
echo "Now, power up second HDD"
echo ""
echo "When second drive up to speed,"
echo ""
echo "Hit <Return>."
read anykey
mount -L /backups2
mount -L /extra
df -h
===

So that should make sure I umount each time.

Thanks for sticking with me on this, nukkel!
 
Old 09-02-2004, 03:53 AM   #13
nukkel
Member
 
Registered: Mar 2003
Location: Belgium
Distribution: Hardened gentoo
Posts: 323

Rep: Reputation: 30
I think that's the safest way to go! Glad to hear it worked out for you!

best regards,
nukkel
 
Old 09-03-2004, 11:21 PM   #14
Coldburn
LQ Newbie
 
Registered: Aug 2004
Location: Texas, USA
Distribution: FD3
Posts: 7

Rep: Reputation: 0
Re: Wow! You guyr are terrific!

Quote:
Originally posted by dgermann
John, nukkel, Coldburn--

Coldburn--

Thanks for bringing up this idea. I wondered just this morning how this might be like raid, and how that might be set up.

You have given me the entry point to see how it is done.

Does raid allow me to take one or more drives off site for safety?

nukkel--

Thank you for sticking with me on this. You have given me some real confidence!
Yes! You can administrativly 'fail' a drive and safely hot-swap (or pull it from the machine while running - provided the hardware supports it) without a hickup. I've done similar on HP and Compaq storage systems for years. It feels weird at first but ya get used to it!

This article isnt too bad.. http://www.linuxdevcenter.com/pub/a/...2/05/RAID.html

If I google mdadm i seem to get the same article copied on different sites...

Oh and to answer your question..

Quote:
Coldburn: nice suggestion, however I wonder... If your 2 drives differ because e.g. you put sth. on one of them from another computer... What will then be considered the "correct" one?
Typically when you fail a drive it's marked with a flag, so the raid set will know which drives are the 'good' ones.
 
Old 09-04-2004, 08:52 PM   #15
dgermann
Member
 
Registered: Aug 2004
Distribution: Ubuntu 8.04.1 desk; Red Hat 9.0 server
Posts: 331

Original Poster
Rep: Reputation: 30
Coldburn--

Thanks!

The article is a little beyond my skills at this point, but perhaps tying it would give me the educations I need. Scary.

If I put both these drives on the machine, and say another couple drives, then I could swap daily and have a decent back up system, yes? Seems to me I do not need to do anything other than use this software to accomplish that, right? No other hardware needed? If so, that's neat.

Would it get rid of those I/O errors I mentioned? Those have me wondering, although it seems it may be a kernal issue, rather than a problem with the drives. Anybody know anything about those I/O errors?
 
  


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
Sync up identical machines kenny_dilger Linux - General 1 07-09-2004 05:26 PM
Two identical computers but different OS-es OlympusHermes Linux - General 19 01-23-2004 03:18 PM
2 identical nic problem darchon Linux - Networking 1 03-27-2003 08:43 PM
Smoothwall w/identical NIC's ocularbob Linux - Software 1 02-28-2003 10:34 AM
2 Identical ethernet cards vwhk Linux - Networking 2 02-08-2002 06:40 AM


All times are GMT -5. The time now is 10:31 PM.

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