In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to use parted to partition disk in Linux". In daily operation, I believe that many people have doubts about how to use parted in Linux to partition disk. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubt about "how to use parted in Linux". Next, please follow the editor to study!
Creating and deleting partitions in Linux is a common operation because storage devices, such as hard drives and USB drives, must be structured in some way before they can be used. In most cases, large storage devices are divided into separate parts called partition partition. Partitioning allows you to split the hard disk into separate parts, each of which is like a hard drive. Partitioning is very useful if you are running multiple operating systems.
There are many powerful tools in Linux to create, delete, and manipulate disk partitions. In this article, I'll explain how to use the parted command, which is particularly useful for large disk devices and many disk partitions. The differences between parted and the more common fdisk and cfdisk commands include:
GPT format: the parted command creates a globally unique identifier partition table GPT, while fdisk and cfdisk are limited to DOS partition tables.
Larger disks: DOS partition tables can format up to 2TB of disk space, although in some cases up to 16TB can be reached. However, an GPT partitioned table can handle the space with the most 8ZiB.
More partitions: using primary and extended partitions, the DOS partition table allows only 16 partitions. In GPT, you get 128 partitions by default, and you can select more partitions.
Reliability: in the DOS partition table, only one backup of the partition table is saved, and two copies of the partition table are kept in GPT (at the beginning and end of the disk). At the same time, GPT also uses the CRC checksum to check the integrity of the partition table, which is not implemented in the DOS partition.
Since today's disks are larger and need to be used more flexibly, it is recommended that you use parted to handle disk partitions. Most of the time, disk partition tables are created as part of the operating system installation process. It is useful to use the parted command directly when adding storage devices to an existing system.
Try parted.
The process of partitioning a storage device using the parted command is explained below. To try these steps, I strongly recommend using a brand new storage device or a device that you don't mind deleting its contents.
1. List the partitions
Use parted-l to identify the devices you want to partition. In general, * hard drives (/ dev/sda or / dev/vda) hold the operating system, so look for another disk to find the disk you want to partition (for example, / dev/sdb, / dev/sdc, / dev/vdb, / dev/vdc, etc.).
$sudo parted-l [sudo] password for daniel: Model: ATA RevuAhn_850X1TU5 (scsi) Disk / dev/vdc: 512GBSector size (logical/physical): 512B/512BPartition Table: msdosDisk Flags: Number Start End Size Type File system Flags 1 1049kB 525MB 524MB primary ext4 boot 2 525MB 512GB 512GB primary lvm2, open storage device
Use parted to select the devices you want to partition. In this example, it is the third disk (/ dev/vdc) on the virtual system. It is important to specify which device you want to use. If you only enter the parted command without specifying a device name, it will randomly select a device to operate.
$sudo parted / dev/vdcGNU Parted 3.2Using / dev/vdcWelcome to GNU Parted! Type 'help' to view a list of commands. (parted) 3, set the partition table
Set the partition table to GPT, and then type Yes to start execution.
(parted) mklabel gpt Warning: the existing disk label on / dev/vdc will be destroyed and all data on this disk will be lost Do you want to continue? Yes/No? Yes
The mklabel and mktable commands are used for the same purpose (creating a partition table on the storage device). Supported partition tables are: aix, amiga, bsd, dvh, gpt, mac, ms-dos, pc98, sun and loop. Remember that mklabel does not create a partition, but a partition table.
4. Check the partition table
View storage device information:
(parted) print Model: Virtio Block Device (virtblk) Disk / dev/vdc: 1396MB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags5, get help
To know how to create a new partition, type: (parted) help mkpart.
(parted) help mkpart mkpart PART-TYPE [FS-TYPE] START END make a partition PART-TYPE is one of: primary, logical, extended FS-TYPE is one of: btrfs, nilfs2, ext4, ext3, ext2, fat32, fat16, hfsx, hfs+, hfs, jfs, swsusp, linux-swap (v1), linux-swap (v0), ntfs, reiserfs, hp-ufs, sun-ufs, xfs, apfs2, apfs1, asfs, amufs5, amufs4, amufs3, amufs2, amufs1, amufs0, amufs, affs7, affs6 Affs5, affs4, affs3, affs2, affs1, affs0, linux-swap, linux-swap (new), linux-swap (old) START and END are disk locations, such as 4GB or 10%. Negative values count from the end of the disk. For example,-1s specifies exactly the last sector. 'mkpart' makes a partition without creating a new file system on the partition. FS-TYPE may be specified to set an appropriate partition ID.6, create Partition
To create a new partition (in this example, partition 0 has 1396MB), enter the following command:
(parted) mkpart primary 0 1396MB Warning: The resulting partition is not properly aligned for best performance Ignore/Cancel? I (parted) print Model: Virtio Block Device (virtblk) Disk / dev/vdc: 1396MB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 17.4kB 1396MB 1396MB primary
The file system type (fstype) does not create an ext4 file system on / dev/vdc1. The partition types of DOS partition tables are primary partition primary, logical partition logical, and extended partition extended. In the GPT partition table, the partition type is used as the partition name. The partition name must be provided under GPT; in the above example, primary is the partition name, not the partition type.
7. Save and exit
When you exit parted, the changes are automatically saved. To exit, enter the following command:
(parted) quitInformation: You may need to update / etc/fstab.$ at this point, the study on "how to use parted for disk partitioning in Linux" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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: 284
*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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.