Android分区管理工具sgdisk使用

#有时df -h查看分区信息无法满足需求#

借助Android系统自带的sgdisk可以查看详细的分区信息,类似fdisk命令,sgdisk同样可以创建分区,功能也很强大。

一、sgdisk帮助信息

127|console:/ # sgdisk
USAGE: sgdisk  [OPTION...] <device>--attributes    operate on partition attributes--set-alignment set sector alignment--backup        backup GPT to file--change-name   change partition's name--recompute-chs recompute CHS values in protective/hybrid MBR--delete        delete a partition--display-alignment     show number of sectors per allocation block--move-second-header    move second header to end of disk--end-of-largest        show end of largest free block--first-in-largest      show start of the largest free block--first-aligned-in-largest      show start of the largest free block, aligned--mbrtogpt      convert MBR to GPT--randomize-guids       randomize disk and partition GUIDs--hybrid        create hybrid MBR--info  show detailed information on partition--move-main-table       adjust the location of the main partition table--load-backup   load GPT backup from file--list-types    list known partition types--gpttombr      convert GPT to MBR--new   create new partition--largest-new   create largest possible new partition--clear clear partition table--print-mbr     print MBR partition table--print print partition table--pretend       make changes in memory, but don't write them--transpose     transpose two partitions--replicate     replicate partition table--sort  sort partition table entries--resize-table  resize partition table--typecode      change partition type code--transform-bsd transform BSD disklabel partition to GPT--partition-guid        set partition GUID--disk-guid     set disk GUID--verify        check partition table integrity--version       display version information--zap   zap (destroy) GPT (but not MBR) data structures--zap-all       zap (destroy) GPT and MBR data structures

二、查看磁盘分区详情

sgdisk --print /dev/block/sdaconsole:/ # sgdisk --print /dev/block/sda
Disk /dev/block/sda: 16777216 sectors, 64.0 GiB
Sector size (logical/physical): 4096/4096 bytes
Disk identifier (GUID): 54054CFA-8B64-425D-A63F-B6B6F795C66E
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 5
First usable sector is 6, last usable sector is 16777210
Partitions will be aligned on 256-sector boundaries
Total free space is 1780981 sectors (6.8 GiB)Number  Start (sector)    End (sector)  Size       Code  Name1             256             511   1024.0 KiB  8300  misc2             512           16895   64.0 MiB    8300  boot_a3           16896           33279   64.0 MiB    8300  boot_b4           33280           33535   1024.0 KiB  8300  dtb_a5           33536           33791   1024.0 KiB  8300  dtb_b6           33792           37887   16.0 MiB    8300  metadata7           37888         6067199   23.0 GiB    8300  super8         6067200         6591487   2.0 GiB     8300  kdump9         6591488         6607871   64.0 MiB    8300  persist10         6607872        14996479   32.0 GiB    8300  userdata

使用这个指令可以很方便查看RAW分区的大小,以及起始和终止簇。新的版本df -h无法查看super分区大小,也需要使用sgdisk来查看。

通过上面信息可以看到sda大小为64GB,还剩余6.8GB空间未划分。

系统df -h信息如下:

console:/ # df -h
Filesystem       Size  Used Avail Use% Mounted on
tmpfs            3.9G  856K  3.9G   1% /dev
tmpfs            3.9G     0  3.9G   0% /mnt
/dev/block/sda6   11M  104K   11M   1% /metadata
/dev/block/dm-0  5.9G  3.6G  2.2G  63% /
/dev/block/dm-5  8.2G  444M  7.7G   6% /mnt/scratch
overlay          8.2G  444M  7.7G   6% /vendor
overlay          8.2G  444M  7.7G   6% /product
overlay          8.2G  444M  7.7G   6% /system_ext
overlay          8.2G  444M  7.7G   6% /odm
tmpfs            3.9G     0  3.9G   0% /apex
tmpfs            3.9G  264K  3.9G   1% /linkerconfig
/dev/block/sda9   58M   24K   58M   1% /persist
/dev/block/sda10  32G  1.6G   30G   6% /data
tmpfs            3.9G     0  3.9G   0% /data_mirror
/dev/block/sda8  1.9G   24K  1.9G   1% /data/vendor/kdump
/dev/fuse         32G  1.6G   30G   6% /mnt/user/0/emulated
/dev/fuse         32G  1.6G   30G   6% /mnt/user/10/emulated

三、分区操作实操

(1)查看可以开始使用的第一个簇

console:/ # sgdisk --first-in-largest /dev/block/sda
14996480

 通过上面的分区详情也可以看到userdata最后一个簇是14996479,接下来可以使用的簇就是14996480,与上面指令得到的一致。

做地址对齐后的第一个可用簇:

console:/ # sgdisk --first-aligned-in-largest /dev/block/sda
14996480

(2)查看可以使用的最后一个簇

console:/ # sgdisk --end-of-largest /dev/block/sda
16777210

如果希望将剩余所有空间都划分出去,可以使用此指令查看最后一个簇。

(3)新建一个test分区

console:/ # sgdisk --new 11:0:0 /dev/block/sda
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.
console:/ # sgdisk --print /dev/block/sda
Disk /dev/block/sda: 16777216 sectors, 64.0 GiB
Sector size (logical/physical): 4096/4096 bytes
Disk identifier (GUID): 54054CFA-8B64-425D-A63F-B6B6F795C66E
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 5
First usable sector is 6, last usable sector is 16777210
Partitions will be aligned on 256-sector boundaries
Total free space is 250 sectors (1000.0 KiB)Number  Start (sector)    End (sector)  Size       Code  Name1             256             511   1024.0 KiB  8300  misc2             512           16895   64.0 MiB    8300  boot_a3           16896           33279   64.0 MiB    8300  boot_b4           33280           33535   1024.0 KiB  8300  dtb_a5           33536           33791   1024.0 KiB  8300  dtb_b6           33792           37887   16.0 MiB    8300  metadata7           37888         6067199   23.0 GiB    8300  super8         6067200         6591487   2.0 GiB     8300  kdump9         6591488         6607871   64.0 MiB    8300  persist10         6607872        14996479   32.0 GiB    8300  userdata11        14996480        16777210   6.8 GiB     8300

 sgdisk --new 11:0:0 /dev/block/sda
11代表分区序号,即sda11,中间的0代表起始簇为第一个可用地址,最后的0代表结束簇为最后一个可用地址。两个都为0即把剩余空间全部划分给新分区。

修改分区名字:

console:/ # sgdisk --change-name 11:"test" /dev/block/sda
Setting name!
partNum is 10
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.
console:/ # sgdisk --print /dev/block/sda
Disk /dev/block/sda: 16777216 sectors, 64.0 GiB
Sector size (logical/physical): 4096/4096 bytes
Disk identifier (GUID): 54054CFA-8B64-425D-A63F-B6B6F795C66E
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 5
First usable sector is 6, last usable sector is 16777210
Partitions will be aligned on 256-sector boundaries
Total free space is 250 sectors (1000.0 KiB)Number  Start (sector)    End (sector)  Size       Code  Name1             256             511   1024.0 KiB  8300  misc2             512           16895   64.0 MiB    8300  boot_a3           16896           33279   64.0 MiB    8300  boot_b4           33280           33535   1024.0 KiB  8300  dtb_a5           33536           33791   1024.0 KiB  8300  dtb_b6           33792           37887   16.0 MiB    8300  metadata7           37888         6067199   23.0 GiB    8300  super8         6067200         6591487   2.0 GiB     8300  kdump9         6591488         6607871   64.0 MiB    8300  persist10         6607872        14996479   32.0 GiB    8300  userdata11        14996480        16777210   6.8 GiB     8300  test

注意:重启生效

(4)新建一个指定大小的分区

新建一个2G大小分区

console:/ # sgdisk --new 11:14996480:+2G /dev/block/sda
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.
console:/ # sgdisk --print /dev/block/sda
Disk /dev/block/sda: 16777216 sectors, 64.0 GiB
Sector size (logical/physical): 4096/4096 bytes
Disk identifier (GUID): 54054CFA-8B64-425D-A63F-B6B6F795C66E
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 5
First usable sector is 6, last usable sector is 16777210
Partitions will be aligned on 256-sector boundaries
Total free space is 1256693 sectors (4.8 GiB)Number  Start (sector)    End (sector)  Size       Code  Name1             256             511   1024.0 KiB  8300  misc2             512           16895   64.0 MiB    8300  boot_a3           16896           33279   64.0 MiB    8300  boot_b4           33280           33535   1024.0 KiB  8300  dtb_a5           33536           33791   1024.0 KiB  8300  dtb_b6           33792           37887   16.0 MiB    8300  metadata7           37888         6067199   23.0 GiB    8300  super8         6067200         6591487   2.0 GiB     8300  kdump9         6591488         6607871   64.0 MiB    8300  persist10         6607872        14996479   32.0 GiB    8300  userdata11        14996480        15520767   2.0 GiB     8300

(5) 查看分区详情

console:/ # sgdisk --info 11 /dev/block/sda
Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
Partition unique GUID: AEA8DD0F-C48F-4177-BD08-C29F28910AD8
First sector: 14996480 (at 57.2 GiB)
Last sector: 15520767 (at 59.2 GiB)
Partition size: 524288 sectors (2.0 GiB)
Attribute flags: 0000000000000000
Partition name: ''

(6)删除一个分区

console:/ # sgdisk --delete 11 /dev/block/sda
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.

11代表/dev/block/sda11这个分区,需要重启才能生效

四、结语

以上就是常用的分区操作,还有一些其他的操作可以根据help信息自行尝试。

说明:Android自带的sgdisk help信息不友好,看了后不清楚参数应该如何添加。Android的sgdisk是从linux移植而来,使用方法和Ubuntu上的sgdisk基本一样,可以参考Ubuntu的help信息。

也可以参考https://www.cnblogs.com/mountain2011/p/9622001.html 

Ubuntu sgdisk使用帮助

# sgdisk --help
Usage: sgdisk  [OPTION...] <device>-A, --attributes=list|[partnum:show|or|nand|xor|=|set|clear|toggle|get[:bitnum|hexbitmask]]     operate on partition attributes-a, --set-alignment=value                                                                       set sector alignment-b, --backup=file                                                                               backup GPT to file-c, --change-name=partnum:name                                                                  change partition's name-C, --recompute-chs                                                                             recompute CHS values in protective/hybrid MBR-d, --delete=partnum                                                                            delete a partition-D, --display-alignment                                                                         show number of sectors per allocation block-e, --move-second-header                                                                        move second header to end of disk-E, --end-of-largest                                                                            show end of largest free block-f, --first-in-largest                                                                          show start of the largest free block-F, --first-aligned-in-largest                                                                  show start of the largest free block, aligned-g, --mbrtogpt                                                                                  convert MBR to GPT-G, --randomize-guids                                                                           randomize disk and partition GUIDs-h, --hybrid=partnum[:partnum...][:EE]                                                          create hybrid MBR-i, --info=partnum                                                                              show detailed information on partition-j, --move-main-table=sector                                                                    adjust the location of the main partition table-l, --load-backup=file                                                                          load GPT backup from file-L, --list-types                                                                                list known partition types-m, --gpttombr=partnum[:partnum...]                                                             convert GPT to MBR-n, --new=partnum:start:end                                                                     create new partition-N, --largest-new=partnum                                                                       create largest possible new partition-o, --clear                                                                                     clear partition table-O, --print-mbr                                                                                 print MBR partition table-p, --print                                                                                     print partition table-P, --pretend                                                                                   make changes in memory, but don't write them-r, --transpose=partnum:partnum                                                                 transpose two partitions-R, --replicate=device_filename                                                                 replicate partition table-s, --sort                                                                                      sort partition table entries-S, --resize-table=numparts                                                                     resize partition table-t, --typecode=partnum:{hexcode|GUID}                                                           change partition type code-T, --transform-bsd=partnum                                                                     transform BSD disklabel partition to GPT-u, --partition-guid=partnum:guid                                                               set partition GUID-U, --disk-guid=guid                                                                            set disk GUID-v, --verify                                                                                    check partition table integrity-V, --version                                                                                   display version information-z, --zap                                                                                       zap (destroy) GPT (but not MBR) data structures-Z, --zap-all                                                                                   zap (destroy) GPT and MBR data structuresHelp options:-?, --help                                                                                      Show this help message--usage                                                                                     Display brief usage message

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/876962.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

linux脚本:自动检测的bash脚本,用于检查linux的系统性能

目录 一、要求 二、脚本介绍 1、脚本内容 2、解释 3、使用方法&#xff1a; &#xff08;1&#xff09;脚本文件 &#xff08;2&#xff09;赋予权限 &#xff08;3&#xff09;执行结果 三、相关命令介绍 1、top &#xff08;1&#xff09;定义 &#xff08;2&…

Layui修改表格分页为英文

Layui修改表格分页为英文 1.前言2.Laypage属性 1.前言 主要记录初次使用Layui没有好好看官方文档踩坑&#xff0c;修改了源码才发现可以自定义 使用的Layui版本2.9.14 2.Laypage属性 Laypage属性中带的有自定义文本的属性 示例代码 table.render({.......page: {skipText: …

2.4GHz射频前端集成芯片:AT2401C芯片中文资料

关于AT2401C的基本资料&#xff1a; AT2401C是一款面向Zigbee&#xff0c;无线传感网络以及其他2.4GHz频段无线系统的全集成射频功能的射频前端单芯片。 那么射频放大器的作用是什么&#xff1f;它是用来放大来自射频信号源的低功率信号&#xff0c;放大到较高的功率后&#xf…

7. 运行时数据区-栈

栈的分类 栈分为Java虚拟机栈还有本地方法栈&#xff1a; Java虚拟机栈&#xff1a;用于保存Java中的方法相关的内容本地方法栈&#xff1a;用于保存在Java中使用native 标记的用C来实现方法 由于hotspot的作者发现使用一个栈就可以保存以上两个部分的内容&#xff0c;所以在…

学习测试14-实战3-复习-使用CANoe打开半成品

数据 链接: https://pan.baidu.com/s/1k0SFq0luDvEbqimFgtfyKg?pwd9a5t 提取码: 9a5t 复制这段内容后打开百度网盘手机App&#xff0c;操作更方便哦 1&#xff0c;导入信号、报文、节点 2&#xff0c;导入数据库 3&#xff0c;导入can代码 4&#xff0c;导入环境变量 5&#x…

CTF竞赛介绍以及刷题网址(非常详细)零基础入门到精通,收藏这一篇就够了

前言 CTF&#xff08;Capture The Flag&#xff09;中文一般译作夺旗赛&#xff0c;在网络安全领域中指的是网络安全技术人员之间进行技术竞技的一种比赛形式。CTF起源于1996年DEFCON全球黑客大会&#xff0c;以代替之前黑客们通过互相发起真实攻击进行技术比拼的方式。发展至今…

【保姆级教程】Windows 远程登陆 Linux 服务器的两种方式:SSH + VS Code,开发必备

0. 前言 很多情况下代码开发需要依赖 Linux 系统&#xff0c;远程连接 Linux 服务器进行开发和维护已成为一种常态。对于使用Windows系统的开发者来说&#xff0c;掌握如何通过 SSH 安全地连接到 Linux 服务器&#xff0c;并利用 VS Code 编辑器进行开发&#xff0c;是一项必备…

海外问卷调查这个项目怎么样?

大家好&#xff0c;我是橙河老师&#xff0c;今天讲一讲海外问卷调查这个项目怎么样&#xff1f;我自己做这个项目已经有三四年的时间了&#xff0c;在这个行业里算是资深玩家&#xff0c;我自己的工作室也一直稳定在操作这个项目&#xff0c;首先可以肯定的是&#xff0c;这个…

<数据集>棉花识别数据集<目标检测>

数据集格式&#xff1a;VOCYOLO格式 图片数量&#xff1a;13765张 标注数量(xml文件个数)&#xff1a;13765 标注数量(txt文件个数)&#xff1a;13765 标注类别数&#xff1a;4 标注类别名称&#xff1a;[Partially opened, Fully opened boll, Defected boll, Flower] 序…

甄选范文“论企业集成架构设计及应用”软考高级论文,系统架构设计师论文

论文真题 论企业集成架构设计及应用企业集成架构(Enterprise Integration Arhitecture,EIA) 是企业集成平台的核心,也是解决企业信息孤岛问题的关键。企业集成架构设计包括了企业信息、业务过程、应用系统集成架构的设计。实现企业集成的技术多种多样,早期的集成方式是通过…

仕考网:公务员可以报考军队文职吗?

公务员可以报考军队文职考试&#xff0c;但是需要满足前提条件。 对于已经与国家、地方的用人单位建立劳动关系的社会人才&#xff0c;在获得当前用人单位的许可后才可以申请报考。 在面试过程中&#xff0c;考生必须出示一份由其用人单位出具的且加盖公章的同意报考证明。一…

远程文件下载

在本机启动 http 服务&#xff0c;在你要下载文件的目录下输入 cmd &#xff0c;运行 python -m http.server前提条件&#xff1a;本机安装了 python 服务。 查看本机 IP&#xff08;无线局域网 IP&#xff09;&#xff0c;重新开一个窗口&#xff0c;查看本机 IP 地址。 ipc…

【arxiv 2024】Latte: Latent Diffusion Transformer for Video Generation

【arxiv 2024】Latte: Latent Diffusion Transformer for Video Generation 一、前言Abstract1 Introduction2 Related Work3 Methodology3.1 Preliminary of Latent Diffusion Models3.2 The model variants of Latte3.3 The empirical analysis of Latte3.3.1 Latent video c…

C语言 ——— 函数指针数组的讲解及其用法

目录 前言 函数指针数组的定义 函数指针数组的使用 前言 数组是存放一组相同类型数据的存储空间 关于指针数组的知识请见&#xff1a;C语言 ——— 指针数组 & 指针数组模拟二维整型数组-CSDN博客 那么要将多个函数的地址存储到数组中&#xff0c;这个数组该如何定义…

C++中的依赖注入

目录 1.概述 2.构造函数注入 3.setter方法注入 4.接口注入 5.依赖注入框架 6.依赖注入容器 7.依赖注入框架的工作原理 8.依赖注入的优势 9.总结 1.概述 依赖注入是一种设计模式&#xff0c;它允许我们在不直接创建对象的情况下为对象提供其依赖项&#xff1b;它通过将…

云仓技术带来的物流变革影响

1、实时可视性&#xff1a; 云仓技术使物流公司能够实时跟踪和监控货物在供应链中的位置和状态。这种实时可视性提供了更好的货物追踪和管理能力&#xff0c;同时也提高了客户服务的质量。 ———————————————————— 2、仓储优化&#xff1a; 云仓技术可以…

从0开始搭建vue + flask 旅游景点数据分析系统(四):编写前端首页【数据驾驶舱】

本期我们编写数据驾驶舱页面(Dashboard)这个页面。主要任务是引入echarts 组件编写数据驾驶舱页面。 视频教程后续会更新在我的B站&#xff1a;https://space.bilibili.com/1583208775?spm_id_from666.25.0.0 推荐从教程第一集开始从零开始学习&#xff1a;https://blog.csdn…

实验室责任人员管理保障实训系统安全

在智慧校园的实训管理生态中&#xff0c;实验室责任人员的角色犹如精密机器中的关键齿轮&#xff0c;他们不仅是实验室安全与高效运转的守护者&#xff0c;更是实训教学质量的直接塑造者。这一角色的重要性&#xff0c;在智慧校园的数字化转型中得到了前所未有的凸显&#xff0…

Linux系统配置STM32的开发环境(代码编辑,编译,下载调试)

常见的stm32开发都是直接使用keil-MDK工具的&#xff0c;这是个集成开发环境&#xff0c;包含了代码编辑&#xff0c;编译&#xff0c;下载&#xff0c;调试&#xff0c;等功能&#xff0c;而且keil还是个图形化操作工具&#xff0c;直接可以点击图标案件就可以实现编译下载啥的…

Tableau入门|数据可视化与仪表盘搭建

原视频链接&#xff08;up:戴戴戴师兄&#xff09;&#xff0c;文章为笔者的自学笔记&#xff0c;用于复习回顾&#xff0c;原视频下方有原up整理的笔记&#xff0c;更加直观便捷。因为视频中间涉及的细节较多&#xff0c;建议一边操作&#xff0c;一边学习。 整体介绍 可视化…