home     open source
PHP and modifications
RPM Building
SuSE Linux RPMs
Linux Installation

Installing RedHat Linux to a second extended partition.

This information applies to RedHat 6.2 and later, but is probably applicable to all RedHat 6 versions.
This is a step by step HOWTO. It explains how to use a second extended partition to install Linux to. You achieve this by temporarily changing the partition type of the DOS extended partition by overwriting the MBR. Use a Linux extended partition (0x85) to put your new Linux partitions in, so you don't confuse DOS and co with multiple extended partitions. After installation you restore the first extended partition. You will have to edit /etc/fstab and /etc/lilo.conf to reflect the new partition layout afterwards and rerun lilo.
Note that fdisk provided by Red Hat only supports 16 partititions since 7.2(?). That makes this procedure also useful if you want to install another Red Hat distribution but have no partitions left.

Although this procedure works for me, overwriting the MBR is inherently dangerous, and I take no responsibility if you screw up your system. Make backups.

In this example I make the following assumptions:
- You have the following paritions
/dev/hda1 vfat (DOS C:)
/dev/hda2 dos extended
/dev/hda3 ntfs (Win2000 root)
/dev/hda5 vfat (DOS D:)
/dev/hda6 vfat (DOS E:)
If you use a different partitioning scheme change your /etc/fstab and /etc/lilo.conf accordingly.
- You have a DOS formatted floppy handy. Better 2, so you can make 2 copies of the partition data.

1) Boot to "linux rescue" from CD.
2) # mkdir /mnt/floppy
3) Make the device /dev/hda:
# mknod /dev/hda
4) Insert a DOS formatted floppy and copy the MBR. Make sure the floppy contains no bad sectors, or you might loose your parition and thus your "logical" DOS partitions.
# mount -t vfat /dev/fd0 /mnt/floppy
# dd if=/dev/hda of=/mnt/floppy/MBR.org bs=512 count=1
You should make an extra copy of this data, preferably on another floppy. Check on another machine that you can read this file before proceeding. Better even, copy it to this machine as backup.
5) Unmount the floppy
# umount /mnt/floppy
6) Go to another machine, make a copy of MBR.org to MBR.mod, and edit MBR.mod with a hex editor. You should change byte 0x1D3 (467) which now reads 0x05 or 0x0F to something like 0xFF.
7) Mount the floppy again, and overwrite the MBR with MBR.mod.
# mount -t vfat /dev/fd0 /mnt/floppy
# dd if=/mnt/floppy/MBR.mod of=/dev/hda bs=512 count=1
# umount /mnt/floppy
8) Reboot your machine and start a normal installation. When coming to the partitioning section create a Linux extended partition (type 0x85). For simplicity I assume you only make a swap and a root (/) partition on /dev/hda5 and /dev/hda6 respectively. Note that your logical DOS partitions have temporarily disappeared, but will not be overwritten, since the DOS extended partition now appears to be a BBT partition (whatever that is :) .
Continue your installation as usual. Don't forget to make a boot disk. You will need it after you have restored your DOS extended partition.
9) After the installation has completed reboot to Linux, either from hd or from floppy.
10) Now you are going to restore the DOS extended partition. Mount a floppy and write the new MBR to it.
# mount -t vfat /dev/fd0 /mnt/floppy
# dd if=/dev/hda of=/mnt/floppy/MBR2.org
# umount /mnt/floppy
11) Copy MBR2.org to MBR2.mod, and edit MBR2.mod with a hex editor. Change byte 0x1D3 (467) with the value it contained previously (0x05 or 0x0F). Write the new MBR to disk:
# mount -t vfat /dev/fd0 /mnt/floppy
# dd if=/mnt/floppy/MBR2.mod of=/dev/hda bs=512 count=1
# umount /mnt/floppy
12) Reboot the machine, using the boot floppy. Issue a "linux root=/dev/hda8" on the LILO prompt. Since the DOS extended partition and the logical partitions within it have reappeared your partitions in the second extended partition have shifted. Your DOS /dev/hda5 and /dev/hda6 partitions have reappeared, so your swap and root partition will now be /dev/hda7 and /dev/hda8. Change these numbers to reflect your situation (I assume you can count ;).
13) Now edit /etc/fstab and /etc/lilo.conf to reflect the new situation (eg swap is /dev/hda7 and root (/) is /dev/hda8). Rerun lilo. (Side note: when using large IDE disks you probably want add the option "lba32" to your lilo.conf.) You now should have a running system with two extended partitions.

Leonard den Ottolander.