parted disk partition command

https://www.cnblogs.com/onlybobby/p/7018788.html

The difference between the command parted and fdisk command:

  fdisk for the MBR partition command is operating, because the MBR partition itself design reasons, can not handle larger than 2TB hard disk, and only four partitions.

  Then for the hard disk larger than 2TB, the need GPT partition, using the operation command parted

parted command

print  [free|all | NUMBER]  View partition status information
mkpart PART-TYPE START END

 Create a new partition,

PART-TYPE: primary  extended   logical 

START, END began, until the end

set NUMBER  FLAG  STATE

 Of the number of labeled NUMBER.

FLAG: boot boot, hidden hidden, raid soft raid, lvm logical volume, 

STATE:  on| off

mkfs NUMBER FS-TYPE  Specify the file system to NUMBER. There FS-Type: ext2, fat16, fat32, linuxswap, NTFS, reiserfs, ufs etc.
 cp  [FROM-DEV] FROM-NUMBER  TO-NUMBER  The complete file system on the partition to a partition copy FROM-NUMBER TO-NUMBER, as an option can also specify a source HDD device name FROM-DEVICE, omitted, if the current copy on the device.
 move NUMBER START END

 The designated number NUMBER partition moves to a position from START to END on. Note: (1) can only move a partition into free space. (2) While the partition was moved, but it will not change the partition number

resize NUMBER START END  

Specifies the number of partitions NUMBER resizing. Start and end positions of the partition is determined by the START and END

check NUMBER

Check whether the specified number NUMBER partition file system What is wrong

rescue START END  rescue START END 
mklabel, mktable LABEL TYPE Create a new type of LABELTYPE empty disk partition table, for PC msdos is commonly used LABELTYPE. If a GUID partition table, LABEL-TYPE should gpt

 

 

 

 

 

 

 

 

 

 

 

 

 

  

 

Example: 

Copy the code
1. / dev / sdb Partitions 
[the root @ localhost ~] # the parted / dev / sdb the GNU the Parted 3.1 the Using / dev / sdb available for purchase to the GNU the Parted! The Type 'Help' to View A List of Commands.

2. Setting Disk format gpt (parted) mklabel ? New disk label of the type gpt

3. View disk partition information (parted) Print Model: VMware, VMware Virtual S (scsi) disk / dev / sdb: 1074MB Sector size (the Logical / PHYSICAL): 512B / 512B Partition the Table: gpt Disk Flags: Number The File System Size the Name Start End Flags
4. make a partition (parted) mkpart ?? Partition name [] d1 File System of the type [the performance of ext2] ext4?? Start 0? End 512M? Warning:. Partition the Resulting at The IS not Properly aligned for Best Performance # pay attention to this warning. In this way partition is just a test, again behind the relevant partitions deleted. ? Ignore / i the Cancel

5. check the status of the new partition (parted) PRIN Model: VMware, VMware Virtual S (scsi) Disk / dev / sdb: 1074MB Sector size (the Logical / PHYSICAL): 512B / 512B Partition the Table: gpt Disk Flags: Start End File System Size Number The the Name Flags 1 17.4kB 512MB 512MB d1 6. Delete Partition 1 (Number number) (parted) RM 1 7. New partition primary partition, starting 2048sector, ending 50% of the size of the disk (parted) mkpart Primary 2048s 50% (parted) Print Model: VMware, VMware Virtual S (scsi) Disk / dev / sdb: 1074MB Sector size (the Logical / PHYSICAL): 512B / 512B Partition the Table: gpt Disk Flags: Number The Start End size File System the Name the Flags . 1 1049kB 537MB 536MB Primary


8. the add another partition, Primary partition 50% of the original disk, the end of the 100% size. (the parted) the mkpart Primary 50% 100%
(parted) the p- Model: VMware, VMware Virtual S (scsi) Disk / dev / sdb: 1074MB Sector size (the Logical / PHYSICAL): 512B / 512B Partition the Table: gpt Disk Flags: Number The Start End Size File System the Name Flags 1 1049kB 537MB Primary 536MB 2 537MB 1073MB 536MB Primary 9. The exit the parted (the parted) Q Information: On May by You need to Update / etc / fstab. 10. The disk status view the fdisk. To discover new disk partition status. [root @ localhost ~] # fdisk the -l Disk / dev / sda: 21.5 GB, 21,474,836,480 bytes, 41.94304 million sectors

Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000c0b7f Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 41943039 20458496 8e Linux LVM Disk /dev/mapper/rhel-root: 18.8 GB, 18798870528 bytes, 36716544 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/rhel-swap: 2147 MB, 2147483648 bytes, 4194304 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion. Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: gpt # Start End Size Type Name 1 2048 1048575 511M Microsoft basic primary 2 1048576 2095103 511M Microsoft basic primary 11. 新增完成后,建议重新格式化分区。 [root@localhost ~]# mkfs.ext4 /dev/sdb1 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 131072 inodes, 523264 blocks 26163 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=34078720 64 block groups 8192 blocks per group, 8192 fragments per group 2048 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409 Allocating group tables: done Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done [root@localhost ~]# mkfs.ext4 /dev/sdb2 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 131072 inodes, 523264 blocks 26163 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=34078720 64 block groups 8192 blocks per group, 8192 fragments per group 2048 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73 729, 204 801, 221 185, 401 409 Allocating Group Tables: DONE Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting Information: DONE


12. The modified / etc / fstab automatic loading

recommended UUID for hanging
blkid / dev / sdb1 (or BLKID)
/ dev / sdb1: the UUID = "bc95b330-5eb9-4b68-9f9f-71c52247a1b4" the TYPE = "ext4"

modify / etc / fstab
the UUID = bc95b330-5eb9-4b68-9f9f-71c52247a1b4 / opt ext4 Defaults 0 0

Guess you like

Origin www.cnblogs.com/zhchy89/p/11457224.html