1830315 Members
2492 Online
110000 Solutions
New Discussion

boot disk substituition

 
SOLVED
Go to solution
Claudio Cilloni
Honored Contributor

boot disk substituition

Hi all.

I got a linux box with 2 ide disks, hda and hdb.
the boot disk (hda) is giving some signals of an imminent mechanical failure (sometimes I hear strange noises from it). But it is still working.

I'm thinking to bring the whole linux system on hdb, connect it as primary master and then boot from it. the old broken hda will become the new hdb... and then I'll wait for its death :-)

How can I do this? I want to keep this working linux without reinstallation.
Eventually I can connect these disks (one at time) to another linux machine with a lot of disk space, in order make some kind of copy between them.

thanks a lot!
Claudio

P.S.: these disks have different capacity. 6 GB for hda (4 GB used), 5.1 GB for hdb.


16 REPLIES 16
Alexander Chuzhoy
Honored Contributor

Re: boot disk substituition

You have the ghost utility. There is a version that runs directly under OS. I got one that runs under Windows(2000,XP),I'm sure they have for Linux too.

You can try mirroring the disk ,but since your second disk is smaller then the first -I'm not sure it'll work.
Best Regards.
Sergejs Svitnevs
Honored Contributor

Re: boot disk substituition

If the disk are identical, dd will copy disk to disk. But it is a bit-by-bit copy and if the source disk has errors, dd will copy those.

Regards,
Sergejs
Mark Grant
Honored Contributor

Re: boot disk substituition

If you have your disk in a LVM volume group you can use pvmove to move physical extents to the other disk. It doesn't sound like you have this so your only option is to use cpio or tar or possibly dd (tar won't copy device files but you can do a quick script to re-create them) and copy everything to similarly created filesystems on the other disk. If you run lilo don't forget to install lilo on the other disk and adjust lilo.conf (or grub.conf if that's your thing).
Never preceed any demonstration with anything more predictive than "watch this"
Claudio Cilloni
Honored Contributor

Re: boot disk substituition

These disks aren't identical, as I said before.
the second disk is smaller than the first, but the data can fit into it.

hda is partitioned so:
/dev/hda1: 1.8 GB for /
/dev/hda2: 200 MB swap space
/dev/hda3: 4 GB for /home

/home isn't so important, I can copy its content somewhere else. just keep the system working on the second disk is enough for me.


Sergejs Svitnevs
Honored Contributor
Solution

Re: boot disk substituition

You can create partitions on the new drive ( not necessary the same size) and then using dump/restore to transfer the partition files. Repeat for each partition. Then reinstall your bootloader.

Regards,
Sergejs
Huc_1
Honored Contributor

Re: boot disk substituition

You could also.

make a bootable floppy
partition disk
mark first partition as bootable (from fdisk)
make a file system's' on partition's'
from the file found in / write script like
ex:
rsync -avz /bin /bck
rsync -avz /boot /bck
rsync -avz /dev /bck
rsync -avz /etc /bck
rsync -avz /home /bck
rsync -avz /initrd /bck
rsync -avz /lib /bck
rsync -avz /lost+found /bck
rsync -avz /misc /bck
rsync -avz /mnt /bck
rsync -avz /opt /bck
rsync -avz /root /bck
rsync -avz /sbin /bck
rsync -avz /System.map /bck
rsync -avz /tmp /bck
rsync -avz /usr /bck
rsync -avz /var /bck
rsync -avz /vmlinuz /bck

bring system to single user
run your tailored rsync script
stop system
physicaly switch disk hda to hdb, hdb to hda
boot from floppy
watch for error
login as root
run lilo ro grube
correct errors ?
take out floppy
boot
watch for errors ?
when all is well add hdb to fstab as read only


note that he command rsync could be used to remote node but then not from single user mode !

The above could give you a few error's on open files (not a lot from single user mode !)

That iw why I thing in theses senario Ghost is still the best/safest way.

Hope this helps

J-P

Smile I will feel the difference
Huc_1
Honored Contributor

Re: boot disk substituition

In the above reply forgot the following

bring system to single user
-----------------------------
mount /dev/hdb /bck
------------------------
run your tailored rsync script

Mea maximila culpa.

J-P
Smile I will feel the difference
Claudio Cilloni
Honored Contributor

