HOWTO: Dual boot Sabayon Linux and Windows

From Sabayon Wiki
Revision as of 05:27, 25 October 2012 by Hatalar205 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
i18n: de en tr

Configure a PC to dual boot Sabayon Linux and Windows

This article explains how to configure your PC in order to dual boot Sabayon Linux and Windows Vista or Windows 7.


Question.png
September 2010: It has been established recently that some Windows applications can make a Grub2-based system unbootable if Grub2 is installed in the MBR. See the blog article Windows applications making GRUB 2 unbootable for details. The method described in Section 1 below does not result in Grub2 code being installed to the MBR, so will avoid this problem.


Windows is already installed

If you already have Windows Vista or Windows 7 installed on your HDD (hard disk drive) in a single partition, then the procedure given below is the best way of ensuring that your Windows installation will still be bootable even if the Linux installation or Grub bootloader become damaged in future. Furthermore, if your PC has a hidden factory restore partition for Windows, the method below is the best way of ensuring that you will still be able to recover Windows in future using that hidden partition. The reason for this is because the method described here does not alter the bootloader in the MBR, which may contain code created by the manufacturer to boot the hidden factory restore partition instead of the Windows Vista/7 partition if it detects a defined key or keys pressed while booting the PC. If the contents of the original MBR are overwritten -- even if it is only by using the Bootrec.exe tool on a standard Windows Vista/7 Installation DVD -- then the manufacturer's code will no longer be in the MBR and so it will no longer be possible to boot the hidden factory restore partition by pressing the key(s) specified by the manufacturer.

Step 1: Reduce the size of the existing partition

Stop.png
Do not use the partition managers Parted, GParted or KDE Partition Manager to reduce the size of the existing Windows partition, or you will damage your Windows installation.

a) Use the Windows defragmenter or a third-party defragmenter to defragment the Windows partition.

b) Use Windows' Disk Management to shrink the partition (see http://www.howtogeek.com/howto/windows-vista/resize-a-partition-for-free-in-windows-vista/). However, the problem with this method is that Windows will only shrink the partition until it reaches the MFT (Master File Table), which means there may be free space in the Windows partition that you would have wanted to use in a Linux partition but cannot.

c) If you cannot shrink the Windows partition to the size you want by using Windows' Disk Management, then you need to move the MFT (see http://www.howtogeek.com/howto/windows-vista/working-around-windows-vistas-shrink-volume-inadequacy-problems/). Basically you need to download a shareware ('trialware') tool that will move the MFT and defragment the Windows partition to a size you select.

Step 2: Create the new partitions for Linux

Boot a LiveCD or LiveDVD which has GParted on it, and run GParted to create and format partitions for Linux (for example /, /boot, /home and swap) in the free space you created in Step 1 above.

Question.png
SystemRescueCD is one good LiveCD to use for running GParted. You can download the ISO file from the SystemRescueCd Web site http://www.sysresccd.org/Main_Page.


Question.png
It is only possible to have up to four primary partitions on a HDD, so, depending on the Linux partitions you decide to create, it is possible that you will need to create an extended partition containing logical partitions. If, for example, your HDD has a hidden Windows factory restore partition and a partition for Windows itself, and you decide you want to have /boot and /home on separate partitions to the root directory, then one of many possible partitioning schemes would be:

- the hidden Windows factory restore partition (a Primary partition)

- the Windows partition (a Primary partition)

- the /boot partition (a Primary partition)

- an Extended partition containing the following Logical partitions:

- the swap partition

- the / (root) partition

- the /home partition
IMPORTANT ! You need to change /dev/sda on the bootloader option page of the Installer

With Sabayon 5.4 this page comes directly after you have created your partition and clicked "yes" to write to disk. At the top you will see the check box is enabled to use /dev/sda. Next to this you will see a button named "change". Click the change button and select the other choice that was not the default (probably /dev/sda3). Make sure the check box is still enabled, and click next after you have made the change. Finish the install and click reboot when it's done. During reboot you will be booted into Windows with no choice for the Sabayon installation (don't panic).

Step 3: Install the Grub bootloader and Linux

Boot Windows Vista/7 and download the freeware tool EasyBCD from the NeoSmart Web site. N.B. You will need to download EasyBCD version 2.* if you want to install a Linux distribution that uses Grub2 (e.g. Sabayon Linux 5.2 or later); it is available to download from http://neosmart.net/dl.php?id=1. If you are going to install a Linux distribution that uses Grub1 a.k.a. Grub Legacy (e.g. Sabayon Linux 5.1-r1 or earlier) then the current version of EasyBCD should work too. Follow the instructions on the EasyBCD site for how to install Linux (http://neosmart.net/wiki/display/EBCD/Linux). N.B. You will reach a point in the Linux installation process when you can make a choice of where to install the Grub bootloader: in the MBR (Master Boot Record) of the HDD or in the first sector of the Linux boot partition. You must select the latter, not the MBR. If you created a separate partition for /boot then Grub will be installed on that separate partition, whereas, if you did not create a separate partition for /boot then Grub will be installed on the partition containing the root directory (for Sabayon Linux this choice is explained at the end of Step 2).

The result of Step 3 is that, when you boot your PC, the Windows Vista/7 bootloader will load the Grub bootloader, and the Grub bootloader will load Linux. This process is called 'chainloading'. When you boot the PC you will first see the Windows bootloader menu and you can select Windows or Linux from it. If you select Linux then you will see the Grub menu and you can select Linux from that menu.

Original article created by Fitzcarraldo on 9 May 2010.

Clean Install of both Sabayon GNU/linux and Windows

