Wednesday, 13 August 2008

Installing Fedora, Dual-Boot

Introduction and Contents

I decided to get Fedora onto my work laptop but keep Windows in such a way that I could boot into either (i.e. a dual-boot configuration). I explain why in First Steps in Tuxland.Since my Windows partitions filled the whole disk I had to shrink one of these to make some space for Fedora. I decided to continue using the Windows boot loader as the primary boot loader rather than overwriting it with the Linux Grub boot loader; this requires some extra steps.

Here's what you have to do:
  1. Get Fedora onto a DVD (or set of CDs)

  2. Get Linux 'SystemRescueCD' software onto a DVD (or CD)

  3. Make some space for Fedora

  4. Install Fedora

  5. Modify Windows boot loader configuration and restart

  6. Complete Fedora post-install configuration


1. Get Fedora onto a DVD

You have to:
  • Download the ISO image for the Fedora installer
  • Burn the image onto a DVD (or set of CDs)

1.1 Download the ISO image for the Fedora installer
Go to http://fedoraproject.org/en/get-fedora and select: Direct Download -> 'x86_64 - Install DVD'. I chose the x86_64 architecture download because my laptop is a Centrino Duo. If in doubt about your architecture see http://docs.fedoraproject.org/install-guide/f9/en_US/sn-which-arch.html.

This downloads the following iso image: ftp://ftp.mirrorservice.org/sites/download.fedora.redhat.com/pub/fedora/linux/releases/9/Fedora/x86_64/iso/Fedora-9-x86_64-DVD.iso. If you are using IE you will get a warning to use Firefox. I didn't and it worked okay: I left the download running overnight as it was clearly going to take several hours.
There are also links on the web site to download CD images - you'll need several CDs though!

1.2 Burn the ISO image onto a DVD (or set of CDs)
You'll need software that can burn an iso image. I chose Nero 8. For a free trial version go to http://www.nero.com/, select Products -> Nero 8 and click the Try link. Once installed, use Nero StartSmart and select Nero Burning ROM. You need to use the Burn ISO option. This tool can burn DVDs and CDs. The trial version of Nero is time-limited, after which you have to pay a fee for a licence. This is fine if you want to use all of Nero's many features. However I only wanted to record an ISO so I made do with the trial version (hey, Mr. Nero, how about a 'NeroLite ISO Edition' for a fraction of the full fee? I might be tempted to cough up.).
Alternatively you can use Alex Feinman's free ISORecorder tool (http://isorecorder.alexfeinman.com/isorecorder.htm). You need V1 for WinXP SP1, V2 for WinXP SP2 and V3 for Vista. Note that the WinXP versions only record ISOs onto CD, not DVD. You can do DVD with the Vista version.

2. Get Linux 'SystemRescueCD' software onto a DVD (or CD)

To paraphrase Peter Quince:

There is two hard things: that is, to resize the Windows partition to release some space for Fedora. Then there is another thing. We must copy the Linux boot loader to a file that can be used by the Windows boot loader.

There are many Windows tools for shrinking NTFS partitions: http://www.wit-soft.com/, http://www.acronis.com/homecomputing/products/diskdirector/disk-editing.html, http://sourceforge.net/projects/beeblebrox are just three that Google throws up.

