Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the parted command in linux

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use the parted command in linux. It is very detailed and has a certain reference value. Friends who are interested must finish it!

The parted command is a powerful disk partition and partition resizing tool developed by the GNU organization. Unlike fdisk, it supports resizing partitions. As a tool designed for Linux, it is not built to handle multiple partition types associated with fdisk, but it can handle the most common partition formats, including: ext2, ext3, fat16, fat32, NTFS, ReiserFS, JFS, XFS, UFS, HFS, and Linux swap partitions.

Img

Usage: parted [option]... [device [command [parameter]...] []

Help options:

-h,-- help displays this help message-- l,-- list lists all other partition information-I,-- interactive, if necessary, prompts the user-s,-- script never prompts the user-v,-- version display version

Operation command:

Cp [FROM-DEVICE] FROM-MINOR TO-MINOR # copy the file system to another partition help [COMMAND] # print general help information Or information about COMMAND mklabel label type # create a new disk label (partition table) mkfs MINOR file system type # create a file system mkpart partition type [file system type] start and end point # create a partition mkpartfs partition type in MINOR File system type start point end point # create a partition move MINOR with file system start point end point # move the partition number MINOR name MINOR name # name the partition number MINOR print [MINOR] # print the partition table Or partition quit # exit program rescue start point and end point # save near "starting point", The missing partition of the "termination point" resize MINOR start point end point # change the size of the file system in the partition numbered MINOR rm MINOR # delete the partition select device numbered MINOR # Select the device set MINOR flag status to edit # change the logo of the partition numbered MINOR

Operation example:

1. Select a partitioned hard disk

First of all, like fdisk, select the hard disk to be partitioned, here is / dev/hdd: ((parted) indicates the command entered in parted, and the other information is automatically printed)

[root@10.10.90.97 ~] # parted / dev/hddGNU Parted 1.8.1Using / dev/hddWelcome to GNU Parted! Type 'help' to view a list of commands.

2. Create a partition

After selecting / dev/hdd as the disk for our operation, we need to create a partition table (you can use the help command to print help information in parted):

(parted) mklabelNew disk label type? Gpt (if we want to correctly partition disks larger than 2TB, we should use the partition table in gpt mode. Enter gpt and enter)

3. Complete the partition operation

After you have created the partition table, you can perform the partition operation, execute the mkpart command, and enter the partition name, file system and partition start and end location, respectively.

(parted) mkpartPartition name []? Dp1File system type? [ext2]? Ext3Start? 0 (can be expressed as a percentage, e.g. Start? 0%, End? 50%) End? 500GB

4. Verify the partition information

After dividing the zone, you can use the print command to print the partition information. Here is an example of print

(parted) printModel: VBOX HARDDISK (ide) Disk / dev/hdd: 2199GBSector size (logical/physical): 512B/512BPartition Table: gptNumber Start End Size File system Name Flags1 17.4kB 500GB 500GB dp1

5. Delete partition example

If the partition is wrong, you can use the rm command to delete the partition. For example, we want to delete the partition above, and then print the deleted result.

(parted) the number of the partition used after rm 1 # rm is Number (parted) printModel: VBOX HARDDISK (ide) Disk / dev/hdd: 2199GBSector size (logical/physical): 512B/512BPartition Table: gptNumber Start End Size File system Name Flags printed with print

6. Complete example

Divide the whole hard drive into areas according to the above method, and here is an example after division

(parted) mkpartPartition name []? Dp1File system type? [ext2]? Ext3Start? 0End? 500GB (parted) mkpartPartition name? Dp2File system type? [ext2]? Ext3Start? 500GBEnd? 2199GB (parted) printModel: VBOX HARDDISK (ide) Disk / dev/hdd: 2199GBSector size (logical/physical): 512B/512BPartition Table: gptNumber Start End Size File system Name Flags1 17.4kB 500GB 500GB dp12 500GB 2199GB 1699GB dp2

7. Format operation

When we are done, we can exit parted using the quit command and format the partition using the system's mkfs command.

[root@10.10.90.97 ~] # fdisk-lWARNING: GPT (GUID Partition Table) detected on'/ devmax HDD lWARNING! The util fdisk doesn't support GPT. Use GNU Parted.Disk / dev/hdd: 2199.0 GB, 2199022206976 bytes255 heads, 63 sectors/track 267349 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System/dev/hdd1 1 267350 2147482623 + ee EFI GPT [root@10.10.90.97] # mkfs.ext3 / dev/hdd1 [root@10.10.90.97] # mkfs.ext3 / dev/hdd2 [root@10.10.90.97] # mkdir / dp1 / dp2 [root@10.10.90.97] # mount / dev/hdd1 / dp1 [root@10.10.90.97] # mount / Dev/hdd2 / dp2 above is all the content of the article "how to use parted commands in linux" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report