fsdisk 分区

芯片主控:imx6q
http://lornyin.top/?p=545

昨天在做一个linux嵌入式项目时要修改板子的分区,查看了ucl2.xml (mfgtool)文件后,找到了他的分区脚本

#!/bin/sh

# partition size in MB
BOOT_ROM_SIZE=10# call sfdisk to create partition table
# destroy the partition table
node=$1
dd if=/dev/zero of=${node} bs=1024 count=1echo "#change test"sfdisk --force -uM ${node} << EOF
${BOOT_ROM_SIZE},500,0c
600,,83
,5000,83
EOF

我们具体来看看sfdisk这一段,网上百度sfdisk发现都是一些比较常见的用法,很少有写到EOF这种用法,于是决定查看官方文档,

man sfdisk

发现输出信息太多,我们把输出结果重定向一个文件

man sfdisk > sfdisk

把输出结果输出到了一个名字叫sfdisk的文本文件中

然后我们来分析下他的分区脚本
这里写图片描述

红框部分是分区参数,每一行为一个分区,上面代码建立的3个分区,我们参考sfdisk文档来分析下几个参数

在151(man sfdisk > sfdisk 的文件)行起,有对参数的说明,一行有4个参数,分别是 开始地址、大小、分区类型、bootable

开始地址就不多说了,我们看看后面3个参数,

大小:

大小这个参数默认值是尽可能大的一个值,如果写成

echo "#change test"sfdisk --force -uM ${node} << EOF
${BOOT_ROM_SIZE},500,0c
600,,83
EOF

就表示第二个分区大小为剩下空间大小,指定大小可以带上单位,用乘法加后缀 KiB, MiB, GiB, TiB, PiB, EiB, ZiB ,YiB

分区类型:

默认值为L (83),代表linux分区,MBR为83

S (82),代表swap分区

E (5), 代表扩展分区

H (933), 代表home分区

X (85) , 代表linux扩展分区

bootable:

这里的参数会将分区标记为可引导。大家可以套用0c参数,脚本这里的0c标记了第一个分区为可引导分区

更多的信息大家可以参考下help信息,老夫能力有限,这些足够我使用了,就没有再进一步探究

INPUT FORMATSsfdisk supports two input formats and generic header lines.Header linesThe optional header lines specify generic information that apply to the partition table.  The header-line format is:<name>: <value>The currently recognized headers are:unit   Specify the partitioning unit.  The only supported unit is sectors.label  Specify the partition table type.  For example dos or gpt.label-idSpecify the partition table identifier.  It should be a  hexadecimal number (with a 0x prefix) for MBR and a UUID for GPT.Note that it is only possible to use header lines before the first partition is specified in the input.Unnamed-fields formatstart size type bootablewhere each line fills one partition descriptor.Fields are separated by whitespace, comma or semicolon possibly followed by whitespace; initial and trailing  whitespace  is  ignored.   Numbers  can  beoctal,  decimal  or  hexadecimal;  decimal  is  the default.  When a field is absent, empty or specified as '-' a default value is used.  But when the -Noption (change a single partition) is given, the default for each field is its previous value.The default value of start is the first non-assigned sector aligned according to device I/O limits.  The default start offset for the first partition  is1  MiB. The offset may be followed by the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB) then the number is interpreted as offset inbytes.The default value of size indicates "as much as possible"; i.e. until the next partition or end-of-device.  A numerical argument  is  by  default  inter‐preted as a number of sectors, however if the size is followed by one of the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB) then thenumber is interpreted as the size of the partition in bytes and it is then aligned according to the device I/O limits.  A '+' can be used  instead  of  anumber  to  enlarge  the partition as much as possible.  Note '+' is equivalent to the default behaviour for a new partition; existing partitions will beresized as required.The partition type is given in hex for MBR (DOS), without the 0x prefix, a GUID string for GPT, or a shortcut:L      Linux; means 83 for MBR and 0FC63DAF-8483-4772-8E79-3D69D8477DE4 for GPT.S      swap area; means 82 for MBR and 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F for GPTE      extended partition; means 5 for MBRH      home partition; means 933AC7E1-2EB4-4F13-B844-0E14E2AEF915 for GPTX      linux extended partition; means 85 for MBR.The default type value is Lbootable is specified as [*|-], with as default not-bootable.  The value of this field is irrelevant for Linux - when  Linux  runs  it  has  been  bootedalready - but ir might play a role for certain boot loaders and for other operating systems.Named-fields formatThis  format  is  more  readable, robust, extendible and allows to specify additional information (e.g. a UUID).  It is recommended to use this format tokeep your scripts more readable.[device :] name[=value], ...The device field is optional.  sfdiskextracts the partition number from the device name.  It allows to specify the  partitions  in  random  order.   Thisfunctionality is mostly used by --dump.  Don't use it if you are not sure.The value can be between quotation marks (e.g. name="This is partition name").  The currently supported fields are:start=numberThe  first non-assigned sector aligned according to device I/O limits.  The default start offset for the first partition is 1 MiB. The off‐set may be followed by the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB) then the number is interpreted as offset  inbytes.size=numberSpecify  the  partition  size in sectors.  The number may be followed by the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB andYiB), then it's interpreted as size in bytes and the size is aligned according to device I/O limits.bootableMark the partition as bootable.attrs=stringPartition attributes, usually GPT partition attribute bits.  See --part-attrs for more details about the GPT-bits string format.uuid=stringGPT partition UUID.name=stringGPT partition name.type=codeA hexadecimal number (without 0x) for an MBR partition, or a GUID for a GPT partition.  For backward compatibility the Id=  field  has  thesame meaning.BACKING UP THE PARTITION TABLEIt is recommended to save the layout of your devices.  sfdisk supports two ways.Use the --dump option to save a description of the device layout to a text file.  The dump format is suitable for later sfdisk input.  For example:sfdisk --dump /dev/sda > sda.dumpThis can later be restored by:sfdisk /dev/sda < sda.dumpIf  you  want  to  do  a  full  (binary)  backup  of  all  sectors  where the partition table is stored, then use the --backup option.  It writes the sectors to~/sfdisk-<device>-<offset>.bak files.  The default name of the backup file can be changed with the --backup-file option.  The backup files contain only raw datafrom the device.  Note that the same concept of backup files is used by wipefs(8).  For example:sfdisk --backup /dev/sdaThe GPT header can later be restored by:dd if=~/sfdisk-sda-0x00000200.bak of=/dev/sda seek=$((0x00000200)) bs=1 conv=notruncNote that sfdisk since version 2.26 no longer provides the -I option to restore sectors.  dd (1) provides all necessary functionality.COLORSImplicit coloring can be disabled by an empty file /etc/terminal-colors.d/sfdisk.disable.See terminal-colors.d(5) for more details about colorization configuration. The logical color names supported by sfdisk are:header The header of the output tables.warn   The warning messages.welcomeThe welcome message.NOTESSince version 2.26 sfdisk no longer provides the -R or --re-read option to force the kernel to reread the partition table.  Use blockdev --rereadpt instead.Since  version  2.26  sfdisk  does  not  provide  the  --DOS, --IBM, --DOS-extended, --unhide, --show-extended, --cylinders, --heads, --sectors, --inside-outer,--not-inside-outer options.ENVIRONMENTSFDISK_DEBUG=allenables sfdisk debug output.LIBFDISK_DEBUG=allenables libfdisk debug output.LIBBLKID_DEBUG=allenables libblkid debug output.LIBSMARTCOLS_DEBUG=allenables libsmartcols debug output.SEE ALSOfdisk(8), cfdisk(8), parted(8), partprobe(8), partx(8)AUTHORKarel Zak <kzak@redhat.com>The current sfdisk implementation is based on the original sfdisk from Andries E. Brouwer.AVAILABILITYThe sfdisk command is part of the util-linux package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux/.util-linux

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

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

相关文章

树莓派Linux内核源码配置、编译、挂载(boot/kernal/根文件)、开启新内核

目录一、树莓派Linux源码配置(适合树莓派)总体概述配置的三种方式1.照搬厂家的配置&#xff08;使用这种方式&#xff09;2.参考厂家的配置&#xff08;感受一下&#xff09;3.完全自主配置&#xff08;需要一定工作经验&#xff09;二、树莓派Linux内核编译三、树莓派挂载新内…

xshell连接linux出现乱码

今天用Xshell连接linux&#xff0c;查看一个脚本&#xff0c;里面有中文写的注解&#xff0c;出现了乱码&#xff0c;所以记录一下&#xff0c;以便下次用到&#xff0c;也可以帮助遇到同样问题的小伙伴。 以下是乱码的截图&#xff1a; 我们可以照着下面的方式更改编码&#x…

阡陌路-车行天下之汽车基础知识

汽车基础知识 1、什么是ABS   ABS是Anti-LockBrakeSystem的英文缩写&#xff0c;翻译过来可以叫做“刹车防抱死系统”。在没有ABS时&#xff0c;如果紧急刹车一般会使轮胎 抱死&#xff0c;由于抱死之后轮胎与地面是滑动摩擦&#xff0c;所以刹车的距离会变长。如果前轮锁死…

java版本号分段比较_Java实现比较版本号

涉及到客户端的系统中经常需要用到比较版本号的功能&#xff0c;但是比较版本号又不能完全按照字符串比较的方式去用compareTo之类的方法&#xff1b;这就需要我们总结版本号的通用规则&#xff0c;设计一个比较算法并封装成通用方法来使用&#xff1a;通常版本号如&#xff1a…

win10 重置串口

最近想起了玩玩51单片机&#xff0c;回味下&#xff0c;发现以前板子送人了&#xff0c;于是随便捡了一个下载器来给AT89S52下程序&#xff0c;下载器是通过串口和电脑通讯的, 可是要求串口端口号不能大于10&#xff0c;我的串口号都特别大&#xff0c;于是尝试到设备管理器里修…

ios 视频知识补充---分解LFLiveKit

视频&#xff1a;泛指将一系列的静态影像以电信号的方式捕捉、记录、处理、储存、传送、重现的各种技术。连续的静态图像变化每秒超过24帧&#xff08;frame&#xff09;以上时&#xff0c;由于视觉残留&#xff0c;人眼无法识别单独的静态图片&#xff0c;此时看上去就是平滑且…

快速排序详解以及java实现

快速排序作为一种高效的排序算法被广泛应用&#xff0c;SUN的JDK中的Arrays.sort 方法用的就是快排。 快排采用了经典的分治思想&#xff08;divide and conquer&#xff09;&#xff1a; Divide&#xff1a;选取一个基元X&#xff08;一般选取数组第一个元素&#xff09;&…

机票预订系统活动图_软件工程(第五版)--习题及答案技术总结.docx

PAGE \* MERGEFORMAT43《软件工程》(第五版)习题参考答案第1章 一、判断题1、()软件的维护与硬件维护本质上是相同的。 2、(√)软件在运行和使用中也存在退化问题。 3、()软件危机的产生主要是因为程序设计人员使用了不适当的程序设计语言。 4、(√)软件同其他事物一样&#xf…

android jni ——Field Method -- Accessing Field

现在我们知道了怎样使用native code访问简单的数据类型和引用参考类型&#xff08;string&#xff0c;array&#xff09;&#xff0c;下面我们来介绍怎样让jni代码去访问java中的成员变量和成员函数&#xff0c;然后可以再jni中回调java中的方法。 ---------------------------…

树状数组的建树 单点修改 单点查询 区间修改 区间查询

单点修改 单点查询 用普通数组就能写出来 单点修改 区间查询 用线段树 树状数组&#xff1b; 区间修改 区间查询 用线段树 树状数组&#xff1b; 区间修改 单点查询 用线段树 树状数组&#xff1b; 建树 #include<bits/stdc.h> using namespace std; …

bert 中文 代码 谷歌_如何用最强模型BERT做NLP迁移学习?

作者 | 台湾大学网红教授李宏毅的三名爱徒来源 | 井森堡&#xff0c;不定期更新机器学习技术文并附上质量佳且可读性高的代码。编辑 | Jane谷歌此前发布的NLP模型BERT&#xff0c;在知乎、Reddit上都引起了轰动。其模型效果极好&#xff0c;BERT论文的作者在论文里做的几个实验…

安装ubuntu20.04(安装vim、gcc、VMtools、中文输入法、汉化、修改IP、无法连网问题)

目录ubuntu安装包获取ubuntu的安装安装网络配置命令ifconfig连接网络(解决ubuntu无法连网问题)如何修改IP地址安装VMtools解决VMware Tools选项灰色VMtools安装安装中文&#xff0c;汉化添加中文输入法调整分辨率安装新版的Vim安装gccubuntu安装包获取 xunlei中直接搜索下载 …

arm-2014.05 编译三星内核错误 “not support ARM mode ‘smc 0’ ”

&#xff08;1&#xff09;arch/arm/mach-exynos/include/mach/smc.h文件&#xff1a; 在第54行和第69下面添加&#xff1a; __asm__ volatile (".arch_extension sec\n""smc 0\n": "r"(reg0), "r"(reg1), "r"(reg2), &…

从servlet中获取spring的WebApplicationContext

需要做一个参数初始化类&#xff0c;当web应用被加载时从数据库里取出相关的参数设置&#xff0c;并把这些参数放置到application里&#xff0c;jsp页面可以从中取出。1.在web.xml中配置&#xff1a; <servlet><servlet-name>Dispatcher</servlet-name><s…

python频率_Python中的频率分析

我试图使用Python来检索现场音频输入的主频率。目前&#xff0c;我正在试验使用音频流我的笔记本内置麦克风&#xff0c;但当测试以下代码时&#xff0c;我得到了非常差的结果。# Read from Mic Input and find the freqsimport pyaudioimport numpy as npimport bgeimport wav…

树莓派基于Linux内核驱动开发详解

目录一、驱动认知1.1 为什么要学习写驱动1.2 文件名与设备号1.3 open函数打通上层到底层硬件的详细过程二、基于框架编写驱动代码2.1 编写上层应用代码2.2 修改内核驱动框架代码2.3 部分代码解读2.3.1 static的作用2.3.2 结构体成员变量赋值方式2.3.3 结构体file_operations(最…

Spring AOP(三)--XML方式实现

本文介绍通过XML方式实现Spring AOP&#xff0c;在上一篇中已经介绍了通过注解&#xff0b;java配置的方式&#xff0c;这篇文章主要是看XML中怎么配置&#xff0c;直接上代码了&#xff1a; 一、创建一个连接点 1⃣️定义接口 注意⚠️&#xff1a;可以定义接口&#xff0c;也…

3.X内核下设备树–platform设备驱动

1。历史的车轮总是向前&#xff0c;技术更替。在linus 同学发出那句 WFK 后内核进入了设备树时代&#xff08;站在驱动工程师角度&#xff09;。 前几天我已经被mach-imx 中的文件折磨的夜不能眠。我终于在一个清晨&#xff0c;喝完一杯咖啡后决定放弃蹩脚的传统device描述方式…

六核cpu安装SQL Server 2005时报错,提示启动服务失败

2019独角兽企业重金招聘Python工程师标准>>> 新买的IBM3650M4的服务器上安装SQL server2005 安装到一半时&#xff0c;报"提示&#xff1a;SQL Server 服务无法启动。"错。 一开始以为是操作系统的问题&#xff0c;先重装了一遍&#xff0c;还是不行&…

postgis数据库优化_PostgreSQL批量导入性能优化

现在很多企业都将数据库逐渐由Mysql转向了更加强大而且开源的PostgreSQL数据库。在数据迁移过程中&#xff0c;PostgreSQL数据库导入大量数据时候非常缓慢&#xff0c;本文我们就来说说PostgreSQL数据库批量导入数据时的优化方法和策略。概述考虑PostgreSQL数据库批量导入数据时…