Re: boot disk substituition

I'll try your suggestions this weekend. See ya next week for the points!

thanks again,
Claudio
Claudio Cilloni
Honored Contributor

Re: boot disk substituition

Hi all... I'm here again.

I tried the dump/restore solution... It seemed to me enough simple.

1. connected the 6GB disk on another linux machine as IDE primary slave.

2. 'dump'ed the /dev/hdb1 and /dev/hdb3 to file.

3. connected the 5.1GB disk on the same machine.

4. repartitioned this disk like the old one: /dev/hdb1 (ext2), /dev/hdb2 (swap), /dev/hdb3 (ext2) BUT a little bit smaller partitions.

5. 'restore'ed from file the partitions 1 and 3.

6. reconnected this disk on his original machine, as primary master.

7. boot from floppy, a floppy that works well with the original boot disk (the 6GB one). I still haven't installed grub on this hard disk.

8. got an error: 'kernel panic: no init found. try passing the init= parameter' or something similar.
I think that the init executable file should be exactly where it was on the old disk... What's wrong?

thanks!

Ciao
Claudio
Alexander Chuzhoy
Honored Contributor

Re: boot disk substituition

try to boot into rescue and in a chroot enviroment install grub in MBR
Huc_1
Honored Contributor

Re: boot disk substituition

Yes boot in rescue chroot to disk and there

#/etc/lilo

if it is lilo you had on disk.

J-P
Smile I will feel the difference
Mark Grant
Honored Contributor

Re: boot disk substituition


It may be that your "root=" line is no longer correct on the floppy. Check which device is which in the boot messages you get before your panic. Try a append="init=/bin/sh" in your lilo.conf which should at least get you a shell on boot so you can see what state your machine is in. Check what has been mounted where. If this fails then your / filesystem is probably not mounted.

One other option is to create a small partition on your new disk and install a tiny linux on it. Boot that.
Never preceed any demonstration with anything more predictive than "watch this"
I.Delic
Super Advisor

Re: boot disk substituition

Best,

Dit you try this:
dd if=/dev/hda1 of=/dev/hdb1


succes

Idriz
Huc_1
Honored Contributor

Re: boot disk substituition

Did you finaly get to try it, Claudio.

I be interested by how you did it

J-P (0 pts for this just a question ?, tks)
Smile I will feel the difference
Claudio Cilloni
Honored Contributor

Re: boot disk substituition

Sorry for the delay... It is one of my home machines (a tiny 486 100Mhz happy to be yet in use), and in the evening I haven't got much time for hardware maintenance. However...

Answering to Mark Grant, the root= parameter is correct. It is root=/dev/hda1 and with the old disk (6GB) it works. I have copied that partition in the first partition of the new disk (5.1GB) so, when I connect the new disk
as primary master the boot partition is always /dev/hda1.
I'm quite sure that the kernel on the floppy hangs because it cannot mount /dev/hda1 of the new disk as /. But I don't know why.

The suggestion of I.Delic (dd if=/dev/hda1 of=/dev/hdb1) isn't good, I think: the source and the destination partitions have different sizes.

I suspended (temporarily) these experiments when I connected the old disk (6GB) as primary master, the new disk (5.1GB) as secondary master and booted rom floppy, expecting to have /dev/hda1 as root partition.
After a while I realized that the root partition was /dev/hdc1 (?!?!?!???) mmmmmh... Now I got to discover what's happened.

I'll keep you informed.

Ciao
Claudio
Claudio Cilloni
Honored Contributor

Re: boot disk substituition

Problem solved. The boot floppy was unable to boot the linux contained in the new harddisk because I formatted the root partition using ext2.

I suppose (but I'm not sure) that the boot floppy's kernel mounts in read-only mode the /dev/hda1 partition, read the /etc/fstab file (where /dev/hda1 is specified as ext3 filesystem), then it tries to remount that partition in read-write mode using ext3. As I said before, it is an ext2 filesystem so the system hangs.

I repeated the restore process after formatting /dev/hda1 of the new harddisk using ext3, then boot from floppy, install grub, reboot again. Wow... it worked!

Sergejs Svitnevs' solution, dump & restore, worked great. Thanks to all!

Ciao
Claudio