sgdisk基本用法
简介
sgdisk是Linux下操作GPT分区的工具,就像fdisk是操作MBR分区的工具。关于GPT和MBR的区别请参考:
http://www.anchor.com.au/blog/2012/10/the-difference-between-booting-mbr-and-gpt-with-grub/
使用
新建分区
root@ceph1:~$ sgdisk --help | grep new
-n, --new=partnum:start:end create new partition
-n 创建一个分区, -n后的参数分别是: 分区号:起始地址:终止地址
分区号如果为0,代表使用第一个可用的分区号;
起始地址和终止地址可以为0,0代表第一个可用地址和最后一个可用地址;
起始地址和终止地址可以为+/-xxx,代表偏移量,+代表在起始地址后的xxx地址,-代表在终止地址前的xxx地址;
- 创建了一个不指定大小、不指定分区号的分区:
root@ceph1:~# sgdisk -n 0:0:0 /dev/vdd
Creating new GPT entries.
The operation has completed successfully.
root@ceph1:~# lsblk | grep vdd
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vdd 253:48 0 40G 0 disk
└─vdd1 253:49 0 20G 0 part
- 创建一个从默认起始地址开始的5G的分区:
root@ceph1:~# sgdisk -n 2:0:+5G /dev/vdd
Creating new GPT entries.
The operation has completed successfully.
root@ceph1:~# lsblk | grep vdd
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vdd 253:48 0 40G 0 disk
└─vdd1 253:49 0 20G 0 part
└─vdd2 253:50 0 5G 0 part
查看分区详情
root@ceph1:~$ sgdisk --help | grep info
-i, --info=partnum show detailed information on partition
-i 显示某个分区详情
- 查看第一分区详情:
root@ceph1:~# sgdisk -i 1 /dev/vdd
Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
Partition unique GUID: C7EB237F-9A8F-4938-B010-125B3D6D0D4A
First sector: 2048 (at 1024.0 KiB)
Last sector: 41943006 (at 20.0 GiB)
Partition size: 41940959 sectors (20.0 GiB)
Attribute flags: 0000000000000000
Partition name: ''
root@ceph1:~# sgdisk --help |grep print
-p, --print print partition table
root@ceph1:~# sgdisk -p /dev/sdc
Disk /dev/sdc: 209715200 sectors, 100.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 1282C5A8-B97E-4384-B2AD-298168BD782D
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 209715166
Partitions will be aligned on 2048-sector boundaries
Total free space is 199229373 sectors (95.0 GiB)
Number Start (sector) End (sector) Size Code Name
2 2048 10487807 5.0 GiB 8300
修改分区的 type code
root@ceph1:~$ sgdisk --help | grep typecode
-t, --typecode=partnum:{hexcode|GUID} change partition type code
-t 修改某个分区的type code
- 指定第一分区的type code:
root@ceph1:~# sgdisk -t 1:4fbd7e29-9d25-41b8-afd0-062c0ceff05d /dev/vdd
The operation has completed successfully.
root@ceph1:~# sgdisk -i 1 /dev/vdd
Partition GUID code: 4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D (Unknown)
Partition unique GUID: C7EB237F-9A8F-4938-B010-125B3D6D0D4A
First sector: 2048 (at 1024.0 KiB)
Last sector: 41943006 (at 20.0 GiB)
Partition size: 41940959 sectors (20.0 GiB)
Attribute flags: 0000000000000000
Partition name: ''
修改分区名
root@ceph1:~$ sgdisk --help | grep change-name
-c, --change-name=partnum:name change partition's name
-c 修改某个分区的分区名
- 指定第一分区的分区名:
root@ceph1:~# sgdisk -c 1:"ceph data" /dev/vdd
The operation has completed successfully.
root@ceph1:~# sgdisk -i 1 /dev/vdd
Partition GUID code: 4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D (Unknown)
Partition unique GUID: C7EB237F-9A8F-4938-B010-125B3D6D0D4A
First sector: 2048 (at 1024.0 KiB)
Last sector: 41943006 (at 20.0 GiB)
Partition size: 41940959 sectors (20.0 GiB)
Attribute flags: 0000000000000000
Partition name: 'ceph data'
清除分区数据
root@ceph1:~$ sgdisk --help | grep zap
-z, --zap zap (destroy) GPT (but not MBR) data structures
- 清除第一分区:
root@ceph1:~# sgdisk -z /dev/vdd1
Creating new GPT entries.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
删除分区
root@ceph1:~$ sgdisk --help | grep delete
-d, --delete=partnum delete a partition
-d 删除一个分区
- 删除第一分区:
root@ceph1:~# sgdisk -d 1 /dev/vdd
The operation has completed successfully.
root@ceph1:~# lsblk | grep vdd
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vdd 253:48 0 40G 0 disk
└─vdd2 253:50 0 5G 0 part
sgdisk基本用法的更多相关文章
- EditText 基本用法
title: EditText 基本用法 tags: EditText,编辑框,输入框 --- EditText介绍: EditText 在开发中也是经常用到的控件,也是一个比较必要的组件,可以说它是 ...
- jquery插件的用法之cookie 插件
一.使用cookie 插件 插件官方网站下载地址:http://plugins.jquery.com/cookie/ cookie 插件的用法比较简单,直接粘贴下面代码示例: //生成一个cookie ...
- Java中的Socket的用法
Java中的Socket的用法 Java中的Socket分为普通的Socket和NioSocket. 普通Socket的用法 Java中的 ...
- [转载]C#中MessageBox.Show用法以及VB.NET中MsgBox用法
一.C#中MessageBox.Show用法 MessageBox.Show (String) 显示具有指定文本的消息框. 由 .NET Compact Framework 支持. MessageBo ...
- python enumerate 用法
A new built-in function, enumerate() , will make certain loops a bit clearer. enumerate(thing) , whe ...
- [转载]Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法总结
本文对Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法进行了详细的总结,需要的朋友可以参考下,希望对大家有所帮助. 详细解读Jquery各Ajax函数: ...
- 【JavaScript】innerHTML、innerText和outerHTML的用法区别
用法: <div id="test"> <span style="color:red">test1</span> tes ...
- chattr用法
[root@localhost tmp]# umask 0022 一.chattr用法 1.创建空文件attrtest,然后删除,提示无法删除,因为有隐藏文件 [root@localhost tmp] ...
- 萌新笔记——vim命令“=”、“d”、“y”的用法(结合光标移动命令,一些场合会非常方便)
vim有许多命令,网上搜有一堆贴子.文章列举出各种功能的命令. 对于"="."d"."y",我在无意中发现了它们所具有的相同的一些用法,先举 ...
随机推荐
- MongoDB使用笔记
先创建目录,创建log文件,然后启动服务 cd /d D:\Program Files\MongoDB\Server\3.4\bin\ mongod.exe --dbpath d:\data\db - ...
- angular2.0学习日记1
使用NG2之前需要安装node以及Npm环境,并到node下下载ng2所需要得文件,具体配置请到https://angular.cn/docs/ts/latest/quickstart.html按照提 ...
- 服务器重装和配置:Ubuntu16.04 + Anaconda3 + GTX1080驱动 + CUDA8 + cuDNN + 常用工具安装
前一篇[基于Ubuntu16.04的GeForce GTX 1080驱动安装,遇到的问题及对应的解决方法]是在机器原有系统上安装GPU驱动,后来决定备份数据后重装系统,让服务器环境更干净清爽. 1.安 ...
- iOS开发:UITableView的优化技巧-异步绘制Cell
最近在微博上看到一个很好的开源项目VVeboTableViewDemo,是关于如何优化UITableView的.加上正好最近也在优化项目中的类似朋友圈功能这块,思考了很多关于UITableView的优 ...
- SQL Server插入或修改数据是中文乱码的问题
SQL Server中乱码解决方案: 在Sql Server2005英文版中,如果未对Varchar类型的字段进行设置,那么很多朋友会发现向数据库中插入记录时,如果对应的varchar类型字段 的值为 ...
- ubuntu下erlang man的安装
下载 http://www.erlang.org/download/otp_doc_man_17.1.tar.gz 找到erlang 安装目录 解压 otp_doc_man_17.1.tar.gz s ...
- erl_0017 《硝烟中的erlang》 读书笔记004 “锁和阻塞”
如果某个进程需要持续地接收新任务,那么其在执行耗时过长的锁或者阻塞操作时,就会出现问题. 最为常见的例子之一就是:某个进程使用了TCP socket,阻塞在了接收新的连接或者等待消息上面.在执行此类阻 ...
- CentOS 7.4中firewall防火墙详解和配置以及切换为iptables防火墙
转载:https://blog.csdn.net/xlgen157387/article/details/52672988 一.firewall介绍 CentOS 7中防火墙是一个非常的强大的功能,在 ...
- BZOJ3196 Tyvj1730 二逼平衡树 【树套树】 【线段树套treap】
BZOJ3196 Tyvj1730 二逼平衡树 Description 您需要写一种数据结构(可参考题目标题),来维护一个有序数列,其中需要提供以下操作: 1.查询k在区间内的排名 2.查询区间内排名 ...
- 利用Topshelf把.NET Core Generic Host管理的应用程序部署为Windows服务
背景 2019第一篇文章. 此文源于前公司在迁移项目到.NET Core的过程中,希望使用Generic Host来管理定时任务程序时,没法部署到Windows服务的问题,而且官方也没给出解决方案,只 ...