LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 02-03-2009, 01:31 PM   #1
ncsuapex
Member
 
Registered: Dec 2004
Location: Raleigh, NC
Distribution: CentOS 2.6.18-53.1.4.el5
Posts: 770

Rep: Reputation: 43
trying to clone a drive with RAID1. getting stuck at grub


I have 2 IDE drives on RAID1 and I want to clone a drive to use in another system. I booted into runlevel 1, with the new drive replacing the original second drive. I mounted the new drive, created the partitions to match the drive I want to clone, made them as fd(linux raid) and formatted the filesystem, copied the data over to match the original drive.

cp -avx /boot /mnt/hdb1
cp -avx / /mnt/hdb3

using hda2/hdb2 as swap

I removed /boot from /mnt/hdb3 as it copied over the boot directory when I copied the files.


/boot/grub/grub.conf looks like this:
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/md3
# initrd /initrd-version.img
#boot=/dev/md2
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-53.1.21.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-53.1.21.el5 ro root=/dev/md3
initrd /initrd-2.6.18-53.1.21.el5.img
[root@localhost:/root] #



When I boot up using only the new cloned drive it gets stuck at the grub screen and says "file not found"

root (hd0,0)
filesystem type is ext2fs, partition type 0xfd
kernel /vmlinuz-2.6.18-53.1.21.el5 ro root=/dev/md3
error 15: file not found
press any key to continue


the pressing any key takes me back to a boot splash screen.




I think the problem is the root=/dev/md3

The new drive doesnt know what md3 is.. What do I need to do to get grub to recognize the new cloned drive as /dev/md3 and also what do I need to do once I get booted up so I can install a 2nd drive to RAID1 it?



I thought I had ran this command initially so I booted back up with both disks in place and ran it again. This time it boots to:

grub>


dd if=/dev/hda of=/dev/hdb bs=512 count=1
 
Old 02-03-2009, 04:55 PM   #2
ncsuapex
Member
 
Registered: Dec 2004
Location: Raleigh, NC
Distribution: CentOS 2.6.18-53.1.4.el5
Posts: 770

Original Poster
Rep: Reputation: 43
In my grub.conf I added /boot to these 2 lines and it now boots up.

kernel /boot/vmlinuz-2.6.18-53.1.21.el5 ro root=/dev/md3
initrd /boot/initrd-2.6.18-53.1.21.el5.img

And when I cd into /boot I have a boot directory.
so. I copied everything that was in /boot/boot into /boot, removed the /boot from the 2 lines above and rebooted and it gave me error 15, without any opportunity to edit grub.

So for now I guess I can keep it like this although I would like to figure out how to remove the /boot from the grub.conf.


2nd question is. Is there a better way to set up RAID1 now that I have the cloned drive up and running? Or do I have to set my RAID1 up from scratch with the new drive?
 
Old 02-03-2009, 05:07 PM   #3
mostlyharmless
Senior Member
 
Registered: Jan 2008
Distribution: Slackware -current (multilib) with kernel 3.16.2
Posts: 1,566
Blog Entries: 13

Rep: Reputation: 178Reputation: 178
Strange, I didn't see RAID anywhere in your description of what you did. Perhaps I misread.

What I would have done is marked one of the RAID-1 disks as failed, removed it from the array, and then swapped the physical hardware. Then I would have rebooted with the array running in degraded mode and added the disk to the array, and let it sync.

What you appear to have now are two disks with the same files and partitions, but that is not the same as RAID-1. Assuming your original boot disk still has your RAID array running degraded, you can still add the new disk to the array. It'll rewrite everything you did, but that's ok.

The name of your boot device has probably changed from /dev/md3; I agree with that part!
 
Old 02-04-2009, 01:04 PM   #4
ncsuapex
Member
 
Registered: Dec 2004
Location: Raleigh, NC
Distribution: CentOS 2.6.18-53.1.4.el5
Posts: 770

Original Poster
Rep: Reputation: 43
Quote:
Strange, I didn't see RAID anywhere in your description of what you did. Perhaps I misread.

Quote:
I have 2 IDE drives on RAID1
first line of the thread





Quote:
What I would have done is marked one of the RAID-1 disks as failed, removed it from the array, and then swapped the physical hardware. Then I would have rebooted with the array running in degraded mode and added the disk to the array, and let it sync.
I'll probably try that next. Would it matter if say I were to go from an IDE drive to a SATA drive?



Quote:
What you appear to have now are two disks with the same files and partitions, but that is not the same as RAID-1. Assuming your original boot disk still has your RAID array running degraded, you can still add the new disk to the array. It'll rewrite everything you did, but that's ok.

