SDB:Install another distribution
Recommended articles
Related articles
Linux multiboot pitfalls
A Linux installation requires a bootloader to boot, and if several installations are required on the same computer - especially on the same hard disk - care must be taken to ensure that they each have their own bootloader, or that the bootloader they share is correctly configured for all of them.
Typically, it is also desirable to be able to share data between installations, and although this can be achieved by sharing a single 'home' partition, this can cause serious and hard to detect problems when one installation's configuration files (such as dotfiles [1]) are overwritten by another. It is preferable to use a neutral 'data' partition, and then automatically mount it at boot, with the desired read and write permissions for user accounts. Optionally, users' data directories such as 'Documents' and 'Music', or specific files such as a browser's bookmarks, can be placed on the shared data partition, and then symbolic links (symlinks [2]) can be used to access them transparently and safely. This HOWTO will explain all of these steps.
Layout and strategy
Before installing anything, decide how you intend to divide your disks between installations, and control which system boots. Although many strategies for controlling the boot exist, two will be described in detail here - which you pick will depend in part on your hardware setup.
If you can place each Linux (or similar Unix-like operating system) installation on a separate disk, the easiest way to determine which system boots is to use a BIOS popup menu - usually accessed by pressing a key such as Esc
during the boot. If your system has such a menu, this is a perfectly viable and simple solution. Consult your motherboard or computer manual to check.
- Allocate a separate disk for each Linux root partition.
- Other Linux partitions (such as home, data or swap partitions) and Windows installations do not need a separate disk.
Strategy two: Using a primary bootloader
If you need to place more than one Linux (or similar Unix-like operating system) installation on any given disk, an effective strategy is to use one bootloader to chain load [3] the others.
- Designate one Linux installation which you will use to control the boot. We will call this your primary Linux, and the disk it is on your primary disk.
- Partitions can be placed anywhere the system allows.
Alternative strategies
If you have many Linux installations, you may consider using a GRUB partition. See [4]
Partitioning and installation
First, space must be created for the additional Linux installations, and optionally a data partition. You can create the partitions before installation, using a specialist tool such as GParted Live [5], or a standard Linux live system such as an openSUSE LiveCD, or you can create them within the installation routines as you install.
Preparation
If you need to shrink a Windows partition, it is very important that you defragment it several times first to avoid data loss. Then resize the partition using the Windows partition tools - consult your Windows documentation. Linux partitions do not normally require defragmentation.
General considerations
- You can only create four primary partitions per disk on a standard partition table - you may need to delete one and turn it into an extended partition in order to create more. Please refer to SDB:Basics of partitions, filesystems, mount points
- There are system dependent limits on partition sizes, and how far into the disk a bootable partition can be placed. This should not present a problem on modern systems, but if an installation refuses to boot, it is possible that moving it closer to the start of the disk will help.
- Many people share a swap partition between different Linux installations to save space, but this can cause problems if you hibernate one system, then boot another. If you have problems with resuming from hibernation, consider trying separate swap partitions.
- It is normally recommended that you create a separate home partition when installing Linux, rather than leaving your users' home directories on the root partition. This isolates the users' data from the system files, and allows easier backing up and reinstalling, or upgrading between versions. If you are installing lots of different Linux systems in parallel, you will end up with lots of partitions, which can create confusion, but on modern systems will not normally cause problems in itself. Alternatively, bear in mind that if you are using a data partition, your users' data files will not take up space on the partition with the home directories on. Leaving the home directories on the root partitions is therefore less problematic.
- If you wish to use a data partition you should ensure that you format it to a file system that all of your Linux installations can read. If you are unsure, ext3 and increasingly ext4 are safe options.
Installation
Install each system (for tips on moving bootloaders on systems you have installed already, see next section).
- For any Linux installed to a disk with another operating system (such as Windows) on already, install the bootloader to the root partition. The MBR may well contain boot code which will allow other systems on the disk to boot, and it should not be altered unnecessarily. See following section for tips.
- For each disk with no other operating system on already, install one Linux bootloader to the MBR (this must include the primary Linux's bootloader, if it is on such a disk). Install any other bootloaders to their root partitions.
- Be aware that some Linux installation routines may install to the MBR of the first disk without permission. See Repairing a Windows boot sector if required.
Create user accounts in the same order for each Linux installation to simplify data sharing - see Sharing access to data below for details.
Fixing the boot
Now ensure that each system can boot, and that the correct system boots by default.
Use the BIOS popup menu to attempt to boot each Linux system. For any that do not boot;
- You may need to set the bootable flag to the root partition. See Setting the bootable flag
- You may need to manually reinstall the bootloader. See Manually installing a bootloader
Strategy two: Using a primary bootloader
Boot the system. If your primary Linux does not boot;
- You may need to set your primary disk to boot first in the BIOS. Consult your motherboard or computer manual.
- You may need to set the bootable flag to your primary Linux's root partition. See Setting the bootable flag
- You may need to manually reinstall the bootloader. See Manually installing a bootloader
The primary Linux system should now boot. Depending on which bootloader your primary Linux uses, use the following instructions to prepare it to boot the other Linux installations.
LILO
As root, edit the file /etc/lilo.conf
Add the following lines for each installation;
other=/dev/hdXY label="<name>"
Substituting the disk number for X, the partition number for Y, and an appropriate name for <name>. To chain load a bootloader on the MBR of a disk, just use hdX. Save the file, then run;
To update LILO.
GRUB
GRUB (sometimes called GRUB 1 or GRUB legacy) is any version of GRUB before 1.9. As root, edit the file /boot/grub/menu.lst
In the section containing the menu entries, add the following lines for each installation;
title <name> rootnoverify(hdX,Y) chainloader +1
Substituting the disk number for X, the partition number for Y, and an appropriate name for <name>. Remember that GRUB counts from zero, so disk one, partition one would be called (hd0,0). To chain load a bootloader on the MBR of a disk, just use (hdX). Save the file.
If you have problems finding a partition, try running the following commands as root;
GRUB should return a list of bootable partitions, with LILO, GRUB and GRUB 2 on respectively.
GRUB 2
GRUB 2 (versions 1.9 and onwards) is designed to automatically detect other operating systems. Run the following command, as root;
Hopefully, upon reboot, your system will have detected your other installations. If any have not been correctly detected, edit the file /etc/grub.d/40_custom as root. Add the following lines for each installation you wish to chain load;
menuentry "<name>" { set root=(hdX,Y) chainloader +1 }
Substituting the disk number for X, the partition number for Y, and an appropriate name for <name>. Remember that GRUB 2 counts disks from zero and partitions from one, so disk one, partition one would be called (hd0,1). To chain load a bootloader on the MBR of a disk, just use (hdX). Save the file.
Optionally, if you are chain loading all your other operating systems, you can disable the script which attempts to automatically detect them, to reduce menu clutter. As root;
Before rebooting, you will need to update GRUB 2. As root;
Sharing access to data
This section contains optional suggestions.
User identifiers
Linux determines filesystem permissions with a User Identifier (UID [7]). Normally, each user's UID should be unique, and above 999. If you have set up the users in the same order on each system, they may not need adjusting. Check by booting each system, and for each user, running;
Substituting the username, and entering their password when requested. For any which are incorrect, change them as root with;
Substituting the desired UID and the username. Files belonging to the user but outside the user's home directory may need to have their ownership changed to the new UID, although this shouldn't be a problem with a new install.
Mounting a data partition automatically
To automatically mount a data partition at boot, boot into each installation. Make a mountpoint, by running, as root;
Edit the file /etc/fstab, also as root. Add the following line;
/dev/sdXY /mnt/data <filesystem> defaults 0 2
Substituting the data partition's disk number for X, its partition number for Y, and the filesystem you have formatted it to. Depending on your distribution's security model, you may need to alter the permissions with 'umask'. Check your local 'man fstab', or your distribution's instructions.
Sharing user data directories
You can also place the users' data directories, such as 'Music' and 'Documents', on the data partition, so they will be shared between different installations.
Ensure that your data partition is mounted. As root;
Create a directory on the data partition for each account you wish to use shared directories for;
Create each shared directory;
Ensure that the original data directory is empty;
If anything (apart from '.' and '..') is present, move it somewhere safe. Remove the directory;
Create a symbolic link to its new location;
Boot into each Linux system which will use the shared directory. Repeat the steps from 'Ensure that the original data directory is empty'. Finally, ensure that the directories have correct ownership;
Sharing other files
Other files, such as a browser's bookmarks, can be shared in the same manner. When it is safe to do this is a judgement call; always maintain good backups, as accessing a file from two different versions of the same software can potentially cause program or system instability and data loss.
See also
External links
- If you get stuck, search the forums, and if still stuck, start a thread: [8]
- For GRUB partitions: [9]