How To Remotely Install Debian Over A RH Based Distro - Page 4
9) Copy base Debian system into new partition
We need to move the system back onto the original partition that held the RH distro. Look back over your notes, select the partition the RH distro was located in. In our case the partition was /dev/hda3.
First do a quick format of the system to clear it off:
mke2fs -j /dev/hda3
Once that's done, we'll move the filesystem over using dd:
dd if=/dev/hda2 of=/dev/hda3 bs=1024
'if' is the current partition you want to copy the data FROM.
'of' is the partition you want to copy the data TO.
'bs' defines the block size. You can use a value larger than 1024 if you want, but 1024 works fine for most.
This command can take 3-30 minutes depending on your system and hard drive speeds, so have another slice of pizza before it gets too cold.
When that finishes, the new filesystem isn't aware of the new partition size. That will need to be adjusted:
e2fsck -f -y /dev/hda3
Run this command until you do not get any more errors (usually twice should do it).
Now resize the partition:
resize2fs -p /dev/hda3
resize2fs 1.40-WIP (14-Nov-2006)
Resizing the filesystem on /dev/hda3 to 19247878 (4k) blocks.
Begin pass 1 (max = 579)
Extending the inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/hda3 is now 19247878 blocks long.
Run fsck on it again to make sure there were no hiccups:
e2fsck -f -y /dev/hda3
Then go back into grub and tell it to boot into the new partition:
default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz #hiddenmenu title Debian! root (hd0,0) kernel /boot/vmlinuz-2.6.18-6-686 root=/dev/hda3 ro initrd /boot/initrd.img-2.6.18-6-686
Note that we changed /dev/hda2 to /dev/hda3.
Change the /etc/fstab to point / (root) at the new partition (/dev/hda3):
# filesystem mount fs-type options dump fsck-order /dev/hda1 /boot ext3 defaults 1 2 /dev/hda3 / auto defaults 0 1 proc /proc proc defaults 0 0
And a reboot to bring the new partition up......
You will now be in your full Debian system. There are still a couple details to be attended to, but the system is now fully functional.
10) Get our swap partition back
One of the final steps is to convert the temporary filesystem we loaded the Debian base onto (/dev/hda2) back into swap space to be utilized by the Debian system.
We need to use fdisk to change the partition type from ext3 to swap:
Command (m for help): t
Partition number (1-4): 2 (change this to your swap partition number!)
Hex code (type L to list codes): 82
Changed system type of partition 2 to 82 (Linux swap / Solaris)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Add an entry into fstab for the swap partition:
# filesystem mount fs-type options dump fsck-order /dev/hda1 /boot ext3 defaults 1 2 /dev/hda2 swap swap defaults 0 0 /dev/hda3 / auto defaults 0 1 proc /proc proc defaults 0 0
Have the system turn it back into swap space:
Activate and sync the swap space for the running system to use:
And that was the last step! You've now converted a RH based machine into a Debian machine without ever physically touching it. I like to do 1 more reboot to make sure everything is working correctly - I'd recommend you do the same.