• Aucun résultat trouvé

Resizing Current Partitions

Dans le document Linux Security (Page 85-88)

If your hard drive currently is taken up by partitions for other operating systems, you need to delete and resize these partitions to allocate space for Linux. There is no safe or reliable way to resize an existing partition without deleting it. An inter-esting experiment is however being carried out by the GNU community at

www.gnu.org/software/parted/. In any case, before repartitioning your drive, you should back up your system. After you have repartitioned the drive, you can reinstall your original software..

Here are the two commands you can use for managing the partitions:

fdisk.

cfdisk.

In the sections that follow, I discuss each of these commands in detail.

fdisk

You use the fdiskcommand to create and manipulate partition tables. The fdisk command is used with DOS type partitions. In addition, it is also compatible with BSD or SUN type disk labels. The volume headers should not be covered by any partition. If you do this, the partition table will be lost.

You can have numerous partitions in a DOS type partition table. In sector 0, there is space for a description of four partitions, called primary partitions. One of these can be an extended partition. The four primary partitions get numbers ranging from 1 to 4. Logical partitions start with the number 5.

The geometry specifies the number of heads and the number of sectors for each track. The fdisk command will automatically try to get the disk geometry. This is not necessarily the physical disk geometry; however, this is the disk geometry that MS-DOS uses for the partition table. If you have only Linux on your com-puter, you shouldn’t have any problem. On the other hand, if multiple operating systems are installed on your computer, you should run the fdiskcommand from the operating systems other than Linux. You should do this to create at least one partition.

When you start Linux, the operating system tries to obtain information about the disk geometry by reading the partition table. The partition table is checked for the integrity for its entries. This happens when the partition table is printed. The check is done to ensure that the logical start and end is the same as that of the physical start and end. The check also ensures that the starting and ending points of the partition is the cylinder boundaries. This may not be necessary for the first partition.

cfdisk

The cfdiskcommand is used for partitioning the hard disk drive. To write to the partition table,cfdiskneeds the geometry of the disk. If the disk is not accessed by other operating systems, you can safely accept the defaults that cfdiskselects.

I’ll now explain the geometry used by the cfdiskcommand. First, the partition table is examined to determine the geometry used by the previous program that changed it. If the partition table is empty, contains garbage, or does not reveal a consistent geometry, the kernel is referred.

The cfdiskcommand reads the current partition table from the disk drive. An error message is generated in case it is unable to do so. The error message also can be displayed due to incorrect geometry information. You also can solve this prob-lem by using the –z option of the cfdiskcommand. The –zoption ignores the partition table.

The main display consists of four sections:

Header. This section contains the program name and the version num-ber. In addition, it contains the disk drive and geometry information.

Partition. This section displays the current partition table.

Command Line. This section contains the available commands.

Warning Line. This section contains information, such as the warnings to be displayed.

The current partition is highlighted with a reverse video or an arrow, if the –a option is given. All partition-specific commands apply to the current partition.

The fdiskcommand can create either primary of logical partitions. The file sys-tem of the partition is displayed in the file syssys-tem type section. If the file syssys-tem is not known, the Unknownvalue and the hex value of the file system get displayed.

The Unusablevalue is displayed for the file system type when all the primary par-titions are used. The partition size is displayed in the size field. If the partition is not aligned on cylinder boundaries, an asterisk is displayed after the size.

Given here is a list of the commands available:

bb. This command toggles the bootable flag of the current partition. The toggling of the bootable flags enables you to select the primary partition.

dd. This command deletes the current partition.

gg. This command changes the disk geometry.

hh. This command prints the help screen.

mm. This command maximizes disk use of the current partition.

nn. This command creates a new partition from free space. If the parti-tion type is primary or logical, a partiparti-tion of primary or logical type is created. On the other hand, if the partition type is Pri/Log, you are prompted for the partition type that you want to create.

pp. This command prints the partition table to the screen or to a file.

qq. This command quits the program.

tt. This command changes the file system type on the partitions.

uu. This command changes the units of the partition size display.

WW. This command writes a partition table to disk. This command might destroy the existing data on the disk. Therefore, you should use this command judiciously. While running this command, you are prompted for the confirmation.

??. This command prints the help screen.

Dans le document Linux Security (Page 85-88)