For copying the Linux boot loader under Windows we can use 'DD for Windows' (http://www.chrysocome.net/dd).

However I decided to use Linux tools to do these things:
  • gparted: This is allegedly more reliable at shrinking existing NTFS partitions than the partition editors supplied with many Linux distros.
  • dd: This is used to copy the Linux boot loader to a file that can be used by the Windows boot loader.
To get these we need a bootable Linux CD. I chose the Linux 'SystemRescueCD' (http://www.sysresccd.org/Main_Page). Once again download the ISO and burn to a CD or DVD.

3. Make some space for Fedora

I will assume that your existing configuration contains a single hard drive with either one NTFS partition (C:) or two NTFS partitions (C: and D:) that fill the whole disk. My laptop has an 80 GB disk and had two partitions: C: was 24 GB and D: was 50.53 GB (that's 74.53 GB but it filled an 80 GB disk..?). I therefore decided to shrink the D: partition by 20 GB to make space for Linux.
If you already have 15 to 20 GB unallocated you can ignore this section and proceed directly to section 4. Install Fedora.

Before you need to do anything else you need to run Disk Cleanup and then Defragment the partition you intend to shrink, and work out how much you can shrink it by without either compromising data or giving you so little free space on the partition as to render it unuseable. You need to be able to shrink it by at least 15 GB (the Fedora install will consume about half of this space and you'll need some space for your own files).

Ensure your BIOS is set to boot from the DVD drive before it boots from the HDD.
Put the SystemRescueCD in the drive and restart the system. It starts booting into Linux. You have to respond to a couple of prompts:

boot: (if you don't respond in a few seconds it boots anyway)

and

Load keymap: uk (or whatever your locale is)

Once it has booted type the following command:

root@sysresccd /root% startx

This starts the x windows manager and opens a terminal window. Now in that window type:

root@sysresccd /root% gparted

This opens the gparted graphical partitioning tool.

In the upper right corner of the gparted window use the down-arrow to select your hard drive (mine was /dev/sda). If you only have one hard drive there will only be one thing to choose.

My partitions were displayed as:
PartitionFilesystemLabelSize...Flags
/dev/sda1ntfsSystem24.00 GiB...boot
/dev/sda2ntfsData50.53 GiB...

Where:
/dev/sda1 is the C: partition and
/dev/sda2 is the D: partition.

We need to shrink /dev/sda2 by 20 GB.

(If you have a single C: partition you will see a single device /dev/sda1, so wherever I write /dev/sda2 you should read /dev/sda1)

In the graphical display click on /dev/sda2.

In the menu bar click Partition -> Resize/Move. This opens the 'Resize/Move /dev/sda2' dialog box.

Either use the arrow at the right end of the graphical display, or you can use the New Size (MB) box, to change the size of the partition to its new smaller size. In my case I changed it from 51741 MB to 31259 MB, freeing up 20481 MB.

Click the Resize/Move button. This closes the dialog box, but nothing else happens just yet.

In the toolbar click Apply. This opens an 'Are you sure?' confirmation box.

In the confirmation box click the Apply button. It opens an information dialog and proceeds to resize the partition. Wait while it resizes the partition.

Once this has finished click Close in the information dialog. It rescans the drive to update its display.

Now you should quit gparted and reboot into Windows before you do anything else:

In the terminal window type:

root@sysresccd /root% shutdown -r now

Wait for the machine to shutdown and, as it starts up again, eject the SystemRescueCD before linux gets a chance to start booting again. If you do this right it will boot into Windows.
Windows detects that its partition table has been fiddled with so it automatically launches AUTOCHK to check the modified partition. Let this run. It took about 15 minutes on my laptop. After it finished that, the boot completes allowing you to log in.
It may ask your permission to restart again. Do this, secure in the knowledge that this is one of the annoyances of Windows that you won't need to put up with in Linux.

4. Install Fedora
Put the Fedora DVD in the drive. Shutdown Windows and restart. Here are the screens I saw together with my responses:

4.1 Welcome to Fedora!
Select 'Install or upgrade existing system'.
Enter.

4.2 Disk Found
TAB to skip media test.
Enter .

4.3 (Graphical installer splash screen)
Next .

4.4 What language would you like to use?
Select your language (I chose English).
Next.

4.5 Select the appropriate keyboard
Select your keyboard (I chose United Kingdom).
Next.

4.6 Network Devices
Select 'Automatically via DHCP'.
Next .

4.7 Select the nearest city in your timezone
Select a City (I chose Europe/London).
For dual boot uncheck 'System clock uses UTC'.
Next.

4.8 Root password
Enter this twice.
Next .

(If you have chosen a weak password you will be given the opportunity to reselect a new password or to continue)

4.9 Partitioning
Select 'Use free space on selected drives and create default layout'.
Under 'Select drive to use for this installation' ensure the correct drive is selected (if there is only one drive this will be listed but greyed out).
Under 'What drive would you like to boot this installation from?' ensure the correct drive is selected (if there's only one drive it won't be possible to change this).
Check 'Review and modify partitioning layout'.
Click Next.

4.10 Review partitioning
You will see the following:
DeviceMount PointTypeFormatSize (MB)
LVM Volume Groups



VolGroup00


20224
LogVol01
swapy1984
LogVol00/ext3y18240





Hard Drives



/dev/sda



/dev/sda1
ntfs
24576
/dev/sda2
ntfs
31259
/dev/sda3/bootext3y196
/dev/sda4
Extended
20285
/dev/sda5VolGroup00LVM PVy20285

Looking under the 'Hard Drives' section, the (one) drive is called /dev/sda.

The installer will configure on this drive the following partitions (note that this is just the proposed configuration - only the ntfs partitions actually exist at this point):

/dev/sda1 is the existing Windows C: partition.
/dev/sda2 is the existing D: partition (if one exists on your system).
/dev/sda3 is the linux boot partition, where we will install the GRUB boot loader. It is important that you remember the device name of the /boot partition (i.e. /dev/sda3 here) as it is required in a later step.
(/dev/sda4 is an Extended partition, which just means it is a container for other partitions)
/dev/sda5 is a logical partition inside /dev/sda4 which will be used to contain a Logical Volume Group where the Linux partitions will go.

[Note: Since doing this I installed on a second machine and on that machine the installer put the /boot partition on a logical partition (/dev/sda6) inside the Extended partition. I don't know why it did this, but wherever the installer puts the /boot partition you need to remember its device name (/dev/sda3 in the table above) as it is required for a later step.]

There is a single Logical Volume Group called VolGroup00, which is mapped to /dev/sda5.

The installer will configure in VolGroup00 two Linux partitions:

LogVol01 is the Linux swap partition.
LogVol00 is the Linux / (root) partition, and will consume all remaining free space on the drive unless we change it.

We need to:

Reduce the size of / (LogVol00) to create space for three other logical volumes. I went for 8192 MB for this partition.
Increase the size of swap (LogVol01) to 3584 MB (see below for why).
Create a /home partition (LogVol02) of 4224 MB.
Create a /opt partition (LogVol03) of 4224 MB.

The swap partition needs to be at least the size of your RAM. I had 4 MB RAM installed, although due to a motherboard 'feature' in the D620 the system can only make use of 3.25 MB. I decided to set swap to 3.5 GB. (I have a colleague with the same laptop and RAM who set his swap at 2 GB to no ill effect (so far)).

To make these changes:

4.10.1 In the main window...
Select VolGroup00.
Click Edit.

4.10.2 'Edit LVM Volume Group: VolGroup00'
Under 'Logical Volumes' click LogVol00.
Click Edit.

4.10.3 'Edit Logical Volume: LogVol00'
(Mount point = /)
(File system type = ext3)
(Logical volume name = LogVol00)
Change size (in my case from 18240 MB to 8192 MB)
Click OK .

4.10.4 'Edit LVM Volume Group: VolGroup00'
Under 'Logical Volumes' click LogVol01.
Click Edit.

4.10.5 'Edit Logical Volume: LogVol01'
(File system type = swap)
(Logical volume name = LogVol01)
Change size (in my case from 1984 MB to 3584 MB)
Click OK .

4.10.6 'Edit LVM Volume Group: VolGroup00'
Under 'Logical Volumes' click Add.

4.10.7 'Make Logical Volume'
Mount point: Select /home
(File system type = ext3)
(Logical volume name = LogVol02)
Size: 4224
Click OK.

4.10.8 'Edit LVM Volume Group: VolGroup00'
Under 'Logical Volumes' click Add.

4.10.9 'Make Logical Volume'
Mount point: Select /opt
(File system type = ext3)
(Logical volume name = LogVol03)
Size: 4224 (this was all that was left)
Click OK .

4.10.10 'Edit LVM Volume Group: VolGroup00'
Click OK .

4.10.11 Review partitioning

This should now read:
DeviceMount PointTypeFormatSize (MB)
LVM Volume Groups



VolGroup00


20224
LogVol00/ext3y8192
LogVol02/homeext3y4224
LogVol03/optext3y4224
LogVol01
swapy3584





Hard Drives



/dev/sda



/dev/sda1
ntfs
24576
/dev/sda2
ntfs
31259
/dev/sda3/bootext3y196
/dev/sda4
Extended
20285
/dev/sda5VolGroup00LVM PVy20285

[As mentioned before the /boot partition might appear on a logical partition inside the extended partition - don't worry about it, but do remember which device name it is.]

Click Next.

4.11 Write partitioning to disk
Click 'Write changes to disk'.
This can take a minute or so.

4.12 Boot loader
Recall that I had decided to keep my original Windows boot loader and use the linux one (GRUB) as a secondary boot loader:
Keep 'Install boot loader on /dev/sda' checked, and click 'Change device'.

4.13 Boot loader device
Check 'First sector of boot partition - /dev/sda3' (this is your /boot partition)
Click OK.

(If you only have one Windows partition then the boot partition may well be /dev/sda2. Or if your Windows partitions are arranged differently it might be another device name entirely - but the Fedora installer will pick the right one for you.)

4.14 Boot loader
Click Next.
Now it transfers the installed image.

4.15 Select software
I selected 'Office and Productivity', 'Software Development' and 'Web Server'.
Check 'Customise now'.
Click Next.

4.16 Customisation
You can do what you like here.

Here is what I chose:
Left panelRight panelCustomised with options
Desktop environmentGNOMENo
ApplicationsEditorsNo
Games & EntertainmentNo
Graphical InternetAdded liferea (RSS/RDF feed reader) and thunderbird (mail/newsgroup reader)
GraphicsNo
DevelopmentDevelopment librariesNo
Development toolsAdded memtest86
Fedora EclipseNo
GNOME s/w developmentNo
Java developmentNo
ServersFTP ServerNo
Web serverAdded mediawiki, tomcat (4 packages) and wordpress
BaseJust took defaults
LanguageJust took defaults

Click Next.

Fedora now installs... it took about 25 minutes on my laptop.
When it finishes it spits out the DVD and asks you to click the 'Reboot' button. Click this. It should boot into Windows since we haven't changed the Windows boot loader yet!

5. Modify Windows boot loader configuration and restart

Put the Linux SystemRescueCD into the DVD drive. Restart Windows.

As before:

boot:

Load keymap: uk (or wherever you are)

We need to be able to write to one of the Windows NTFS partitions. This didn't used to be possible with linux, but the Linux SystemRescueCD (and Fedora 9) supports it.

See if you already have a mount point for the NTFS C: partition:

root@sysresccd /root% ls /mnt

If you see a windows folder then all is well. If you don't then you need to make a mount point:

root@sysresccd /root% mkdir /mnt/windows

The command ls /mnt/windows should show no files.

Mount the C: partition:

root@sysresccd /root% mount -t ntfs-3g -o umask=0000 /dev/sda1 /mnt/windows

Where /dev/sda1 is the device name for the C: partition.

The command ls /mnt/windows should now show your C: partition files.

Now create a file that Windows can use to boot Linux:

root@sysresccd /root% dd if=/dev/sda3 of=/mnt/windows/fedora.bin bs=512 count=1

Where /dev/sda3 is the device name for the /boot partition where we put the boot loader during the Fedora install (remember it might not be /dev/sda3 in your system, for example if you only have one Windows partition the boot partition might be /dev/sda2) . This is why we had to remember the device name for this earlier.

The command ls /mnt/windows should now show the new fedora.bin file among your C: partition files.

Now we need to boot back into Windows:

root@sysresccd /root% shutdown -r now

As before, wait for the machine to shutdown and, as it starts up again, eject the SystemRescueCD before linux gets a chance to start booting again. This should boot back into Windows.

Once in Windows you should be able to see fedora.bin on your C: drive.

In Explorer select Tools -> Folder options and click the View tab.
Select 'Show hidden files and folders'.
Uncheck 'Hide protected Operating System files'.
Click Apply.

Right-click C:\boot.ini, select Properties, uncheck 'Read Only'.

Edit boot.ini and make the last line:

C:\fedora.bin="Fedora Linux"

While you're at it change the timeout= value to 10 instead of 30.

Exit and save changes.

Make boot.ini Read Only again.
Make fedora.bin Read Only and Hidden.
Restart Windows.
You should see the Windows boot loader offering you Windows or Fedora.
Select Fedora.

6. Complete Fedora post-install configuration

6.1 Welcome
Click forward.

6.2 License Information
Click Forward.

6.3 Create User
Enter Username, Full Name, and Password (twice).

6.4 Date and Time
Click Network Time Protocol tab
Click 'Enable Network Time Protocol'
Click Time Zone tab
Check your city is selected
Click Forward

6.5 Hardware Profile
Chose an option
Click Finish

Login and enjoy!

7. Acknowledgements

My main sources were:

The Fedora 9 Installation Guide chapters 12 and 13.
http://www.matthewjmiller.net/howtos/dual-boot-linux-and-windows/
http://highlandsun.com/hyc/linuxboot.html
http://www.canerten.com/dual-boot-linux-and-windows-with-windows-boot-manager/
http://www.topklik.com/articles/2007/08/09/fedora-7-network-installation-and-dual-boot-with-win-xp/

Thanks to all concerned!

No comments: