Chapter 5. Managing Disk Storage

After you have installed your Red Hat Linux system, you may want to view the existing partition table, change the size of the partitions, remove partitions, or add partitions from free space or additional hard drives. The utility parted allows you to perform these tasks. This chapter discusses how to use parted to perform file system tasks. Alternatively, you can use fdisk to perform most of these tasks, excluding resizing partitions. For more information on fdisk, refer to man or info page for fdisk.

If you want to view the system's disk space usage or monitor the disk space usage, refer to Section 26.3 File Systems.

You must have the parted package installed to use the parted utility. To start parted, at a shell prompt as root, type the command parted /dev/hdb, where /dev/hdb is the device name for the drive you want to configure. You will see a (parted) prompt. Type help to view a list of available commands.

If you want to create, remove, or resize a partition, the device can not be in use (partitions can not be mounted, and swap space can not be enabled). The easiest way to achieve this it to boot your system in rescue mode. Refer to Chapter 9 Basic System Recovery for instructions on booting into rescue mode. When prompted to mount the file system, select Skip.

Alternately, if the drive does not contain any partitions in use, you can unmount them with the umount command and turn off all the swap space on the hard drive with the swapoff command.

Table 5-1 contains a list of commonly used parted commands. The sections that follow explain some of them in more detail.

Command

Description

check minor-num

Perform a simple check of the file system

cp from to

Copy file system from one partition to another; from and to are the minor numbers of the partitions

help

Display list of available commands

mklabel label

Create a disk label for the partition table

mkfs minor-num file-system-type

Create a file system of type file-system-type

mkpart part-type fs-type start-mb end-mb

Make a partition without creating a new file system

mkpartfs part-type fs-type start-mb end-mb

Make a partition and create the specified file system

move minor-num start-mb end-mb

Move the partition

print

Display the partition table

quit

Quit parted

resize minor-num start-mb end-mb

Resize the partition from start-mb to end-mb

rm minor-num

Remove the partition

select device

Select a different device to configure

set minor-num flag state

Set the flag on a partition; state is either on or off

Table 5-1. parted commands

5.1. Viewing the Partition Table

After starting parted, type the following command to view the partition table:

print

A table similar to the following will appear:

Disk geometry for /dev/hda: 0.000-9765.492 megabytes
Disk label type: msdos
Minor    Start       End     Type      Filesystem  Flags
1          0.031    101.975  primary   ext3        boot
2        101.975    611.850  primary   linux-swap  
3        611.851    760.891  primary   ext3        
4        760.891   9758.232  extended              lba
5        760.922   9758.232  logical   ext3        

The first line displays the size of the disk, the second line displays the disk label type, and the remaining output shows the partition table. In the partition table, the Minor number is the partition number. For example, the partition with minor number 1 corresponds to /dev/hda1. The Start and End values are in megabytes. The Type is one of primary, extended, or logical. The Filesystem is the file system type, which can be one of ext2, ext3, FAT, hfs, jfs, linux-swap, ntfs, reiserfs, hp-ufs, sun-ufs, or xfs. The Flags column lists the flags set for the partition. Available flags are boot, root, swap, hidden, raid, lvm, or lba.

Tip

Tip

 

To select a different device without having to restart parted, use the select command followed by the device name such as /dev/hdb. Then, you can view its partition table or configure it.


ActorActressGallery.com

CheapConsumerElectronics.com

ArtistActorActress.com

Bill88.com

CalvaryMusic.org

Link-Web.net

NewReleaseBooks.com

GermanBooks88.com

GermanElectronics88.com

RingTone88.com

SmallPanda.com