As in life, there are many options... So many options that your eyes will be bleeding from all the reading you will do if you care to search it out. I'll try to keep it as simple and painless as possible, but feel free to do your own experimenting. I highly recommend not activating Windows nor updating Windows or Sabayon until you can boot into both cleanly, in case for whatever reason you want to reinstall.

Optional, but I recommend a clean install with a wiped hard drive first. One pass with shred is not too painful.

Install Windows on one partition, using about 50% of the free space.

You need to decide the percentage of hard drive space you want for each operating system. I usually aim for about 50% Windows, 50% Sabayon, but your needs and volume may vary. Even though you installed on one partition, two partitions were created: one for Windows and one as a boot partition. Hard drives allow four primary partitions, which means that you can create two further primary partitions. I highly recommend not activating Windows nor updating anything until you can boot into both systems cleanly, in case you need to reinstall. . .

Run the Sabayon LiveDVD

Load to the desktop on the LiveDVD. Click on the "install Sabayon" icon.

Begin the installation process. The first few screens are pretty straightforward. The screen that asks "What type of installation would you like?" is for selecting a partition scheme. On this screen I suggest the following:

Create partitions, select "create custom layout"

Select "create custom layout", and click next.

You will see your two Windows partitions; don't touch those. Click on the the area that shows free space, so that it is highlighted. Once free space is highlighted click the button that says "create". Because we only have the possibility to create two more primary partitions, and we want more partitions, we will use the LVM to first create one physical volume, then create four logical partitions inside of it. (N.B. It is not essential to create a LVM volume: an extended partition can be used instead to contain logical partitions.)

Create LVM physical volume.

In the small pop up window select the create LVM volume, and change the number of MB to all of the available free space (or the amount you want if you have other plans). This should be about the remaining 50% of the hard drive. Click "ok". Now we need to create our logical partitions into which to install Sabayon.

Create LVM Volume Groups.
Stop.png
This procedure works, but i have found i can not see swap after installation using LVM. As of yet, I'm not certain if swap is working with LVM groups. I do know swap works on its own primary partition. I have reports it also works on an extended partition. If you have a small amount of ram you may wish to take this into consideration.

On the same page you will now click on the LVM physical volume you just created so that it is highlighted, and click the "create" button. In the small pop up window select "create LVM group", and click ok. You need to create the partitions into which to install Sabayon. You do this by clicking the ADD button in the new pop-up window. I suggest the following partitions inside the LVM groups: 100MB for boot using ext4, 1-4GB for swap (based roughly on your physical memory amount), 25-30GB for / (root), a little smaller may be ok but /var is inside it, and finally I put the remaining space into /home (this should be the largest of the four new volumes as all of your personal data and downloads will be stored here). When you finish you should see a lock symbol next to "physical volume (LVM)". Click "Next" when you are ready.

After it finishes formatting and writing to disk, you will have a chance to set a password for the bootloader. I would NOT set the password for the bootloader yet. I would want to make sure I can boot into Sabayon and Windows first, then set a bootloader password later. But you also need to make a decision...

Decision Time: Boot from Windows bootloader or the Grub/Linux bootloader

You may wish to consider if issues of "plausible deniability" are important to you, where you may wish to hide the existence of one of your operating systems. To use the boot options from Windows you would want to use EasyBCD, or you can use the boot options screen that installs with Sabayon. I have generally found it easier to use Grub and the Linux boot menu, as it's painless to reinstall Grub if issues arise, but using the Windows loader with EasyBCD and with TrueCrypt installed gives nice options for plausible deniability. Choose one of the following options below:

Option 1 (To use Grub bootloader)

Simply click next on bootloader option screen and make NO changes.

This page comes directly after you have created your partition and clicked "yes" to write to disk. Simply click "next" on bootloader option screen, without changing anything. There is a check box that is enabled by default to use /dev/sda. N.B. this will overwrite the MBR, which you should not do if you do not want to risk a) losing the ability to boot a Windows factory restore partition and b) the possibility of Windows applications later overwriting Grub2 code in the MBR. Change nothing and you will use Grub and the Linux bootloader. Finish the installation and click the reboot button when it is done. During reboot look to see if Windows was one of the boot options on the Grub menu. If not, continue to the Sabayon desktop and reinstall Grub, or you can load the LiveDVD and reinstall the bootloader. To use the LiveDVD, boot the LiveDVD and run to the desktop. Click the "install Sabayon" icon (don't panic). You only begin the first couple of steps, and then you will have the option to fix your bootloader. Don't change the settings, just reinstall the bootloader.

Option 2 (To Use EasyBCD and the Windows bootloader)

Click "CHANGE" on the bootloader option page.

This page comes directly after you have created your partition and clicked "yes" to write to disk. At the top you will see the check box is enabled to use /dev/sda. Next to this you will see a button named "change". Click the change button and select the other choice that was not the default (probably /dev/sda3). Make sure the check box is still enabled (I would NOT set a bootloader password yet), and click next after you have made the change. Finish the install and click "reboot" when it's done. During reboot you will be booted into Windows with no choice for the Sabayon installation (don't panic). Download and install EasyBCD. Run EasyBCD. Click the "Add new entry" button on the left, then click the "Linux/BSD" tab on the top. Change the boot entry to "Grub 2". Change the Linux name to "Something Cool". Click the "ADD" button. Click the "Edit Entries" button on the left. Click the "Save" button on the bottom. Close it and restart.

Check that you can boot into both operating systems.

Links and and further information

Clean Install section created and authored by Skull Fire on Dec. 18th, 2010, using information learned from the open-source GNU/Linux and open-source BSD communities. You guys rock!