Grub and MBR manipulation question

Posted by OuldeFauder on 2011/11/19 4:17:34
I have a machine that I would like to use for testing. Elrepo kernels etc. To do this I will use several drives on the same machine, using DD (dcfldd) to reinstall any system that gets messed up. Replication the complete drive with DD causes it to boot the drive that you IF from and if that is a failed system your only option is to reinstall Centos as the MBR is copied from the source drive which points back to the original source drive. I have tried changes to grub but I always end up with booting the failed the system. My bios allows for selecting the drive to boot from but the MBR for that drive which is the drive which has been DD'ed from the source by DD so if you boot sdb it will actually end up running sda, the failed system. Grub lists the drives as HD0, HD1, etc but Centos disk utility list drives as sda etc. What is the correlation? Can this be done with grub or is the MBR so completely separate that this is not possible? Can the MBR be changed without the use of assembler, C++ etc? I would like to "DD if =/dev/sda of=/dev/sdb bs 4096 conv=notrun,noerror" and if a problem ocuurs after changes to sda boot sdb and do" DD if /dev/sdb of=//dev/sda bs=4096 conv=notrun,noerror" after telling my bios to boot sdb which I can do from the bios boot menu. In other words, I boot to sda and get a failure, I reboot to sdb and from Centos run DD, then boot to a now working sda. getinfo.sh disk as follows.



Information for disk problems.
== BEGIN uname -rmi ==
2.6.32-71.29.1.el6.x86_64 x86_64 x86_64
== END   uname -rmi ==

== BEGIN rpm -qa \*-release\* ==
rpmforge-release-0.5.2-2.el6.rf.x86_64
centos-release-6-0.el6.centos.5.x86_64
elrepo-release-6-4.el6.elrepo.noarch
adobe-release-x86_64-1.0-1.noarch
== END   rpm -qa \*-release\* ==

== BEGIN cat /etc/redhat-release ==
CentOS Linux release 6.0 (Final)
== END   cat /etc/redhat-release ==

== BEGIN getenforce ==
Enforcing
== END   getenforce ==

== BEGIN free -m ==
             total       used       free     shared    buffers     cached
Mem:          1878        689       1188          0         29        298
-/+ buffers/cache:        362       1515
Swap:         3775          0       3775
== END   free -m ==

== BEGIN cat /etc/fstab ==

#
# /etc/fstab
# Created by anaconda on Thu Nov 17 22:08:04 2011
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vg_alice-lv_root /                       ext4    defaults        1 1
UUID=f03b9fef-ff56-4377-b43c-bac3520bf4e0 /boot                   ext4    defaults        1 2
/dev/mapper/vg_alice-lv_home /home                   ext4    defaults        1 2
/dev/mapper/vg_alice-lv_swap swap                    swap    defaults        0 0
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
== END   cat /etc/fstab ==

== BEGIN df -h ==
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_alice-lv_root
                       50G  4.2G   43G   9% /
tmpfs                 940M  100K  939M   1% /dev/shm
/dev/sdc1             485M   50M  411M  11% /boot
/dev/mapper/vg_alice-lv_home
                       21G  172M   19G   1% /home
== END   df -h ==

== BEGIN fdisk -l ==
Disk /dev/sda doesn't contain a valid partition table
Disk /dev/dm-0 doesn't contain a valid partition table
Disk /dev/dm-1 doesn't contain a valid partition table
Disk /dev/dm-2 doesn't contain a valid partition table

Disk /dev/sda: 799.9 GB, 799937658880 bytes
255 heads, 63 sectors/track, 97253 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/sdb: 250.1 GB, 250059350016 bytes
91 heads, 10 sectors/track, 536700 cylinders
Units = cylinders of 910 * 512 = 465920 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001589b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           3      536700   244197376    7  HPFS/NTFS

Disk /dev/sdc: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d406e

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sdc2              64        9730    77637632   8e  Linux LVM

Disk /dev/sdd: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00084381

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sdd2              64       38914   312057856   8e  Linux LVM
Partition 2 does not end on cylinder boundary.

This Post was from: https://www.centos.org/newbb/viewtopic.php?forum=57&topic_id=34314&post_id=147500