The name of your boot device has probably changed from /dev/md3; I agree with that part!

Right.. I wasn't really trying to RAID the old drive with the new one but clone it, then take the clone and raid it in another box.



I guess what I was asking is, is there a way to clone the drive but still have all the RAID configs intact so when I moved the new cloned drive into a new box I could just add another drive to RAID1 it?
 
Old 02-05-2009, 02:19 PM   #5
mostlyharmless
Senior Member
 
Registered: Jan 2008
Distribution: Slackware -current (multilib) with kernel 3.16.2
Posts: 1,566
Blog Entries: 13

Rep: Reputation: 178Reputation: 178
Unmounting one of the raided disks and using dd to clone the drive will copy everything, partition table, raid info, you name it. There are disadvantages to that approach. I don't know if clonezilla will clone raided disks with their raid setup. To use dd, there is a massive thread here that has nearly everything you could think of to do with it written about it. "Learn to use dd" or something like that...but it looks like the last line of your first post shows that you did use dd, or did you use cp like you stated at the beginning? Well, it doesn't matter.

You can probably get rid of error 15 by reinstalling grub and letting it know where your new files are.

Probably setting up RAID 1 from scratch is the easiest and safest thing to do.

Last edited by mostlyharmless; 02-05-2009 at 02:26 PM. Reason: added info
 
Old 02-05-2009, 05:21 PM   #6
ncsuapex
Member
 
Registered: Dec 2004
Location: Raleigh, NC
Distribution: CentOS 2.6.18-53.1.4.el5
Posts: 770

Original Poster
Rep: Reputation: 43
Initially I was going to use dd to clone the disks, then I read where if the disk geometry of the 2 disks were different it wasn't a good idea to use dd, so I used dd to just copy the mbr from one disk to another, then set up my partitions, then used cp to copy all the files to the right partitions. Later I found a good tutorial on how to change the disk geometry.

Today I tried it the way you suggested and used a SATA disk to clone from an IDE, since when I get ready to do this for real that's how I need to do it.

I broke the raid with:

mdadm --fail /dev/mdx /dev/hdxx
mdadm --remove /dev/mdx /dev/hdxx


Then shutdown replaced the 2nd drive in the RAID with the new SATA drive. Set up the partitions just like the main drive and made it RAID. Everything looked fine till I rebooted and it won't add the second drive to the RAID on boot, get errors in dmesg about the uuid being different. but it will let me manually add the 2nd disk to the raid and it syncs. Well at least it will let me re-add the swap and boot RAID as I can umount those devices but not the root partition.


Also, another problem I am running into is grub again. In the grub.conf for my IDE drives it has the references to (hd0,0). So when I boot up with just the newly cloned SATA drive it freezes on GRUB, not the grub command line, just the word GRUB and it will not let me type anything, the only keyboard response is CTRL-ALT-DEL. Anyway to force grub to know that the SATA drive is the boot drive? Or do I need to use a grub boot CD to reinstall grub at that point? Floppy isn't an option.
 
Old 02-06-2009, 10:03 AM   #7
mostlyharmless
Senior Member
 
Registered: Jan 2008
Distribution: Slackware -current (multilib) with kernel 3.16.2
Posts: 1,566
Blog Entries: 13

Rep: Reputation: 178Reputation: 178
Quote:
about the uuid being different
Got a question: when you rebooted and replaced the IDE with the SATA drive, did you add the SATA drive and sync it before rebooting and getting the error message?

i.e. I assume that you ran the array "degraded" with 1 device being "missing", then reassembled with the new device specified, which would have automatically sync'd. You should be able to add the extra device to the running raid root partition without unmounting. To fix the uuid problem I suppose you might need to assemble the array with the -U option to update the uuid. Worst comes to worst, I suppose you could use a rescue CD like Knoppix to reassemble the array on your root partition with it unmounted, but that should be unnecessary.

Quote:
Anyway to force grub to know that the SATA drive is the boot drive? Or do I need to use a grub boot CD to reinstall grub at that point?
I don't know how adding the SATA drive has changed grub's view of your disk geometry; it can be somewhat arbitrary, and depends on the bios settings. If you setup your SATA disk as the first boot device in your bios, grub will generally see that as hd0, if it's the second device to boot, hd1, and so forth.

