学生组织网站建设,安徽金鹏建设集团网站,企业做网站的注意什么,北京微网站建设#有时df -h查看分区信息无法满足需求#
借助Android系统自带的sgdisk可以查看详细的分区信息#xff0c;类似fdisk命令#xff0c;sgdisk同样可以创建分区#xff0c;功能也很强大。
一、sgdisk帮助信息
127|console:/ # sgdisk
USAGE: sgdisk [OPTION...] device类似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 partitions 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 dont 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, --attributeslist|[partnum:show|or|nand|xor||set|clear|toggle|get[:bitnum|hexbitmask]] operate on partition attributes-a, --set-alignmentvalue set sector alignment-b, --backupfile backup GPT to file-c, --change-namepartnum:name change partitions name-C, --recompute-chs recompute CHS values in protective/hybrid MBR-d, --deletepartnum 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, --hybridpartnum[:partnum...][:EE] create hybrid MBR-i, --infopartnum show detailed information on partition-j, --move-main-tablesector adjust the location of the main partition table-l, --load-backupfile load GPT backup from file-L, --list-types list known partition types-m, --gpttombrpartnum[:partnum...] convert GPT to MBR-n, --newpartnum:start:end create new partition-N, --largest-newpartnum 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 dont write them-r, --transposepartnum:partnum transpose two partitions-R, --replicatedevice_filename replicate partition table-s, --sort sort partition table entries-S, --resize-tablenumparts resize partition table-t, --typecodepartnum:{hexcode|GUID} change partition type code-T, --transform-bsdpartnum transform BSD disklabel partition to GPT-u, --partition-guidpartnum:guid set partition GUID-U, --disk-guidguid 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