Redhat disk partition tools




















The reason for doing this is to rearrange the data to maximize the available free space at the "end" of the partition. In the previous example, the first diagram represents disk before compression, and the second diagram after compression. This step is crucial. Without it, the location of the data could prevent the partition from being resized to the desired extent. Note that some data cannot be moved.

In this case, it severely restricts the size of your new partitions, and you might be forced to destructively repartition your disk. The following figure shows the actual resizing process. While the actual result of the resizing operation varies, depending on the software used, in most cases the newly freed space is used to create an unformatted partition of the same type as the original partition. In the previous example, the first diagram represents partition before resizing, and the second diagram after resizing.

It is important to understand what the resizing software you use does with the newly freed space,so that you can take the appropriate steps. In the case illustrated here, it would be best to delete the new DOS partition and create the appropriate Linux partition or partitions.

As mentioned in the example Resizing the existing partition , it might or might not be necessary to create new partitions.

However, unless your resizing software supports systems with Linux installed, it is likely that you must delete the partition that was created during the resizing process. In the previous example, the first diagram represents disk before configuration, and the second diagram after configuration. Chapter 3. Getting started with partitions. Viewing the partition table with parted.

Additional resources The parted 8 man page. Example output of parted print. Partition Table: msdos The disk label type. Number The partition number. Start and End The location on the device where the partition starts and ends.

Type Valid types are metadata, free, primary, extended, or logical. File system The file system type. If the File system field of a device shows no value, this means that its file system type is unknown. The parted utility cannot recognize the file system on encrypted devices. Flags Lists the flags set for the partition. Available flags are boot , root , swap , hidden , raid , lvm , or lba. Formatting a block device with a partition table deletes all data stored on the device.

Considerations before modifying partitions on a disk. On a device formatted with the Master Boot Record MBR partition table, you can have either: Up to four primary partitions, or Up to three primary partitions, one extended partition, and multiple logical partitions within the extended. The starting point of the partition is aligned to the exact sector specified by size. The ending point is aligned to the specified size minus 1 sector. Table 3. Disk with MBR partition table. The points on the disk where the partition starts and ends.

Whether the partition is active. Only one partition can be flagged as active. Disk with a single partition. The header contains the disk GUID, the location of the primary partition table, the location of the secondary GPT header, and CRC32 checksums of itself, and the primary partition table. It also specifies the number of partition entries on the table.

It is used mainly as a backup table for recovery in case the primary partition table is corrupted. The secondary GPT header is located on the last logical sector of the disk and it can be used to recover GPT information in case the primary header is corrupted.

It contains the disk GUID, the location of the secondary partition table and the primary GPT header, CRC32 checksums of itself and the secondary partition table, and the number of possible partition entries.

Creating a partition table on a disk with parted. Next steps Create partitions on the device. See Section 3. The parted utility provides some control of partition types by mapping the partition type to flags.

The fdisk utility supports the full range of partition types by specifying hexadecimal codes. For example, the swap , fat , or hfs file system types set different GUIDs. In systems with more than 26 drives, you can use more letters. N The final letter indicates the number that represents the partition. The first four primary or extended partitions are numbered 1 through 4. Logical partitions start at 5. Drive partition numbering applies only to MBR partition tables.

Note that N does not always mean partition. Prerequisites There is a partition table on the disk. For details on how to format the disk, see Section 3. If there is not enough free space, you can resize an existing partition. For more information, see Section 3. From the partition table, determine: The start and end points of the new partition On MBR, what partition type it should be. Replace part-type with with primary , logical , or extended based on what you decided from the partition table.

This applies only to the MBR partition table. Replace name with an arbitrary partition name. For example, to create a primary partition with an ext3 file system from megabytes until megabytes on a hard drive type the following command:. If you use the mkpartfs command instead, the file system is created after the partition is created.

However, parted does not support creating an ext3 file system. Thus, if you wish to create an ext3 file system, use mkpart and create the file system with the mkfs command as described later. The changes start taking place as soon as you press Enter , so review the command before executing to it. After creating the partition, use the print command to confirm that it is in the partition table with the correct partition type, file system type, and size. Also remember the minor number of the new partition so that you can label it.

You should also view the output of. Formatting the Partition. Formatting the partition permanently destroys any data that currently exists on the partition.

Labeling the Partition. Next, give the partition a label. By default, the installation program uses the mount point of the partition as the label to make sure the label is unique. You can use any label you want. Creating the Mount Point. The new line should look similar to the following:.

The second column should contain the mount point for the new partition, and the next column should be the file system type for example, ext3 or swap. If you need more information about the format, read the man page with the command man fstab. If the fourth column is the word defaults , the partition is mounted at boot time.

To mount the partition without rebooting, as root, type the command:. Removing a Partition. Do not attempt to remove a partition on a device that is in use. Before removing a partition, boot into rescue mode or unmount any partitions on the device and turn off any swap space on the device.

View the current partition table to determine the minor number of the partition to remove:. Remove the partition with the command rm. For example, to remove the partition with minor number The changes start taking place as soon as you press Enter , so review the command before committing to it.

You are creating a new primary partition using the ext4 architecture. For demonstration purposes, I chose to create a 50 MB partition. Now that you have created the new partition at 50 MB, you can resize it to MB, and then shrink it back to the original 50 MB. First, note the partition number. You can find this information by using the print command. You are then going to use the resizepart command to make the modifications. You can then verify the changes with the print command. You can now resize it back down to 50 MB.

Keep in mind that shrinking a partition can cause data loss. Again, you will need the partition number, which is found in the print output. NOTE: Be sure that you have all of the information correct here, there are no safeguards or are you sure? When you run the rm command, it will delete the partition number you give it.

Parted is another great option for manipulating hard disks in Linux, and is about as easy to use as any tool I've seen! From creation, deletion, shrinking, extending, etc, there is so much functionality offered.

I highly recommend that you take the time to learn parted , and if you have the chance, consider using it to accomplish your next partitioning job! Take a skills assessment today. Tyler is a community manager at Enable Sysadmin, a submarine veteran, and an all-round tech enthusiast! More about me. Relive our April event with demos, keynotes, and technical sessions from experts, all available on demand.

Enable Sysadmin.



0コメント

  • 1000 / 1000