LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-18-2007, 07:43 PM   #1
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Rep: Reputation: 45
mdadm question on how to re-sync


I have this Linux server that a previous IT guy before me set up. He left no documentations so nobody knows how to reinstall things. We just want to keep it the way it is.

Fortunately he did a software RAID1. Unfortunately now one of the hard drives is dead when I check `cat /proc/mdstat`. Both are 160GB IDE hard drives.

I want to buy a new & bigger 250GB hard drive since they are cheaper than trying to find a 160GB, but I don't care about size difference. I just need the 250GB to partition and be EXACTLY like the 160GB. Is this possible with mdadm?

How would I do this? Do I need to create similar partitions first, and then use mdadm to sync each partition? Or can I just stick in the new 250GB hard drive and let mdadm automagically partition it for me in RAID1?
 
Old 09-18-2007, 10:13 PM   #2
i_grok
Member
 
Registered: Jun 2006
Location: Massachusetts
Distribution: Gentoo
Posts: 79

Rep: Reputation: 16
This is pretty easy, but I don't think mdadm has the ability to do this automatically for you.

Let's say /dev/hda is the existing good 160GB drive and /dev/hdb is the new 250GB drive.

Code:
sfdisk -d /dev/hda | sfdisk /dev/hdb

mdadm /dev/md1 --add /dev/hdb1
mdadm /dev/md2 --add /dev/hdb2

etc.
 
Old 09-19-2007, 12:03 AM   #3
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Original Poster
Rep: Reputation: 45
thanks, i_grok. I will test this out on my VMware before I do it to the real thing!
 
Old 09-20-2007, 05:00 PM   #4
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Original Poster
Rep: Reputation: 45
I can't get the backup hard drive to boot! If I put back the 1st original broken hard drive, then the computer boots. /dev/sda was my main hard drive and /dev/sdb was the backup mirror drive. one of /dev/sda's partition is broken so I can still boot. But when I physically disconnect /dev/sda, /dev/sdb won't boot! No errors or anything. Not even a grub menu.

here is the degraded output:

Code:
mdadm --detail /dev/md2
/dev/md2:
        Version : 00.90.03
  Creation Time : Wed Feb  8 13:00:07 2006
     Raid Level : raid1
     Array Size : 58596992 (55.88 GiB 60.00 GB)
    Device Size : 58596992 (55.88 GiB 60.00 GB)
   Raid Devices : 2
  Total Devices : 1
Preferred Minor : 2
    Persistence : Superblock is persistent

    Update Time : Thu Sep 20 09:31:21 2007
          State : clean, degraded
 Active Devices : 1
Working Devices : 1
 Failed Devices : 0
  Spare Devices : 0

           UUID : a818e9c3:d37fa0f5:ef7b5aaa:fd0f1784
         Events : 0.1604239

    Number   Major   Minor   RaidDevice State
       0       0        0        -      removed
       1       8       22        1      active sync   /dev/sdb6
So how do I go about fixing and resyncing the hard drive if I can't even boot into Linux with the backup hard drive? I have the 2nd new hard drive and just want to resync it.

Last edited by Micro420; 09-20-2007 at 09:18 PM.
 
Old 09-20-2007, 11:18 PM   #5
i_grok
Member
 
Registered: Jun 2006
Location: Massachusetts
Distribution: Gentoo
Posts: 79

Rep: Reputation: 16
Sorry, I forgot about that. The Linux software RAID does not address the boot sector at the beginning of the drive. The previous administrator must not have written the boot sector on both drives. You write the boot sector by starting grub from the command line as root. Then enter:

Code:
device (hd0) /dev/hda
root (hd0,0)
setup (hd0)

device (hd0) /dev/hdb
root (hd0,0)
setup (hd0)
This will write the boot sector to both drives, but presumes that your /boot directory is on the first partition of the device.
 
Old 09-21-2007, 12:36 AM   #6
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Original Poster
Rep: Reputation: 45
i_grok to the rescue (again)! I tested this on my VMware and it worked! I will do this tomorrow on the real computer. Just in case, is there any suggestion you can make on cloning the fully working drive before I copy GRUB? you know, just in case I completely hose the hard drive somehow? We can't afford to lose the data on there so I need to take every precaution I can!
 
Old 09-23-2007, 04:54 PM   #7
i_grok
Member
 
Registered: Jun 2006
Location: Massachusetts
Distribution: Gentoo
Posts: 79

Rep: Reputation: 16
The only way to truly duplicate an entire drive is to directly copy the blocks from one to another. This should only be done if the drives have exactly the same number of sectors. Also, you should not do this unless BOTH of the drives are completely unmounted.

Code:
dd if=/dev/hda of=/dev/hdb bs=2M
This command copies the blocks from the input file (/dev/hda) directly to the output file (/dev/hdb) using 2M chunks. It could take an hour or two for a larger drive with several hundred GB.
 
Old 09-23-2007, 05:14 PM   #8
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Original Poster
Rep: Reputation: 45
i_grok, would this work on the same hardware system:

1) tar and backup each directory such as /home, /boot, /var, /usr, etc...
2) pop in new hard drive that is bigger
3) use fdisk to recreate partitions and size
4) extract tar file and respective directories to the new hard drive
5) grub-install to the new hard drive
6) take out old hard drive
7) boot off new hard drive

Would it work?
 
Old 09-24-2007, 06:38 PM   #9
i_grok
Member
 
Registered: Jun 2006
Location: Massachusetts
Distribution: Gentoo
Posts: 79

Rep: Reputation: 16
Yes, this will work, but you need to make sure you get everything right.

I have done this many times, but it was not uncommon for me to forget some minor detail that had to be fixed with a second reboot.

In particular, make sure you exactly copy the permissions from the original drive. Make sure you DO NOT try to tar the contents of /proc and /sys. These are generated by the kernel and should not be backed up.

Common errors for me are:
  • not re-creating /proc and /sys
  • forgetting to 'chmod 1777 /tmp'
  • leaving an empty /dev (this depends on the distro)
  • forgetting to mkswap on the swap partition
 
  


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
mdadm says "mdadm: /dev/md1 not identified in config file" when booting FC7 raffeD Linux - Server 1 08-11-2008 11:47 AM
Time sync question sunman Slackware 10 03-13-2006 11:36 AM
Mdadm Raid question stefaandk Linux - General 12 08-16-2005 02:11 AM
interesting question about mysql database sync shadow.blue Linux - Software 0 11-15-2003 08:24 AM
Mplayer DVD A-V sync question Amerist Linux - Software 1 10-15-2002 11:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:39 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
Open Source Consulting | Domain Registration