3

I have a disk with separate partitions for each folder (/usr, /var, /home etc.) and wish to transfer the whole thing to another disk that is slightly larger, now I do not wish to keep the partition scheme, so should I mount all partitions (so they populate the proper folder locations) and then rsync, or cp -avx the whole partiton (of course under runlevel 1) to the new drive?

Will I need to use dd to copy the root partition / and /boot to the disk before copying all the other files manually?

I am really just wanting to berid of the multiple partitions so I can use LVM instead, I have no clue how to transfer it the "proper" way though.

1 Answer 1

4

Normally I do this kind of transfers by rsync'ing between the two hard drives, so your hunch about either rsync or cp -avx looks more than right to me.

In order to boot from the new disk as you did from the old one you just need to reinstall grub in the new boot sector (I'm assuming you're using grub here).

For RedHat based Linux distros (CentOS, RHEL, Fedora) you can do this by executing as root grub-install /dev/hdX, just telling where your new hard drive is.

For Debian systems you'll need to execute sudo update-grub

Reinstalling grub sometimes is a bit of trial/error so be careful.

If you want to do it the manual way you can do so by following this steps:

Check that your new disk appears in grub device.map file

(fd0)     /dev/fd0
(hd0)     /dev/hda
(hd1)     /dev/hdc

Once you know that the new drive is in device.map from the OS booted from the old drive execute the following commands

# grub
grub> root (hd0,0)
 Filesystem type is ext2fs, partition type 0xfd

grub> setup (hd0)
 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 (hd0)"...  15 sectors are embedded.
succeeded
 Running "install /grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/grub/stage2 /grub/grub.conf"... succeeded
Done.

BE AWARE: You need to substitute (hd0,0) with the appropiate disk and partition for your kernel images

If your kernel is in partition /dev/hdX1 -> (hdX,0) If your kernel is in partition /dev/hdX2 -> (hdX,1)

And so forth...

Also substitute hdX with the drive as declared in your device.map, so if you have your drive declared as (hd1) you need to make it (hd1,X)

2
  • Oh wow, I can safely say you've answered and inspired me in learning about these tasks (I am inspired to learn systems administration down the road as a possible job). Much appreciated, thank you. Jan 31, 2011 at 9:08
  • After the copy, for installing Grub, I had more success with the tiny 7MB bootable "Super Grub2 Disk" at supergrubdisk.org which booted my new hard drive and allowed me to run install-grub from there, without worrying about device mappings.
    – Nicolas
    Jan 24, 2013 at 2:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .