Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Try to copy a linux&xp to a different hard drive.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
penright
n00b
n00b


Joined: 17 Aug 2005
Posts: 10

PostPosted: Wed Aug 17, 2005 1:17 am    Post subject: Try to copy a linux&xp to a different hard drive. Reply with quote

This maybe a hard question to bottom line, but here we go. I need to set the stage before I ask the question. I have a dual boot system. The first gig is for linux. The rest of the hard drive is for windows xp. The reason is so I can boot into linux and fix windows registery and such. There is a second harddrive that is a backup to the first(same partions). I have a bootable cd for linux and a script to bring a new hard drive in sync with the first. Basically the script repartions the new hard drive, then partimage puts down a blank linux and xp image, and then using rsync copies data to the new one. I can not get this to work with 60gig hard drive. These were IBM NetVistas and had 40 gig hard drives. I can go from 40 gig to 40 gig no problem. The new one boots. In fact I can go from 40 gig to 60 gig. The 60 will not boot. Then from the same 60 gig back to a 40 gig and it boots. I am suspecting there is a difference in the geometry and the MBR. Now the MBR comes from the blank partimage file.

When windows does not boot I get no error it just stops after the chain loader prompt.

Booting 'Windows'
rootnoverify (hd0,1)
chainloader +1 <--- Stops here


Any thoughts on fixing the MBR (Fixmbr from the xp recovery disk does not help)
Any thoughts on what could be the problem?


P.S.
My grub.conf
default 1
timeout 3
splashimage=(hd0,0)/boot/grub/splash.xpm.gz

title=System Restore
root (hd0,0)
kernel (hd0,0)/boot/kernel-2.4.24-xfs-r3 root=/dev/ram0 init=/linuxrc real_root=/dev/hda1 splash=silent
initrd (hd0,0)/boot/initrd-2.4.24-xfs-r3

title=Windows
rootnoverify (hd0,1)
chainloader +1
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Wed Aug 17, 2005 6:26 am    Post subject: Reply with quote

Yes, the 60 GB Disk has another geometry (and another 40 GB from another Vendor will probably have too). The Problem with Windows is, that its Partition handling depends on the Harddisk Geometry! Unlike the Linux fdisk, which can create partitions down to Block size (512 Bytes), Windows partitions are a bit more restricted. So if you create a partition on another drive you will have to make sure the (at least the boot and system) partition has a recognized geometry.

Sadly this prevents any type of dd copying, but your rsync process should work.
Back to top
View user's profile Send private message
adnoh
Tux's lil' helper
Tux's lil' helper


Joined: 21 Jul 2005
Posts: 120

PostPosted: Wed Aug 17, 2005 6:33 am    Post subject: Reply with quote

do a windows repair setup ... maybe it helps.
this works for me when I have duplicated a system with different HAL and I only got a blue screen "inaccessible boot device".
If it doesn't work on the first time give it a second or third try - yes, often you can persuade windows :lol:
_________________
the german dude with the broken english
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Wed Aug 17, 2005 11:12 am    Post subject: Reply with quote

This helps if you changed your mainboard and therefore the IDE Controller. But when you only change harddisks the new Windows will have the same problems reading the partition.
Back to top
View user's profile Send private message
penright
n00b
n00b


Joined: 17 Aug 2005
Posts: 10

PostPosted: Wed Aug 17, 2005 12:51 pm    Post subject: Reply with quote

Just in case it is a clue, I am going to post the script that I use. First in the post will be what I think is relevant, then at the bottom of the post I will post the whole script in case needed for reference. Remember there are two partitions (linux then xp).
Some definitions:
blankxp.000 = partimage of a working xp image that everything has been deleted.
Blankgentoo = partimage of a working linux that everything was deleted.

