Utility management commands for Linux disk partitioning

Source: Internet
Author: User

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:

    1. Parted #不带参数直接进入交互式模式, enter the options and tips for help with commands
    2. 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
    3. Parted/dev/sdb Print #----printing/dev/sdb The existing partition of this disk
    4. Parted/dev/sdb Mkpart Primary 1 200 (default m) #创建主分区, (directly effective)
    5. 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:

    1. Gdisk/dev/sdb
    2. #备份
    3. Command (? For help):?
    4. B Back up GPT data to a file
    5. C Change a partition ' s name
    6. D Delete a partition
    7. I show detailed information on a partition
    8. L list known partition types
    9. n Add a new partition
    10. o Create a new empty GUID partition table (GPT)
    11. P Print the partition table
    12. Q Quit without saving changes
    13. R Recovery and Transformation options (experts only)
    14. s sort partitions
    15. t change a partition ' s type code
    16. V Verify Disk
    17. W Write table to disk and exit
    18. X extra functionality (experts only)
    19. ? Print this menu
    20. Enter B, enter a name, backup the GPT partition table to the current directory
    21. #恢复
    22. Gdisk/dev/sdb
    23. Command (? For help):?
    24. B Back up GPT data to a file
    25. C Change a partition ' s name
    26. D Delete a partition
    27. I show detailed information on a partition
    28. L list known partition types
    29. n Add a new partition
    30. o Create a new empty GUID partition table (GPT)
    31. P Print the partition table
    32. Q Quit without saving changes
    33. R Recovery and Transformation options (experts only)
    34. s sort partitions
    35. t change a partition ' s type code
    36. V Verify Disk
    37. W Write table to disk and exit
    38. X extra functionality (experts only)
    39. ? Print this menu
    40. Enter r to enter recovery mode
    41. Recovery/transformation Command (? For help):?
    42. Recovery/transformation Command (? For help):?
    43. b Use Backup GPT header (rebuilding main)
    44. C Load backup partition table from disk (rebuilding main)
    45. D Use main GPT header (rebuilding backup)
    46. e load main partition table from disk (rebuilding backup)
    47. F load MBR and build fresh GPT from it
    48. G convert GPT into MBR and exit
    49. H Make hybrid MBR
    50. I show detailed information on a partition
    51. L load partition data from a backup file
    52. M return to main menu
    53. o Print Protective MBR data
    54. P Print the partition table
    55. Q Quit without saving changes
    56. T transform BSD Disklabel partition
    57. V Verify Disk
    58. W Write table to disk and exit
    59. X extra functionality (experts only)
    60. ? Print this menu
    61. Use the L option to restore files from the backup
    62. Use the B option to restore the backup from the tail of the GPT partition to the GPT header
    63. Use the D option to back up the GPT header information to the tail

Utility management commands for Linux disk partitioning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.