Copying a linux from a PATA disk to a SATA disk
Tuesday, September 26th, 2006This is a kind of a rewrite of my very first blog entry and it describes how to copy one disk with a linux-os on to another one, including the creation of the master boot record.
I assume you have the SATA disk as /dev/sda with two partitions: /dev/sda1 is the root filesystem, /dev/sda2 is the swap.
- Connect the SATA drive to the computer.
- Reboot Computer.
- Partition the Harddrive:
# cfdisk /dev/sda - Create the filesystem:
#mkfs.ext3 -m 1 /dev/sda1 - Mount the new filesystem:
# mount -t ext3 /dev/sda1 /mnt - Copy the files over:
cd /; find . -xdev | cpio -padm /mnt - Chroot into the new filesystem:
# chroot /mnt - Edit /etc/fstab so the new system finds it’s filesystem:
# gedit /etc/fstab
Then change the entries so the root-filesystem ( / ) is located on /dev/sda1 and the swap is located at /dev/sda2. - Edit /boot/grub/menu.lst:
# gedit /boot/grub/menu.lst to have an entry like (italic portions matter for the diskchange:title Ubuntu, kernel 2.6.15-27-386 root (hd1,0) kernel /boot/vmlinuz-2.6.15-27-386 root=/dev/sda1 ro quiet splash initrd /boot/initrd.img-2.6.15-27-386 savedefault boot
- Leave the chroot environment by typing
# exit. - Install master boot record:
# grub. In the grub write:grub> root (hd1,0) grub> setup (hd1) grub> quit