The assumption is /dev/had is the source. Because of different hardware we have to find the destination hard drive device (/dev/?). One found ‘$SECONDDRIVE’ is loaded with it.
So all partitions are removed from ‘$SECONDDRIVE’
The linux and a known sized xp partitions are created.
Partimage lays down the blank ones.
Then the xp partition is resized to the rest of the disk.
The $SECONDDRIVE linux and xp partitions are mounted.
Then source linux is rsync to destination linux, it is the same for xp.

Pertinent code
Code:

   sfdisk -R /dev/$SECONDDRIVE
   echo unmounting /dev/"$SECONDDRIVE"1
   umount /dev/"$SECONDDRIVE"1
   echo unmounting /dev/"$SECONDDRIVE"2
   umount /dev/"$SECONDDRIVE"2
   echo unmounting /dev/"$SECONDDRIVE"3
   umount /dev/"$SECONDDRIVE"3
   umount /mnt/windows/c
   umount /mnt/windows/d
   sfdisk -ls /dev/$SECONDDRIVE| grep /dev/"$SECONDDRIVE"1 > /root/hdcmap
   sfdisk /dev/$SECONDDRIVE << EOF
0,
;
;
;
EOF
   parted --script /dev/$SECONDDRIVE rm 2
   parted --script /dev/$SECONDDRIVE rm 1
   echo Creating /dev/"$SECONDDRIVE"1
   parted --script /dev/$SECONDDRIVE mkpart primary ext3 0 1027.959
   echo Turning off boot flag on /dev/"$SECONDDRIVE"1
   cat /proc/partitions | grep -w $SECONDDRIVE > /root/"$SECONDDRIVE".prop
   export ENDOF2=`awk '{print $3}' /root/"$SECONDDRIVE".prop`
   export ENDOF2=$[$ENDOF2/1024]
   echo Creating /dev/"$SECONDDRIVE"2
   parted --script /dev/$SECONDDRIVE mkpart primary FAT 1027.959 6147.959
   sleep 5s
   echo Turning on boot flag on /dev/"$SECONDDRIVE"2
   parted --script /dev/$SECONDDRIVE set 2 boot on
#   sfdisk /dev/hda < hda.out
   sfdisk -R /dev/$SECONDDRIVE
   sleep 5s
#   partimage -bf3 restore /dev/"$SECONDDRIVE"2 /mnt/images/blankxp.000
#   partimage -bf3 restore /dev/"$SECONDDRIVE"1 /mnt/images/blankgentoo.000
   partimage -bf3 restore /dev/"$SECONDDRIVE"2 /cdrom/blankxp.000
   partimage -bf3 restore /dev/"$SECONDDRIVE"1 /cdrom/blankgentoo.000
   sfdisk -R /dev/$SECONDDRIVE
   echo Resizing second partition
   parted --script /dev/$SECONDDRIVE resize 2 1027.959 $ENDOF2
   sfdisk -l
   echo Begin to Copy Windows Partition This will take a while
   #parted --script /dev/$SECONDDRIVE cp /dev/$FIRSTDRIVE 2 2
   mount /dev/"$FIRSTDRIVE"2 /mnt/windows/c
   mount /dev/"$SECONDDRIVE"2 /mnt/windows/d
   rm -f /mnt/windows/c/pagefile.sys
   rm -fR /mnt/windows/c/windows/system32/dllcache/*
   rm -fR /mnt/windows/c/Recycled/*
   rsync -av /mnt/windows/c/ /mnt/windows/d/
   mkdir /mnt/gentoo1
   mkdir /mnt/gentoo2
   mount /dev/"$SECONDDRIVE"1 /mnt/gentoo2
   mount /dev/"$FIRSTDRIVE"1 /mnt/gentoo1
   echo Begin to Copy Linux Partition This will take a while
   rsync -av --delete --exclude=/usr/portage /mnt/gentoo1/ /mnt/gentoo2/
   echo Now Grubbing both harddrives
   echo UnMounting /dev/"$FIRSTDRIVE"1
   umount /dev/"$FIRSTDRIVE"1
   echo UnMounting /dev/"$FIRSTDRIVE"2
   umount /dev/"$FIRSTDRIVE"2
   echo UnMounting /dev/"$SECONDDRIVE"1
   umount /dev/"$SECONDDRIVE"1
   echo UnMounting /dev/"$SECONDDRIVE"2
   umount /dev/"$SECONDDRIVE"2
   ./BrGrubHD2



The whole script for referance. I may have to explain why on some parts.

Code:

#!/bin/bash
PATH=$PATH:/etc/Braums/scripts:/mnt/tech
LAPTOPIP=`GetLapIP.py`
echo "LapTopIP=$LAPTOPIP"
FindDrive()
{
   #test /dev/hda harddrive 4 parts
   disktype /dev/$1 2>/dev/null| grep 'GiB' > /root/$1.size
    export `echo $1|tr a-z A-Z`SIZE=`awk '{print $4}' /root/$1.size`
}
FindRegType()
{
   #test /dev/hda harddrive 4 parts
   disktype /dev/$12 2>/dev/null| grep 'GiB' > /root/$12.type
    export `echo $1|tr a-z A-Z`2TYPE=`awk '{print $4}' /root/$12.type`
}


#Braums Installation Script
echo Begin Harddrive detection

FindDrive hda
FindDrive hdb
FindDrive hdc
FindDrive hdd
sleep 5s
echo hda $HDASIZE
echo hdb $HDBSIZE
echo hdc $HDCSIZE
echo hdd $HDDSIZE

#1st drive is pre install
FIRSTDRIVE=hda
if test "$HDBSIZE" != ""; then
   SECONDDRIVE=hdb
fi
if test "$HDCSIZE" != ""; then
   SECONDDRIVE=hdc
fi
if test "$HDDSIZE" != ""; then
   SECONDDRIVE=hdd
fi
mount -t vfat /dev/"$FIRSTDRIVE"2 /mnt/windows/c
if test -e "/mnt/windows/c/Program Files/Microsoft SQL Server/mssql/Data/IRIS_Data.mdf"; then
   echo "IBM SQL DATA EXISTS!"
   export REGTYPE=IBM
else
   if test -e "/mnt/windows/c/winnt/micros.ini"; then
      echo "MICROS.INI EXISTS!"
      export REGTYPE=MICROS
   else
      echo "NO IBM DATABASE OR MICROS.INI = TROUBLE, EXITING!!!"
      exit
   fi
fi

echo regtype is $REGTYPE firstdrive is $FIRSTDRIVE second drive is $SECONDDRIVE
if test $REGTYPE == "MICROS"; then
   echo micros -- here we go
   sfdisk -R /dev/$SECONDDRIVE
   echo unmounting /dev/"$SECONDDRIVE"1
   umount /dev/"$SECONDDRIVE"1
   echo unmounting /dev/"$SECONDDRIVE"2
   umount /dev/"$SECONDDRIVE"2
   echo unmounting /dev/"$SECONDDRIVE"3
   umount /dev/"$SECONDDRIVE"3
   sfdisk -ls /dev/$SECONDDRIVE| grep /dev/"$SECONDDRIVE"1 > /root/hdcmap
   parted --script /dev/$SECONDDRIVE rm 1
   parted --script /dev/$SECONDDRIVE rm 2
   parted --script /dev/$SECONDDRIVE rm 3
   echo Creating /dev/"$SECONDDRIVE"1
   parted --script /dev/$SECONDDRIVE mkpartfs primary ext2 0.031 4094.692
   echo Turning off boot flag on /dev/"$SECONDDRIVE"1
   parted --script /dev/$SECONDDRIVE set 1 boot off
   echo Creating /dev/"$SECONDDRIVE"2
   parted --script /dev/$SECONDDRIVE mkpartfs primary FAT 4094.692 8189.384
   echo Turning on boot flag on /dev/"$SECONDDRIVE"2
   parted --script /dev/$SECONDDRIVE set 2 boot on
   echo Creating /dev/"$SECONDDRIVE"3
   parted --script /dev/$SECONDDRIVE mkpartfs primary FAT 8189.385 12284.077
   sfdisk -R /dev/$SECONDDRIVE
   echo Begin to Copy Windows Partition This will take a while
   #parted --script /dev/$SECONDDRIVE cp /dev/$FIRSTDRIVE 2 2
   #parted --script /dev/$SECONDDRIVE cp /dev/$FIRSTDRIVE 3 3
   partimage -bf3 restore /dev/"$SECONDDRIVE"2 /mnt/images/blankmicros.000
   sfdisk -R /dev/$SECONDDRIVE
   mount /dev/"$SECONDDRIVE"2 /mnt/windows/d
   mount /dev/"$FIRSTDRIVE"2 /mnt/windows/c
#   rsync -av /mnt/windows/c/ /mnt/windows/d/
   mkdir /mnt/gentoo1
   mkdir /mnt/gentoo2
   mount /dev/"$SECONDDRIVE"1 /mnt/gentoo2
   mount /dev/"$FIRSTDRIVE"1 /mnt/gentoo1
   echo Begin to Copy Linux Partition This will take a while
   rsync -av --delete --exclude=/usr/portage /mnt/gentoo1/ /mnt/gentoo2/
   echo Now Grubbing both harddrives
   echo UnMounting /dev/"$FIRSTDRIVE"1
   umount /dev/"$FIRSTDRIVE"1
   echo UnMounting /dev/"$FIRSTDRIVE"2
   umount /dev/"$FIRSTDRIVE"2
   echo UnMounting /dev/"$FIRSTDRIVE"3
   umount /dev/"$FIRSTDRIVE"3
   echo UnMounting /dev/"$SECONDDRIVE"1
   umount /dev/"$SECONDDRIVE"1
   echo UnMounting /dev/"$SECONDDRIVE"2
   umount /dev/"$SECONDDRIVE"2
   echo UnMounting /dev/"$SECONDDRIVE"3
   umount /dev/"$SECONDDRIVE"3
   mkfs.msdos -n 2 /dev/"$SECONDDRIVE"3
   ./BrGrub
fi
if test $REGTYPE == "IBM"; then
   echo ibm -- here we go
   sfdisk -R /dev/$SECONDDRIVE
   echo unmounting /dev/"$SECONDDRIVE"1
   umount /dev/"$SECONDDRIVE"1
   echo unmounting /dev/"$SECONDDRIVE"2
   umount /dev/"$SECONDDRIVE"2
   echo unmounting /dev/"$SECONDDRIVE"3
   umount /dev/"$SECONDDRIVE"3
   umount /mnt/windows/c
   umount /mnt/windows/d
   sfdisk -ls /dev/$SECONDDRIVE| grep /dev/"$SECONDDRIVE"1 > /root/hdcmap
   sfdisk /dev/$SECONDDRIVE << EOF
0,
;
;
;
EOF
   parted --script /dev/$SECONDDRIVE rm 2
   parted --script /dev/$SECONDDRIVE rm 1
   echo Creating /dev/"$SECONDDRIVE"1
   parted --script /dev/$SECONDDRIVE mkpart primary ext3 0 1027.959
   echo Turning off boot flag on /dev/"$SECONDDRIVE"1
   cat /proc/partitions | grep -w $SECONDDRIVE > /root/"$SECONDDRIVE".prop
   export ENDOF2=`awk '{print $3}' /root/"$SECONDDRIVE".prop`
   export ENDOF2=$[$ENDOF2/1024]
   echo Creating /dev/"$SECONDDRIVE"2
   parted --script /dev/$SECONDDRIVE mkpart primary FAT 1027.959 6147.959
   sleep 5s
   echo Turning on boot flag on /dev/"$SECONDDRIVE"2
   parted --script /dev/$SECONDDRIVE set 2 boot on
#   sfdisk /dev/hda < hda.out
   sfdisk -R /dev/$SECONDDRIVE
   sleep 5s
#   partimage -bf3 restore /dev/"$SECONDDRIVE"2 /mnt/images/blankxp.000
#   partimage -bf3 restore /dev/"$SECONDDRIVE"1 /mnt/images/blankgentoo.000
   partimage -bf3 restore /dev/"$SECONDDRIVE"2 /cdrom/blankxp.000
   partimage -bf3 restore /dev/"$SECONDDRIVE"1 /cdrom/blankgentoo.000
   sfdisk -R /dev/$SECONDDRIVE
   echo Resizing second partition
   parted --script /dev/$SECONDDRIVE resize 2 1027.959 $ENDOF2
   sfdisk -l
   echo Begin to Copy Windows Partition This will take a while
   #parted --script /dev/$SECONDDRIVE cp /dev/$FIRSTDRIVE 2 2
   mount /dev/"$FIRSTDRIVE"2 /mnt/windows/c
   mount /dev/"$SECONDDRIVE"2 /mnt/windows/d
   rm -f /mnt/windows/c/pagefile.sys
   rm -fR /mnt/windows/c/windows/system32/dllcache/*
   rm -fR /mnt/windows/c/Recycled/*
   rsync -av /mnt/windows/c/ /mnt/windows/d/
   mkdir /mnt/gentoo1
   mkdir /mnt/gentoo2
   mount /dev/"$SECONDDRIVE"1 /mnt/gentoo2
   mount /dev/"$FIRSTDRIVE"1 /mnt/gentoo1
   echo Begin to Copy Linux Partition This will take a while
   rsync -av --delete --exclude=/usr/portage /mnt/gentoo1/ /mnt/gentoo2/
   echo Now Grubbing both harddrives
   echo UnMounting /dev/"$FIRSTDRIVE"1
   umount /dev/"$FIRSTDRIVE"1
   echo UnMounting /dev/"$FIRSTDRIVE"2
   umount /dev/"$FIRSTDRIVE"2
   echo UnMounting /dev/"$SECONDDRIVE"1
   umount /dev/"$SECONDDRIVE"1
   echo UnMounting /dev/"$SECONDDRIVE"2
   umount /dev/"$SECONDDRIVE"2
   ./BrGrubHD2
fi

Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Thu Aug 18, 2005 6:34 am    Post subject: Reply with quote

For the script to work on a disk with other geometry I would leave the partitioning out of the backup script.

Create the Partitions on the backup disk under Windows. Then you can reformat them in the script and use rsync to create a exact copy of all the userland data.

Maybe you will have to do a rescue install of your Windows on the backup disk once to make it bootable (don't know if you can make rsync duplicate the boot sector of a partition) and do a "fdisk /MBR" from a dos bootdisk or "fixmbr" on the Windows XP rescue console (this requires the backup drive to be the first disk AFAIK)
Back to top
View user's profile Send private message
penright
n00b
n00b


Joined: 17 Aug 2005
Posts: 10

PostPosted: Thu Aug 18, 2005 1:12 pm    Post subject: Reply with quote

I guess I left off one small detail, the goal. I have these in over 280 remote locations that are serviced by a third party Service Company. Up until this geometry issue there was a bootable knoppix CD. Then the tech could replace the hard drive and run this script. The goal is to make if fool proof and repeatable. That’s why when I hit geometry thing I am spending the time that I am. I hate magic. If it is just you then you can live with magic, but you throw in about 20 other guys (the Service Company), it can be a killer.

Any way I was hoping there was a silver bullet. Maybe a GNU ghost product. The issue is not licensing,, it is Ghost does not handle grub boot very well. After the Ghost you can re-grub, but again the goal is to make it as much as one step as possible. I guess I wish that partimage would fix the MBR when making a fat32 partion.

Any way, enough rambles for now.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum