Managing partitions

From Wikislax

Revision as of 20:22, 7 July 2012 by WikiSysop (Talk | contribs)
Jump to: navigation, search

Contents

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. 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. It 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 unplugged – as there is always a possibility to boot from or write to the wrong disk.

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 lilo only, not grub. 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 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.

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 9

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/linux.pbr 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.


Choosing a System Main Page Installing Slackware
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox