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…

快速排序详解以及java实现

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

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), &…

树莓派基于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(最…

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;还是不行&…

网络编程知识预备(1) ——了解OSI网络模型

参考&#xff1a;简单了解OSI网络模型 作者&#xff1a;丶PURSUING 发布时间&#xff1a; 2021-03-18 20:07:09 网址&#xff1a;https://blog.csdn.net/weixin_44742824/article/details/114968802?spm1001.2014.3001.5502 根据需求摘抄自下面这篇文章&#xff0c;内容非常详…

antd表格显示分页怎么取消_真相!Word里怎么也删不掉的文档空白页原来是这样...

大家好&#xff0c;我是你们的海宝老师在Word里&#xff0c;经常会遇到这种情况&#xff1a;文档莫名其妙地多出一个或多个空白页&#xff0c;没啥内容却怎么也删不掉。不着急&#xff0c;咱们来一一分析。1、标题前的空白页像这种标题前面有空白&#xff0c;基本就是【段落】设…

网络编程知识预备(2) ——三次握手与四次挥手、流量控制(滑动窗口)、拥塞控制、半连接状态、2MSL

参考&#xff1a;浅显易懂的三次握手与四次挥手 作者&#xff1a;丶PURSUING 发布时间&#xff1a; 2021-03-19 09:33:20 网址&#xff1a;https://blog.csdn.net/weixin_44742824/article/details/114990198?spm1001.2014.3001.5502 参考&#xff1a;&#xff08;四十七&…

面向对象2

python之路——面向对象进阶 阅读目录 isinstance和issubclass反射setattr  delattr  getattr  hasattr__str__和__repr____del__item系列__getitem__  __setitem__  __delitem____new____call____len____hash____eq__回到顶部isinstance和issubclass isinstance(obj…

DM9000网卡原理与基地址设置

从上面可以看出DM9000的地址总线就一根&#xff0c;它不像CS8900那样地址总线和数据总线都齐全。而这里只有一根地址线(CMD)&#xff0c;16跟数据线&#xff0c;所以可以确定位宽为16位&#xff0c;而地址线为什么只有一根&#xff0c;这是DM9000决定的&#xff0c;看手册可以知…

网络编程知识预备(3) ——SOCKET、TCP、HTTP之间的区别与联系

参考&#xff1a;SOCKET,TCP,HTTP之间的区别与联系 作者&#xff1a;丶PURSUING 发布时间&#xff1a; 2021-03-19 11:54:01 网址&#xff1a;https://blog.csdn.net/weixin_44742824/article/details/114992140?spm1001.2014.3001.5502 参考&#xff1a;TCP连接、Http连接与S…

debian 9 安装后的配置,debian 9 开发环境。

注意&#xff1a;以下命令用sudo或者以root用户进行 一.Xterm&#xff08;在安装KDE桌面情况下&#xff09;的配置&#xff08;可以黏贴&#xff0c;复制&#xff09;&#xff1a; 首先在根目录下编辑文件.Xresources(没有可以创建) rootdebian:~# vim ~/.Xresources rootdebi…

嵌入式RT3070 AP模式移植

环境&#xff1a;ubuntu1~14.04.3 编译器&#xff1a;arm-none-linux-gnueabi-gcc-4.8.3 无线网卡为RT3070&#xff0c;驱动分为STA驱动和SoftAP驱动两种&#xff0c;STA驱动支持无线网卡工作在STA模式下&#xff0c;而SoftAP的驱动支持无线网卡工作在软AP的模式下&#xff0…

Wireshark抓包介绍和TCP三次握手分析

wireshark介绍 wireshark的官方下载网站&#xff1a; http://www.wireshark.org/ wireshark是非常流行的网络封包分析软件&#xff0c;功能十分强大。可以截取各种网络封包&#xff0c;显示网络封包的详细信息。 wireshark是开源软件&#xff0c;可以放心使用。 可以运行在Wind…