分区管理工具-gdisk命令实战案例
分区管理工具-gdisk命令实战案例
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
gdisk工具擅长管理GPT分区。接下来我们就简单介绍一下该工具的使用。
一.分区表概述
博主推荐阅读: https://www.cnblogs.com/yinzhengjie/p/12347792.html
二.安装gdisk
gdisk工具和fdisk很类似,都是对磁盘进行分区管理的开源工具。如下图所示,fdisk对于GPT分区方式目前只是实验性的,因此生成环境建议大家谨慎使用。
我们的gdisk工具很擅长处理GPT分区方式,不仅如此还支持MBR以及APM和BSD分区方式(虽说后两者分区方式使用相对较少,感兴趣的同学可以自行查阅相关资料)。
综上所述,如果生产环境您使用GPT分区推荐使用gdisk工具,最小化安装的系统需要手动安装哟~
[root@yinzhengjie.com ~]# yum -y install gdisk Loaded plugins: fastestmirror Determining fastest mirrors * base: mirror.bit.edu.cn * extras: mirrors.bfsu.edu.cn * updates: mirror.bit.edu.cn base | 3.6 kB 00:00:00 extras | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 (1/4): updates/7/x86_64/primary_db | 168 kB 00:00:00 (2/4): extras/7/x86_64/primary_db | 190 kB 00:00:00 (3/4): base/7/x86_64/group_gz | 153 kB 00:00:01 (4/4): base/7/x86_64/primary_db | 6.1 MB 00:00:03 Resolving Dependencies --> Running transaction check ---> Package gdisk.x86_64 0:0.8.10-3.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================ Package Arch Version Repository Size ============================================================================================================================================================================ Installing: gdisk x86_64 0.8.10-3.el7 base 190 k Transaction Summary ============================================================================================================================================================================ Install 1 Package Total download size: 190 k Installed size: 660 k Downloading packages: gdisk-0.8.10-3.el7.x86_64.rpm | 190 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : gdisk-0.8.10-3.el7.x86_64 1/1 Verifying : gdisk-0.8.10-3.el7.x86_64 1/1 Installed: gdisk.x86_64 0:0.8.10-3.el7 Complete! [root@yinzhengjie.com ~]#
三.gdisk工具使用案例
[root@yinzhengjie.com ~]# gdisk /dev/sdc #进入到gdisk工具的管理界面 GPT fdisk (gdisk) version 0.8.10 Partition table scan: MBR: not present BSD: not present APM: not present GPT: not present Creating new GPT entries. Command (? for help):
1>.查看帮助信息
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 Command (? for help):
2>.新建分区
Command (? for help): n #执行新建分区的指令 Partition number (1-128, default 1): First sector (34-838860766, default = 2048) or {+-}size{KMGTP}: Last sector (2048-838860766, default = 838860766) or {+-}size{KMGTP}: +100G #这里的结束位置我这里写+100G Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): #我们可以自定义创建分区的代码(默认是8300),输入字母"l"可以查看所有的代码标签哟~通常情况下我们直接回车即可。 Changed type of partition to 'Linux filesystem' Command (? for help):
3>.查看分区信息
Command (? for help): p Disk /dev/sdc: 838860800 sectors, 400.0 GiB Logical sector size: 512 bytes Disk identifier (GUID): 37B1331C-C436-48CA-B5A6-B157D0BB9AD0 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 838860766 Partitions will be aligned on 2048-sector boundaries Total free space is 629145533 sectors (300.0 GiB) Number Start (sector) End (sector) Size Code Name 1 2048 209717247 100.0 GiB 8300 Linux filesystem Command (? for help):
4>.保存分区信息并退出
Command (? for help): w #保存分区信息到磁盘(默认所有的修改都放在内存中,直到执行当前的写入指令才会写入到磁盘。) Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): Y #注意哈,这里得输入字母"Y"才能保存成功哟~ OK; writing new GUID partition table (GPT) to /dev/sdc. The operation has completed successfully. [root@yinzhengjie.com ~]#
5>.命令行中查看gpt的分区信息
[root@yinzhengjie.com ~]# gdisk -l /dev/sdc GPT fdisk (gdisk) version 0.8.10 Partition table scan: MBR: protective BSD: not present APM: not present GPT: present Found valid GPT with protective MBR; using GPT. Disk /dev/sdc: 838860800 sectors, 400.0 GiB Logical sector size: 512 bytes Disk identifier (GUID): C4A5426E-BE89-46EE-B842-3CAC96156388 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 838860766 Partitions will be aligned on 2048-sector boundaries Total free space is 629145533 sectors (300.0 GiB) Number Start (sector) End (sector) Size Code Name 1 2048 209717247 100.0 GiB 8300 Linux filesystem [root@yinzhengjie.com ~]#
[root@yinzhengjie.com ~]# fdisk -l /dev/sdc WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion. Disk /dev/sdc: 429.5 GB, 429496729600 bytes, 838860800 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 Disk identifier: C4A5426E-BE89-46EE-B842-3CAC96156388 # Start End Size Type Name 1 2048 209717247 100G Linux filesyste Linux filesystem [root@yinzhengjie.com ~]# [root@yinzhengjie.com ~]#
当你的才华还撑不起你的野心的时候,你就应该静下心来学习。当你的能力还驾驭不了你的目标的时候,你就应该沉下心来历练。问问自己,想要怎样的人生。
欢迎交流学习技术交流,个人微信: "JasonYin2020"(添加时请备注来源及意图备注)
作者: 尹正杰, 博客: https://www.cnblogs.com/yinzhengjie/p/12359770.html