System environment: CENTOS6, 7
Command information:
1, LSBLK list partition information, you can view the partition of the light in the directory and usage (read the partition table information in memory)
2. Fdisk is used to create MBR partitions (you can also create GPT partitions, but the support is not particularly perfect)
3. Gdisk is used to create a GPT partition (use this command if you want to create a GPT partition)
4, parted advanced partition operation (note the operation, a lot of commands to complete a key, no hint, so there is no room for regret, powerful)
5, Partprobe re-read the partition list, and loaded into memory (CENTOS6 This command has a bug, can not use, 5 and 7 no problem, wait for the solution).
6, Cfdisk more silly than Fdisk more intuitive partitioning method
7, Cgdisk more stupid than gdisk more intuitive partitioning method
——————————————————————————————————————————————————————————————–
1. fdisk/dev/sd* Management partition
Sub-command:
P Partition List
t change the partition type
n Create a new partition
D Delete Partition
V-Check Partition
U Conversion Unit
W Save and exit
Q Do not save and exit
When using the Fdisk partition, the discontinuous unallocated storage space can not divide the disjoint unallocated space into 1 partitions, it is important to note that the default unit of the partition is block, or you can specify units such as: m,g,t
2, gdisk/dev/sd* Management partition (similar to Fdisk no longer repeat)
3, Cfdisk, cgdisk Two commands is relative to Fdisk and Gdisk, there is a menu, too intuitive, do not say they two.
4, Partprobe powerful partition command, but the operation of parted is effective in real time, use carefully
Use the/DEV/SDB disk to do the demo:
- Parted #不带参数直接进入交互式模式, enter the options and tips for help with commands
- Parted/dev/sdb Mklabel gpt|msdos #----Specify a GPT partition or MBR partition (note that there is no prompt, the operation is irreversible, the data is not good for me)---the first step
- Parted/dev/sdb Print #----printing/dev/sdb The existing partition of this disk
- Parted/dev/sdb Mkpart Primary 1 200 (default m) #创建主分区, (directly effective)
- Parted/dev/sdb RM 1 #----Delete a partition with number 1
Re-partitioning on a partitioned disk, after partitioning is complete, reading the partitioned table using the LSBLK command will find that the partition table has not changed because the system does not re-read the new partition table after the partition has been finished. For the latest configuration to take effect, you can use the Partprobe command to re-read the partition table
But then comes the question:
The Partprobe command of the CENTOS6 system has a bug and cannot be used properly.
Workaround:
New Partition with
Partx-a/dev/device
Kpartx-a/dev/device-f: Force
Delete partition with
Partx-d–nr M-n/dev/device
Backup and recovery of MBR:
Backup
DD IF=/DEV/SDA of=/app/mbr Bs=1 count=512
Restores
DD if=mbr OF=/DEV/SDA Bs=1 count=64 skip=446 seek=446 (restore only the partition table, the first 446 bytes contain bootloader and the error data area, if this instruction cannot reply to the partition, the last byte is also destroyed, Count Change to 66)
DD if=mbr of=/dev/sdb Bs=1 count=512 (Full recovery includes, bootloader and partitioned tables)
Backup and restore of GPT partitions:
- Gdisk/dev/sdb
- #备份
- Command (? For help):?
- B Back up GPT data to a file
- C Change a partition ' s name
- D Delete a partition
- I show detailed information on a partition
- L list known partition types
- n Add a new partition
- o Create a new empty GUID partition table (GPT)
- P Print the partition table
- Q Quit without saving changes
- R Recovery and Transformation options (experts only)
- s sort partitions
- t change a partition ' s type code
- V Verify Disk
- W Write table to disk and exit
- X extra functionality (experts only)
- ? Print this menu
- Enter B, enter a name, backup the GPT partition table to the current directory
- #恢复
- Gdisk/dev/sdb
- Command (? For help):?
- B Back up GPT data to a file
- C Change a partition ' s name
- D Delete a partition
- I show detailed information on a partition
- L list known partition types
- n Add a new partition
- o Create a new empty GUID partition table (GPT)
- P Print the partition table
- Q Quit without saving changes
- R Recovery and Transformation options (experts only)
- s sort partitions
- t change a partition ' s type code
- V Verify Disk
- W Write table to disk and exit
- X extra functionality (experts only)
- ? Print this menu
- Enter r to enter recovery mode
- Recovery/transformation Command (? For help):?
- Recovery/transformation Command (? For help):?
- b Use Backup GPT header (rebuilding main)
- C Load backup partition table from disk (rebuilding main)
- D Use main GPT header (rebuilding backup)
- e load main partition table from disk (rebuilding backup)
- F load MBR and build fresh GPT from it
- G convert GPT into MBR and exit
- H Make hybrid MBR
- I show detailed information on a partition
- L load partition data from a backup file
- M return to main menu
- o Print Protective MBR data
- P Print the partition table
- Q Quit without saving changes
- T transform BSD Disklabel partition
- V Verify Disk
- W Write table to disk and exit
- X extra functionality (experts only)
- ? Print this menu
- Use the L option to restore files from the backup
- Use the B option to restore the backup from the tail of the GPT partition to the GPT header
- Use the D option to back up the GPT header information to the tail
Utility management commands for Linux disk partitioning