You can try messing around with the bios or you can boot with a grub CD to see what the current arrangement looks like using the grub> command line and using command completion. E.g. root (hd[TAB] should show the possible options...
 
Old 02-09-2009, 11:20 AM   #8
ncsuapex
Member
 
Registered: Dec 2004
Location: Raleigh, NC
Distribution: CentOS 2.6.18-53.1.4.el5
Posts: 770

Original Poster
Rep: Reputation: 43
Quote:
Got a question: when you rebooted and replaced the IDE with the SATA drive, did you add the SATA drive and sync it before rebooting and getting the error message?
I think so. I've gone round and round doing so many ways of doing this I'm not sure.


Quote:
I don't know how adding the SATA drive has changed grub's view of your disk geometry; it can be somewhat arbitrary, and depends on the bios settings. If you setup your SATA disk as the first boot device in your bios, grub will generally see that as hd0, if it's the second device to boot, hd1, and so forth.

Ok I was thinking the hd0 referred to the device(/dev/hda) so that grub would need to be changed to something like sd0.




I started over this time user clonezilla, using pretty much the generic defaults. Now when I boot up with just the clonded SATA drive I get the kernel panic not syncing, attempted to kill init:

screen shot included.

I've tried various changes to grub.conf/menu.list/device.mapper/fstab/with no such luck. Ive booted with a knoppix CD, mounted the cloned drive and made the changes to those files.
Attached Images
File Type: jpg photo.jpg (209.4 KB, 3 views)
 
Old 02-10-2009, 09:29 AM   #9
mostlyharmless
Senior Member
 
Registered: Jan 2008
Distribution: Slackware -current (multilib) with kernel 3.16.2
Posts: 1,566
Blog Entries: 13

Rep: Reputation: 178Reputation: 178
Quote:
I think so. I've gone round and round doing so many ways of doing this I'm not sure.
Indeed, I think sitting back and restating the configuration would be helpful, as it seems confusing to me at this point. For example, at this point, does your system have three disks (2 IDEs in RAID and one SATA), or one IDE and one SATA, and does it still boot off the original array with some configuration? We seem to be in a room full of twisty little tunnels, all of which look alike.

Quote:
Ok I was thinking the hd0 referred to the device(/dev/hda) so that grub would need to be changed to something like sd0.
As I said before: "you can boot with a grub CD to see what the current arrangement looks like using the grub> command line and using command completion. E.g. root (hd[TAB] should show the possible options..." You could try root (sd[TAB] also, but I think everything is "hdX" to grub.

Looking at your screenshot, it looks like your system is trying to mount a RAID set but failing - since it doesn't succeed, all the mount points fail after that, leading to the kernel panic. You can debug your initrd by rebuilding it with "sh" commands in it so that you can see what is or isn't mounted and fix it, but I suspect that's the hard way to go about this problem. Instead:

Quote:
I've tried various changes to grub.conf/menu.list/device.mapper/fstab
Maybe it'll help if I can see the current versions of those, and if any boot configuration currently works.
 
Old 02-10-2009, 11:01 AM   #10
ncsuapex
Member
 
Registered: Dec 2004
Location: Raleigh, NC
Distribution: CentOS 2.6.18-53.1.4.el5
Posts: 770

Original Poster
Rep: Reputation: 43
Im just going to start over again. So forget everything above. I reinstalled CentOS 5.1 in RAID1 with 2 IDE drives. I want to clone one of those to a SATA drive, then rebuild the array with the newly cloned SATA drive with a 2nd SATA drive, so that my new setup will be 2 SATA drives in a RAID1.


In my existing RAID1 IDE setup I am going to run these 2 commands:

mdadm --fail /dev/mdx /dev/hdxx
mdadm --remove /dev/mdx /dev/hdxx

Then shutdown the PC, swap the 2nd IDE drive with a brand new SATA drive. Power up


Then when I reboot will I run this command?

mdadm --manage --re-add /dev/mdx /dev/sdax

for each of the md devices?


EDIT:

Ok I ran these commands with the 2 original IDE RAID1 drives:
mdadm --fail /dev/mdx /dev/hdxx
mdadm --remove /dev/mdx /dev/hdxx

*for each md device.

shutdown, removed the 2nd IDE drive and added the SATA drive.

Partitioned and formatted the new SATA drive just just the 1st IDE drive.

ran:

mdadm --manage -add /dev/mdx/dev/sdax

for each or the md devices. Let all 2 partitions sync and the shut down. Removed the 1st IDE, powered back up. got the GRUB ERROR 15 message, rebooted with a knoppix live CD and ran grub with these options:

grub> device (hd0) /dev/sda
grub> root (hd0,0)
grub> setup (hd0)


rebooted. got past the boot splash screen and it failed again kernel panic, same as the previous attachment:


files on the sata drive:

/boot/grub/grub.conf:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/md3
# initrd /initrd-version.img
#boot=/dev/md2
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-53.1.21.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-53.1.21.el5 ro root=/dev/md3
initrd /initrd-2.6.18-53.1.21.el5.img


/boot/grub/menu.lst

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/md3
# initrd /initrd-version.img
#boot=/dev/md2
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-53.1.21.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-53.1.21.el5 ro root=/dev/md3
initrd /initrd-2.6.18-53.1.21.el5.img



/etc/fstab

/dev/md3 / ext3 defaults 1 1
/dev/md2 /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/md1 swap swap defaults 0 0

Last edited by ncsuapex; 02-10-2009 at 02:33 PM. Reason: new info
 
Old 02-11-2009, 10:44 AM   #11
mostlyharmless
Senior Member
 
Registered: Jan 2008
Distribution: Slackware -current (multilib) with kernel 3.16.2
Posts: 1,566
Blog Entries: 13

Rep: Reputation: 178Reputation: 178
Hmmm, now you've got me stumped. Looking at your screenshot, I focused on the message "Trying to resume from md1". Makes me wonder whether you needed to update mdadm.conf. I would suggest putting back the 1st IDE drive, which ought to let you boot again without error, notwithstanding having grub on the SATA drive too. Then make sure the array is synced and clean. You know, mdadm -D /dev/mdX

If everything looks good then try
mdadm -E -s >> /etc/mdadm.conf (or /etc/mdadm/mdadm.conf, or wherever CentOS stores it's mdadm.conf file.)

Last edited by mostlyharmless; 02-11-2009 at 10:45 AM. Reason: typo
 
Old 02-11-2009, 03:27 PM   #12
ncsuapex
Member
 
Registered: Dec 2004
Location: Raleigh, NC
Distribution: CentOS 2.6.18-53.1.4.el5
Posts: 770

Original Poster
Rep: Reputation: 43
After reading your last response I decided to start over again using the commands in my post #10, just to see what happens to the /etc/mdadm.conf file.
Once I reinstalled the OS with the RAID1 on the IDE drives I copied the /etc/mdadm.conf to mdadm.orig, the proceeded with the clone of the SATA drive After cloneing the SATA drive I checked the new mdadm.conf and it looked exactly like the mdadm.orig, I also check the output of mdadm -E -s and it was identical to the mdadm.conf. Not sure what all that means..

One other thing I have noticed is, after I cloned the new SATA drive, if I reboot using the original IDE drive as the master drive with the SATA as it's clone. It boots up fine but does not have the RAID active. But I can manually --add or -re-add(tried both ways and rebooted). Then if I reboot, same thing. The RAID is not active.

mdadm -D /dev/md2 showsthe all show this, just using md2 as the example)
State: clean, degraded

then under Number, Major, Minor, RAIDDevice State it has:
0 3 2 0 active sync /dev/hda1

1 0 0 1 removed


Then of course if I --add it back it shows /dev/sda1 in the 2nd column.

And of course when I boot up with the new SATA drive it fails, same kernel panic.

Once I clone the IDE to SATA, do I have to fail/break the array or tell the array that the SATA drive is the master or something?
 
Old 02-12-2009, 12:32 PM   #13
mostlyharmless
Senior Member
 
Registered: Jan 2008
Distribution: Slackware -current (multilib) with kernel 3.16.2
Posts: 1,566
Blog Entries: 13

Rep: Reputation: 178Reputation: 178
Well that's definitely the problem; you have to figure out why the SATA drive isn't staying in the array, because if it isn't, when you boot with only the SATA, you have no array.

I bet it's because the array gets initialized before the SATA drive is available. Unfortunately, if that's the case, you'll have to modify your initrd, which is pretty easy in Slackware, but I have no idea how it's done in CentOS. I suppose it is similar to Ubuntu; have to look it up...
 
Old 02-12-2009, 02:54 PM   #14
ncsuapex
Member
 
Registered: Dec 2004
Location: Raleigh, NC
Distribution: CentOS 2.6.18-53.1.4.el5
Posts: 770

Original Poster
Rep: Reputation: 43
ahhhhhhhh. That did it. I modified the initrd(pretty easy in CentOS as well) before I cloned and pretty much followed my other steps and it worked. Didn't even have to touch grub!


A THOUSAND thanks!
 
  


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
trying to clone a drive with RAID1. getting stuck at grub ncsuapex Linux - Software 0 02-03-2009 01:12 PM
Grub, RAID1 and a spare theooze Linux - General 3 10-15-2008 11:53 AM
RAID1 array down to one disk with bad blocks, clone to good disk with dd noerror? ewolf Linux - Server 2 05-10-2008 01:40 AM
RAID1 Set up using GRUB Bootloader mreeves Debian 4 03-14-2008 09:34 PM
SuSe 10 + GRUB + RAID1 questions TimBee Suse/Novell 5 12-22-2005 07:23 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration