LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices

Reply
 
Search this Thread
Old 09-04-2012, 02:56 PM   #1
patmicom
LQ Newbie
 
Registered: Sep 2012
Posts: 4

Rep: Reputation: Disabled
Selecting boot drive after cloning with dd


I have two questions that I think are related to each other. Both questions have to do with copying a SATA drive and making it the boot device. I am copying a disk with "dd" and attempting to boot off the first drive. Detailed questions at bottom. (Redhat v6)

1) backup sda to sdb (Both Western Digital 2.0TB, SATA Drives)
dd if=/dev/sda of=/dev/sdb

2) reboot system, When both drives are in always boots off 2nd drive /dev/sdb

3) Output of df -k

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_mast4-lv_root
51606140 13130136 35854564 27% /
tmpfs 4052108 272 4051836 1% /dev/shm
/dev/sdb1 495844 244471 225773 52% /boot
/dev/mapper/vg_mast4-lv_home
1860635512 16287164 1749833560 1% /home
/dev/sr0 2704778 2704778 0 100% /media/K3b data project

Questions:
#1) When both SATA drives are in, it skips the first drive /dev/sda and boots from /dev/sdb. How can I always force the system to always boot from the first drive? The only way I have found is to pull the second drive and the system will boot from first drive /dev/sda. I have tried setting the hardware boot prom to change the boot order to no success.

#2) The SATA harddrives are the same make/model/size. When I use "dd if=/dev/sda of=/dev/sdb" I thought I was making a sector for sector copy. However, the first drive "sda" will only boot when in the first slot and the second drive will only boot when in the second slot. After making a sector for sector copy why are the drives slot dependant?

Thanks,
 
Old 09-04-2012, 06:16 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 11,900

Rep: Reputation: 746Reputation: 746Reputation: 746Reputation: 746Reputation: 746Reputation: 746Reputation: 746
Welcome to LinuxQuestions.

When a drive is cloned everything is duplicated i.e. VG names, filesystem UUIDs etc. With duplicate names I would guess it depends on how grubs picks which root LV and / to use. Take a look at the output of the dmesg command. It might provide some clues.

Changing names should fix the problem.

Last edited by michaelk; 09-04-2012 at 06:17 PM.
 
Old 09-04-2012, 07:31 PM   #3
KenJackson
Member
 
Registered: Jul 2006
Location: Maryland, USA
Distribution: Fedora, Arch
Posts: 572

Rep: Reputation: 64
Quote:
Originally Posted by michaelk View Post
When a drive is cloned everything is duplicated ..., filesystem UUIDs ...
Ah! That makes sense. And if that's the problem, then you can fix it with the tune2fs command. (That is, assuming the file system is ext2, ext3 or ext4. It probably is unless you explicitly chose something else.)

Maybe something like this:

tune2fs -L <new-label-1> -U random /dev/sdb1
tune2fs -L <new-label-2> -U random /dev/sdb2
tune2fs -L <new-label-3> -U random /dev/sdb3

See man tune2fs for more.

Also note that once you've assigned unique UUIDs you can edit /etc/fstab to reference the UUID instead of the device. Then it won't matter which device letter gets assigned.
 
Old 09-04-2012, 08:52 PM   #4
jefro
Guru
 
Registered: Mar 2008
Posts: 11,549

Rep: Reputation: 1405Reputation: 1405Reputation: 1405Reputation: 1405Reputation: 1405Reputation: 1405Reputation: 1405Reputation: 1405Reputation: 1405Reputation: 1405
Also might be a bios issue.
 
Old 09-04-2012, 09:06 PM   #5
purevw
Member
 
Registered: Jan 2007
Location: Texas
Distribution: OpenSuSE 13, Kernel 3.13.3
Posts: 88

Rep: Reputation: 43
Just out of curiosity, how is your BIOS set up as far as boot order is concerned? Is it possible that BIOS is choosing sdb as a first boot device when both are there and only chooses sda when sdb is not available? If I connect my phone by USB before I boot, BIOS warns me that boot devices have changed. If I press "F1" to ignore, the system is unable to find grub and I have to reboot.
 
Old 09-05-2012, 03:39 AM   #6
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,665

Rep: Reputation: Disabled
There might be something like /boot/grub/device.map on your disk (depending from the version of GRUB you are using and whether that deemed a map file necessary). It contains assignments of your disks for GRUB. You might experiment with that.
 
Old 09-05-2012, 08:48 AM   #7
geox
Member
 
Registered: Jan 2012
Posts: 40

Rep: Reputation: 2
As michaelk suggested, look at dmesg. The boot code is smart enough to figure out they are not actually the same disks so it assigns them different ID's (like HD0 and HD1). That is why is seems the drives are location dependant but all you have to do is go into the grub command line and redetect the proper disk.

I wouldn't worry too much about this. dd does make a bit-for-bit copy but sometimes the BIOS and grub can do funny things to booting up your system. In fact, i am positive that you would find tiny differences between the two disks as simply booting up changes files.

I have used dd many times and never did it fail on me. If you are not certain you could do a diff on both drives for the important dirs (easiest is to use rsync with the -n switch for that; rsync -av -n /dev/sda1 /dev/sdb1)
 
Old 09-06-2012, 12:14 AM   #8
kostya
Member
 
Registered: Mar 2010
Location: Moscow, Russia
Distribution: Ubuntu Studio, antix(mepis), Fedora, FreeBSD
Posts: 172
Blog Entries: 5

Rep: Reputation: 17
Quote:
How can I always force the system to always boot from the first drive?
It must be set via BIOS, where you have in BOOT section a subsection "boot device priority".
Make sure your SECOND drive is set up as first boot device.
Perhaps, where you insert your second drive is actually the 1st SATA port, while your "first" drive was originally inserted into the 2nd one. That's the only possible explanation, except if by "IT boots off" you mean your GRUB bootloader.

Last edited by kostya; 09-06-2012 at 12:17 AM.
 
1 members found this post helpful.
Old 09-08-2012, 11:31 AM   #9
cesarbergara
LQ Newbie
 
Registered: Feb 2012
Location: Buenos Aires, Argentina
Distribution: Debian, Suse, Mandrake,
Posts: 8

Rep: Reputation: Disabled
Hi. You should use blkid command to show you new block names (in the new device). Then, choose in /etc/fstab the new blkid for each device (for sda1, sdb1, etc). Second: choose in grub the new id names and run: grub-install /dev/sda (or /dev/sdb). Pull out (or not) the old device, and restart. I wish this explanation will useful.
Have a nice day.
 
  


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
Cloning a drive with dd scandalist Linux - Newbie 19 06-25-2012 08:06 PM
Just Finished Cloning my Dual Boot Setup, but Linux OS won't boot kuyalfinator Linux - Virtualization and Cloud 8 03-07-2011 11:38 PM
Cloning dual-boot drive onto a smaller drive. Harju Linux - Newbie 4 05-29-2010 11:40 AM
cloning a drive with dd gdanko Linux - General 3 01-20-2010 01:11 PM
Need help in cloning drive raddad51x Fedora 1 05-16-2006 01:31 AM


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

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