I have a CentOS 4.4 system where all of the main filesystems are on a single hard drive. This drive is starting to give some errors, so I got a new (larger) drive to replace it with. What is the easiest way to copy my filesystems over to the new drive? I considered using dd, but I lose the extra capacity of the new drive that way. I tried using SystemImager, but it is giving me some errors. I think the easiest way may be to boot from the LiveCD, recreate the partitions, copy the info with rsync and then fix the boot partition and grub. Any tips or pointers to a good how-to? -- Bowie
On Mar 14, 2007, at 9:35 AM, Bowie Bailey wrote:> I have a CentOS 4.4 system where all of the main filesystems are on a > single hard drive. This drive is starting to give some errors, so > I got > a new (larger) drive to replace it with. What is the easiest way to > copy my filesystems over to the new drive? > > I considered using dd, but I lose the extra capacity of the new drive > that way. > > I tried using SystemImager, but it is giving me some errors. > > I think the easiest way may be to boot from the LiveCD, recreate the > partitions, copy the info with rsync and then fix the boot > partition and > grub. Any tips or pointers to a good how-to? > > -- > BowieHere is what I recently did for a similar operation. 1) Download the system restore iso http://www.sysresccd.org/Main_Page 2) Boot into the sysrescue cd 3) Run partimage against your old disk to save the slices. 4) Partition your new disk as per your old disk (sfdisk -d /dev/disk1 | sfdisk /dev/disk2) 5) Use partimage to restore backups you just did to the new disk. 6) Remove old disk 7) Remove CD 8) Reboot Viola.. -ed- PS. You might need to fix grub if addressing for the new disk changed but there are smarter people to comment on that aspect.
Bowie Bailey wrote:> I have a CentOS 4.4 system where all of the main filesystems are on a > single hard drive. This drive is starting to give some errors, so I got > a new (larger) drive to replace it with. What is the easiest way to > copy my filesystems over to the new drive? > > I considered using dd, but I lose the extra capacity of the new drive > that way. > > I tried using SystemImager, but it is giving me some errors. > > I think the easiest way may be to boot from the LiveCD, recreate the > partitions, copy the info with rsync and then fix the boot partition and > grub. Any tips or pointers to a good how-to? >I'm assuming you're using straight ext3 without LVM or raid.... I'd probably boot the regular CD into rescue mode, without mounting the file systems, then partition the new disk to suit (making each partition at least as large as the original drive, and in the same order, then run something like.... this assumes new drive is hda, old drive is hdb mkdir /mnt/src /mnt/dst for f in 1 2 5 6; do mount /dev/hdb$f /mnt/src mount /dev/hda$f /mnt/dst dump 0f - /mnt/src | (cd /mnt/dst; restore rf - ) umount /mnt/dst /mnt/src end mkswap /dev/hda3 mount /dev/hda2 /mnt/dst && mount /dev/hda1 /mnt/dst/boot chroot /mnt/dst grub-install /dev/hda ^z umount /mnt/dsk/boot; umount /mnt/dsk adjust file and device names to suit. dump to restore like that creates a very accurate copy of a file system, complete with special files, links, ACLs, permissions, etc, etc intact. now, swap the new drive (where 1, 2, 5, 6 are your file system partitions, leaving out your swap which I'm guessing is hda3)
Bowie Bailey wrote:> I have a CentOS 4.4 system where all of the main filesystems are on a > single hard drive. This drive is starting to give some errors, so I got > a new (larger) drive to replace it with. What is the easiest way to > copy my filesystems over to the new drive? > > I considered using dd, but I lose the extra capacity of the new drive > that way.Not necessarily.> > I tried using SystemImager, but it is giving me some errors. > > I think the easiest way may be to boot from the LiveCD, recreate the > partitions, copy the info with rsync and then fix the boot partition and > grub. Any tips or pointers to a good how-to?I don't see a particular advantage to rsync for a once-off copy. My perennial favourite is tar clC / ... | tar xpC .... Insert ssh if you need to copy system to system. insert buffer into the chain if you have it. Use compression if you're copying over a slow network. btw I recently did this, and I discovered the failing drive didn't work at all in a USB enclosure. I used the tar trick, it's more robust than dd when some stuff can't be read. You might want to enclose the commands: (tar ... | tar ...) 2>&1 | tee /tmp/reportfile because if there are lots of errors, you probably want to know there are lots of errors and be able to inspect them later. We lost stuff - stuff like the squid cache, some mirrored Linux - stuff that was fairly easy to ignore/recreate.> > -- > Bowie > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos >-- Cheers John -- spambait 1aaaaaaa at coco.merseine.nu Z1aaaaaaa at coco.merseine.nu Please do not reply off-list
John R Pierce wrote:> Bowie Bailey wrote: > > I have a CentOS 4.4 system where all of the main filesystems are on > > a single hard drive. This drive is starting to give some errors, > > so I got a new (larger) drive to replace it with. What is the > > easiest way to copy my filesystems over to the new drive? > > > > I considered using dd, but I lose the extra capacity of the new > > drive that way. > > > > I tried using SystemImager, but it is giving me some errors. > > > > I think the easiest way may be to boot from the LiveCD, recreate the > > partitions, copy the info with rsync and then fix the boot > > partition and grub. Any tips or pointers to a good how-to? > > > > I'm assuming you're using straight ext3 without LVM or raid.... > > I'd probably boot the regular CD into rescue mode, without mounting > the file systems, then partition the new disk to suit (making each > partition at least as large as the original drive, and in the same > order, then run something like.... > > this assumes new drive is hda, old drive is hdb > > mkdir /mnt/src /mnt/dst > for f in 1 2 5 6; do > mount /dev/hdb$f /mnt/src > mount /dev/hda$f /mnt/dst > dump 0f - /mnt/src | (cd /mnt/dst; restore rf - ) > umount /mnt/dst /mnt/src > end > mkswap /dev/hda3 > mount /dev/hda2 /mnt/dst && mount /dev/hda1 /mnt/dst/boot > chroot /mnt/dst > grub-install /dev/hda > ^z > umount /mnt/dsk/boot; umount /mnt/dsk > > adjust file and device names to suit. dump to restore like that > creates a very accurate copy of a file system, complete with special > files, links, ACLs, permissions, etc, etc intact. > > now, swap the new drive > > > (where 1, 2, 5, 6 are your file system partitions, leaving out your > swap which I'm guessing is hda3)I attempted this method with a few modifications and I'm mostly done. I partitioned the new drive and created the filesystems. I then mounted them one by one and copied the information over. There is a bad inode that caused 'dump' to crash, so I used 'rsync -a' to make the copy instead. When I tried to do the 'chroot' and 'grub-install', grub complained that it didn't have a device file (which it didn't, /dev/ was empty). So I copied the '/dev/hda*' files from the rescue environment to the destination hard drive and tried again. This time, the 'grub-install' ran fine. Now the problem is that when I try to boot, I get the world's worst error message: "GRUB GRUB GRUB...". I read that this can be fixed by setting your bios to manual rather than auto for the hard drives, but that didn't work for me. What else can I do? I think everything is copied to the new drive, I just need to convince it to boot. -- Bowie