Managing partitions

From Wikislax
Jump to: navigation, search

Linux won't probably be the only system on your hard disk so this page tells you how to get different operating and file systems to coexist, storing each of them in one partition.

Intel disk architecture

The Intel disk architecture affords defining a maximum of 4 partitions on each physical disk. These partitions can be primary or extended. It is possible to include secondary partitions inside an extended partition. This affords increasing the number of partitions, but extended and secondary partitions are not directly bootable. Bootable means that the bootloader on the partition can be used by the bios to boot itself or another partition. Only one of the primary partitions receives the active flag, which designates it to the bios as the partition to be booted.

Partition management

Designating the active partition and other basic partition management is part of operating system installation, but a few software programs afford more flexible and sophisticated operations. gparted, the gnome partition editor, is available on a Live Linux CD and is also part of the SystemRescueCD distribution, that can be installed on a USB stick. Gparted affords creating, deleting, redimensionning, copying, formatting partitions and more. Managing partitions remains dangerous however, so be sure that any particular disk not required during operations is physically disconnected – as there is always a possibility to boot from or write to the wrong disk. Last note, Gparted is also included with the Slackware distribution however cannot be used with mounted partitions.

The Bootloader

The first 512 bytes of each partition – called the Master Boot Record – contain the code to load and run the bootloader, a program to – in turn – load and run the rest of the system. Each system comes with its bootloader. There is one for Windows XP, one for Windows 7, and two for Linux : lilo and grub. All these bootloaders afford booting not only from their own partition, but from other partitions as well. This mechanism – called multiboot – affords choosing at the very beginning of the startup which system to actually boot. Interestingly, multiboot affords booting also secondary partitions, which normally would not be bootable, as they cannot be designated as active.

The Lilo bootloader

Slackware Linux comes with both lilo and grub, with lilo as the standard. Lilo affords multiboot. At the end of the Slackware installation, you are proposed to choose which systems to include, and you are asked which boot sector to use, Master Boot Record or main partition. Choosing Master Boot Record will use the partition first sector, while choosing the main partition will use the disk first sector, replacing any bootloader there by Lilo. The information you provide is written into /etc/lilo.conf, then taken as input by the lilo command to generate the boot sector. /etc/lilo.conf can be edited afterwards, and lilo reused at anytime afterwards to generate an updated boot sector.

Note : just editing /etc/lilo.conf without running lilo after is not enough as lilo needs to recompute the kernel position on disk in order to boot properly. This is not the case with grub, who is able to locate the kernel to boot dynamically at boot time - a handy feature.

The Grub bootloader

Slackware Linux comes with both lilo and grub, with grub as an option. Grub is the acronym for "Grand Unified Bootloader". Grub was developped to offer more sophistication than Lilo was able to offer. Once installed at the root of the disk, Grub is able to bootload any other system on any other partition of the disk by simply modifying configuration files. This is a handy feature that makes the exercize of getting a new system to boot much simpler.

Grub will be required if you want to use Xen. Slackware includes Grub but installs Lilo by default so you will need to install the grub bootloader after the Slackware installation. Get more details on the Using Grub2 page.

The Windows 7 bootloader

The Windows 7 bootloader can boot Linux partitions. The bcdedit command affords viewing the bootloader configuration and creating and updating new entries to boot. bcdedit needs to be ran from a console with administrator priviledges. Go to “start” “accessories” then right click on “Ms command” and choose “run with administrator privileges” (you need to use an administrator account). To specify a new partition to boot use the /create selector that will give in return the identifier created by the system, that needs to be used in subsequent invocations.

C:\> bcdedit /create /d “Linux” /application BOOTSECTOR
Entry {1e9b74ee-2bd3-11dd-af47-005056c00008} was correctly created.
C:\> bcdedit /set {1e9b74ee-2bd3-11dd-af47-005056c00008} device partition=C:
C:\> bcdedit /set {1e9b74ee-2bd3-11dd-af47-005056c00008} path \Boot\Linux.mbr
C:\> bcdedit /displayorder {1e9b74ee-2bd3-11dd-af47-005056c00008} /addlast
C:\> bcdedit /default {1e9b74ee-2bd3-11dd-af47-005056c00008}
C:\> bcdedit /timeout 5

The file specified must be created in the Windows partition and contain a copy of the 512 bytes of the boot sector of the partition to boot. This can be done at the end of the Linux installation (Slackware proposes to create the required /etc/fstab entries during the installation process) with commands such as :

# mount -t ntfs /dev/sdaX /mnt/win7
# dd if=/dev/sdaY of=/mnt/win7/Boot/Linux.mbr bs=512 count=1
# sync
# umount /mnt/win7

"if" is the source boot sector and should be /dev/sdaY if on the Master Boot record, or /dev/sda if on the main partition.

Note : if you inadvertently overwrite the boot sector of your main Windows partition /dev/sda(X), there is a menu option on the Windows 7 installation CDROM that affords fixing the MBR and restore the original boot sector.

The Windows XP bootloader

The Windows XP bootloader can boot Linux partitions, adding in the system list after the [operating systems] tag of the c:\boot.ini file a line such as: C:\linux.pbr="Slackware x.y". The file specified must be created in the Windows partition and contain a copy of the 512 bytes of the boot sector of the partition to boot. This can be done at the end of the Linux installation (Slackware proposes to create the required /etc/fstab entries during the installation process) with commands such as :

# mount -t ntfs /dev/sdaX /mnt/winxp
# dd if=/dev/sdaY of=/mnt/winxp/Boot/Linux.pbr bs=512 count=1
# sync
# umount /mnt/winxp

"if" is the source boot sector and should be /dev/sdaY if on the Master Boot record, or /dev/sda if on the main partition.

Note : if you inadvertently overwrite the boot sector of your main Windows partition /dev/sda(X), the R option on the Windows XP installation CDROM affords using the FIXMBR command to restore the original boot sector. However you must provide the administrator password specified when you installed the system for the first time. After 3 failed attempts you will need to reboot (this takes quite a bit of time).

Note : if the administrator password has been changed, the new administrator password will not work. Only the administrator password specified when you installed the system for the first time will work.

Copying Linux partitions

It is easy to set up Linux on one computer then copy the partition to another disk and boot from another computer. There are two conditions :

  • First, the kernel must be able to manage the target system hardware, so if not using a generic kernel, be sure to include the required drivers
  • Second, the bootloader and configuration on the target disk must be properly setup and correspond to the partition number.


Choosing a System Main Page DVDless install