You are not logged in.

#1 2011-02-13 06:53:42

DarksideEE7
Member
From: Arkansas, United States
Registered: 2009-06-06
Posts: 356

[SOLVED] Cloning boot and var partitions to a new drive for booting

Ok first of all here's my setup:
fakeraid (dmraid) / and home on an OCZ Revodrive
boot with GRUB on a flash drive (since fakeraid doesn't support grub)
var and downloads/media folder on a 500GB WD Caviar drive

When I originally installed Arch I had the Caviar drive in my home server in a RAID5 array, so that's why I opted to install boot and grub on a flash drive simply for booting.  Now that I have the drive in my desktop I've cloned the flash drive's partitions and MBR using dd:

#dd if=/dev/sde of=~/MBR.img bs=512 count=1
#dd if=/dev/sde1 of=~/boot.img
#dd if=/dev/sdc1 of=~/var.img

I then backed up my downloads/media partition, then removed the partition table, then used dd to put the img files on the Caviar drive.

#dd if=~/MBR.img of=/dev/sdc bs=512 count=1
#dd of=~/boot.img of=/dev/sdc1
#dd of=~/var.img of=/dev/sdc2

I also created labels for the filesystems and put those in fstab.
I'm able to mount both partitions, however I can't boot from the drive.  I get a 'grub hard disk error' (no error number) when I put it as my first drive in the BIOS. 

I can still use the flash drive as the first hard drive in the BIOS and boot from it, then it mounts the dmraid root partition and boots successfully.  It is also able to mount the var and boot partitions in fstab. 

Basically the only problem is that the MBR is somehow wrong.  I then tried booting back into an Arch live USB and installing GRUB from the prompt:

grub
grub>setup (hd4,0) (in this case the Caviar drive's boot partition was /dev/sde1

So essentially what I'm asking is how GRUB handles the MBR.  Is it specific to the partition table of the drive in which it resides when it's originally installed?  For instance, since I had an 8GB flash drive with 2 partitions when I installed GRUB, is the backed up MBR no good for a 500GB drive with 3 partitions?

I have everything backed up so I can start with a fresh /boot and /var if need be....I'm just not sure where to start. 

Thanks in advance.

Last edited by DarksideEE7 (2011-02-13 23:25:31)

Offline

#2 2011-02-13 13:06:05

mcsilva
Member
From: Portugal
Registered: 2009-12-16
Posts: 95

Re: [SOLVED] Cloning boot and var partitions to a new drive for booting

DarksideEE7 wrote:

boot with GRUB on a flash drive (since fakeraid doesn't support grub)

Sorry, but I do not agree with that!
I use dmraid with grub.
Just create a RAID1 /boot Raid Array and install grub in both disks.
We can discuss this later, if you want to do it.

I think the best way to copy data from a RAID Array is not using "dd" but other tools.
You should have copied from /dev/mdX and not /dev/sdX.
Also copying MBR from a disk with different partitions and cilinders does not work. You have to reinstall grub with "grub" command.
Don't forget also that you should configure BIOS setup to read the drive you want grub installed in the first place (or install grub in every disk).

If you need some more help please send me more information, like:
1 - Which disks and partitions you have (/dev/sda[1, 2], /dev/sdb[1,2,3], etc.)?
2 - Raid structure:
# cat /proc/mdstat
# fdisk -l
3 - Mounted partitions (/ = /dev/md0, /home = /dev/md1  or something similar)

Offline

#3 2011-02-13 22:15:41

DarksideEE7
Member
From: Arkansas, United States
Registered: 2009-06-06
Posts: 356

Re: [SOLVED] Cloning boot and var partitions to a new drive for booting

Sorry, I forgot to mention that I tried to install GRUB from the GRUB shell in a live Arch USB.  It failed on a few non-critical parts, and succeeded on the last part. I'm going to try again shortly, possibly I did something wrong.  GRUB is able to find the stage files using:

#grub
grub>find /grub/stage1
grub> find /grub/stage1
 (hd0,0)
 (hd5,0)

grub>

(hd0,0) is the desired boot drive, while (hd5,0) is the current bootable flash drive with /boot and GRUB installed.

Here is the output of fdisk -l:

WARNING: GPT (GUID Partition Table) detected on '/dev/sde'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sde: 2000.4 GB, 2000398934016 bytes
256 heads, 63 sectors/track, 242251 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1  3907029167  1953514583+  ee  GPT

Disk /dev/sdb: 60.0 GB, 60022480896 bytes
255 heads, 63 sectors/track, 7297 cylinders, total 117231408 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xedb72db9

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048      206847      102400    7  HPFS/NTFS
/dev/sdb2          206848   117227519    58510336    7  HPFS/NTFS

Disk /dev/sdd: 40.0 GB, 40018599936 bytes
255 heads, 63 sectors/track, 4865 cylinders, total 78161328 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdd doesn't contain a valid partition table

Disk /dev/sdc: 40.0 GB, 40018599936 bytes
32 heads, 32 sectors/track, 76329 cylinders, total 78161328 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb8372fcd

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1              32    21484543    10742256   83  Linux
/dev/sdc2        21484544   156317695    67416576   83  Linux

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x8497e059

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      206847      102400   83  Linux
/dev/sda2          206848    42149887    20971520   83  Linux
/dev/sda3        42149888   976773167   467311640   83  Linux

Disk /dev/dm-0: 80.0 GB, 80035053568 bytes
32 heads, 32 sectors/track, 152654 cylinders, total 156318464 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 65536 bytes / 131072 bytes
Disk identifier: 0xb8372fcd

     Device Boot      Start         End      Blocks   Id  System
/dev/dm-0p1              32    21484543    10742256   83  Linux
Partition 1 does not start on physical sector boundary.
/dev/dm-0p2        21484544   156317695    67416576   83  Linux

Disk /dev/dm-1: 11.0 GB, 11000070144 bytes
255 heads, 63 sectors/track, 1337 cylinders, total 21484512 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 65536 bytes / 131072 bytes
Alignment offset: 49152 bytes
Disk identifier: 0x00000000

Disk /dev/dm-1 doesn't contain a valid partition table

Disk /dev/dm-2: 69.0 GB, 69034573824 bytes
255 heads, 63 sectors/track, 8392 cylinders, total 134833152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 65536 bytes / 131072 bytes
Disk identifier: 0x00000000

Disk /dev/dm-2 doesn't contain a valid partition table

Disk /dev/sdf: 8086 MB, 8086618112 bytes
249 heads, 62 sectors/track, 1023 cylinders, total 15794176 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x8497e059

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1   *          62      200693      100316   83  Linux
/dev/sdf2          200694    15794175     7796741   83  Linux

I'm using dmraid, so just to be clear I've configured the raid using:

#modprobe dm_mod
#dmraid -ay

Then I saw the array stored in /dev/mapper/silXXXXX.  I then created partitions for /boot, /, and home.  At that time I was hoping to get GRUB working with the AUR package grub2-dmraid.  I wasn't able to get it working for some time, so I just went ahead and installed boot and GRUB to a separate USB flash drive.

Here is the output of df -h:

Filesystem            Size  Used Avail Use% Mounted on
udev                   10M  268K  9.8M   3% /dev
/dev/mapper/sil_bgbgdjaddicbp1
                       11G  5.3G  4.3G  56% /
shm                   6.0G  584K  6.0G   1% /dev/shm
/dev/mapper/sil_bgbgdjaddicbp2
                       64G   38G   23G  63% /home
/dev/sda1              95M   16M   75M  18% /boot
/dev/sda2              19G  142M   19G   1% /var
/dev/sda3             439G  148G  269G  36% /home/l33/Torrents
none                 1000M  132K 1000M   1% /tmp
shm                   6.0G  584K  6.0G   1% /dev/shm
/dev/sde1             1.8T  1.1T  665G  62% /mnt/Green

and cat /etc/mtab

proc /proc proc rw,nosuid,nodev,noexec,relatime
sys /sys sysfs rw,nosuid,nodev,noexec,relatime
udev /dev devtmpfs rw,nosuid,relatime,size=10240k,nr_inodes=1022975,mode=755
/dev/mapper/sil_bgbgdjaddicbp1 / ext4 rw,noatime,barrier=1,stripe=32,data=ordered
devpts /dev/pts devpts rw 0 0
shm /dev/shm tmpfs rw,nosuid,nodev 0 0
/dev/mapper/sil_bgbgdjaddicbp2 /home ext4 rw,noatime 0 0
/dev/sda1 /boot ext2 rw 0 0
/dev/sda2 /var reiserfs rw,noatime 0 0
/dev/sda3 /home/l33/Torrents ext4 rw,noatime 0 0
none /tmp tmpfs rw,nosuid,nodev,noatime,size=1000M,mode=1777 0 0
shm /dev/shm tmpfs rw,nosuid,nodev,size=6G 0 0
rpc_pipefs /var/lib/nfs/rpc_pipefs rpc_pipefs rw 0 0
nfsd /proc/fs/nfsd nfsd rw,noexec,nosuid,nodev 0 0
/dev/sde1 /mnt/Green ext4 rw 0 0

Also I don't have a /proc/mdstat.  That's only for mdadm RAID setups, right?  It's been quite some time since I've used mdadm so I can't remember.

EDIT:

So I booted into a live Arch USB and entered the grub shell.  I ran:

#grub
grub> root (hd3,0)
Filesystem type is ext2fs, partition type 0x83
grub> setup (hd3)
Checking if "/boot/grub/stage1" exists.....no
Checking if "/grub/stage1 exists.......yes
Checking if "/grub/stage2 exists.......yes
Checking if "/grub/e2fs_stage1_5 exists....yes
Running "embed /grub/e2fs_stage1_5 (hd3)".....25 sectors are embedded.
succeeded
Running "install /grub/stage1 (hd3) (hd3))1+25 p (hd3,0)/grub/stage2 /grub/menu.lst".......succeeded
Done.

Last time I recall more errors than this, then it reporting that one was a non-critical error, so I think the problem may be solved.  More to come.

Last edited by DarksideEE7 (2011-02-13 23:18:44)

Offline

#4 2011-02-13 23:25:11

DarksideEE7
Member
From: Arkansas, United States
Registered: 2009-06-06
Posts: 356

Re: [SOLVED] Cloning boot and var partitions to a new drive for booting

All right that fixed it.  What I was doing wrong was not changing menu.lst to reflect the correct root device for grub.  I had it still as (hd0,0), which was the boot order that my flash drive was located.  I set it to (hd3,0), installed grub, then rebooted, changed the BIOS back to the GRUB drive as the first device (which is what it normally is), then edited the grub entry by pressing 'e' on the grub menu. 

Now I just have to edit /boot/grub/menu.lst to reflect (hd0,0) so the changes are permanent.


I guess my problem stemmed from the fact that I read that a grub MBR could be cloned from a hard drive with a different size and partition table, when in fact this is wrong.  That's what I get for reading some random guide :\.

I may add some info to the wiki because this isn't explicitly stated there, and in fact the info is quite scarce on the exact requirements for GRUB when searching.

Offline

Board footer

Powered by FluxBB