How To Remotely Install Debian Over A RH Based Distro

Want to support HowtoForge? Become a subscriber!
 
Submitted by jakev383 (Contact Author) (Forums) on Fri, 2008-08-08 14:25. :: CentOS | Debian | Fedora

How To Remotely Install Debian Over A RH Based Distro

Introduction

Ocassionally, servers need to be retasked for various reasons.  It has always been a challenge when the server has a distribution other than what I need. I do not want to drive to the data center to swap CDs around, so I decided to see if there was a way to remotely install the machine.  I found some notes by Erik Jacobsen and used them to come up with an up-to-date how-to.

Hopefully this will be useful to others out there.  Be warned that you can cause some serious headaches for yourself.  I offer no warranties, expressed nor implied, that this will work for you.

In this tutorial, I have an ancient Fedora Core 3 machine that I need to turn into a Debian Etch machine.  The machine is 600 miles from my home office so traveling to put in CDs is not an economical option.  The system has one 80G hard drive that is currently divided into 3 partitions: a 100M /boot partition, a 1G swap partition, and the remainder as the / partition for the Fedora Core installation. The machine has a public static IP address and will be accessed through an SSH connection.

You'll need to make sure your swap space is adequate.  We will be loading the base Debian system into the space currently allocated for swap, so you need to make sure you have enough room to accomplish this task.  In my case I used 371M of space out of a 1012M swap when the Debian base was loaded, leaving me 590M of free space.

 

1) Install debootstrap

If you have another Debian machine available to you, you can build the debootstrap package yourself.  You may download the latest debootstrap .deb file from here:

http://packages.debian.org/etch/all/debootstrap/download

On the Debian build machine, install alien:

apt-get install alien

You then need to convert the Debian .deb file to a RPM for the RH machine to use:

alien -rkv debootstrap*.deb

This will create a debootstrap RPM file that you need to install on the current RH based machine once you get it transferred over:

rpm -Uvh debootstrap*

I've made a copy of the RPM available in the event you cannot build it for whatever reason.  You may download the RPM from http://v2gnu.com/filemgmt/visit.php?lid=27. I make this file available, but I will not be updating it.

 

2) Change the swap space into a usable filesystem

The remainder of this paper will be run on the RH machine that we will be converting into a Debian based machine.

Turn off your swap space so we can load Debian onto it:

swapoff -a

Use

fdisk -l

to see which partition your swap space is.  On my system, the swap space is /dev/hda2:

Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14         144     1052257+  82  Linux swap
/dev/hda3             145        9729    76991512+  83  Linux

Use fdisk to change the swap space into a Linux partition so we can load data into it.

*** WARNING - You are now entering the point of no return where your system may be unusable! ***

fdisk /dev/hda

Command (m for help): t
Partition number (1-4): 2              (change this to your swap partition number!)
Hex code (type L to list codes): 83
Changed system type of partition 2 to 83 (Linux)

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.
Syncing disks.

Double check to make sure that the swap partition (/dev/hda2) is now a Linux partition:

fdisk -l

Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14         144     1052257+  83  Linux
/dev/hda3             145        9729    76991512+  83  Linux

We next need to format this partition as ext3 so that we may load the Debian base onto it:

mke2fs -j /dev/hda2

mke2fs 1.35 (28-Feb-2004)
max_blocks 269377536, rsv_groups = 8221, rsv_gdb = 64
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
131616 inodes, 263064 blocks
13153 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=272629760
9 block groups
32768 blocks per group, 32768 fragments per group
14624 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376

Writing inode tables: done                           
inode.i_blocks = 2568, i_size = 4243456
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

There was an issue with the older Debian distros that balked at the dir_index flag.  This issue may or may not be present in the newer versions.  We're going to turn it off to be on the safe side:

tune2fs -O ^dir_index /dev/hda2

 

3) Load the Debian packages onto the new partition

Next we create a variable name for the new partition to save on typing.  We used $ASD as an arbitrary place holder since it was easier and quicker to type than /dev/hda2.  Feel free to substitute any variable name that is convenient for you:

export ASD=/mnt/asd

We next create the directory to serve as the mount point:

mkdir -p $ASD

And lastly we mount the new partition:

mount /dev/hda2 $ASD

From here on, we can use $ASD in the place of /dev/hda2.  

Now we run debootstrap which will take a while and populate the packages needed.  You will be choosing the architecture (i386 here), distribution (Etch used here), directory, and URL to a Debian archive. For the URL at the end, it can be any valid Debian mirror.  You are encouraged to choose a mirror closest to your geographic location.  A list of available mirrors is available on the main Debian site, specifically here: http://www.debian.org/mirror/list.

I am going to use one of the more permanent mirrors so it may be a little slow, but feel free to use any mirror you wish (even your own repo!):

/usr/sbin/debootstrap --arch i386 etch $ASD http://mirrors.kernel.org/debian

This will take a while.  Go have a cup of coffee or order a pizza. Once it's done you will have the base Debian packages installed into the new partition ($ASD).


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by acasto (registered user) on Mon, 2008-08-11 17:55.

Here is a post I made a couple years ago on remotely converting a Fedora system to Debian on software RAID-1.

Here is some of my guides and notes I made at the time.