sfdisk [options] device …
常用選項:
-s [or --show-size]: 顯示一個分區的大小
-c [or --id]: 顯示或者修改文件系統類型ID
-l [or --list]: 顯示每個設備的分區表信息
-d [or --dump]: 同上,但是以一個格式化的方式輸出
-i [or --increment]: number cylinders etc. from 1 instead of from 0
-uS, -uB, -uC, -uM: 以扇面/塊/柱面數/MB為單位 顯示或形成報告
-T [or --list-types]:顯示所有已知的sfdisk能辨識的文件系統ID
-D [or --DOS]: 兼容DOS但是會浪費一點磁盤空間
-R [or --re-read]: 讓內核重新讀取分區表
-N# : 只改變分區的編號 #
-n : 修改但實際上並沒有保存到磁盤
-O file : 保存扇面修改並寫入分區表文件
-I file : 重新恢復修改的扇面
危險的選項:
-g [or --show-geometry]: print the kernel’s idea of the geometry
-G [or --show-pt-geometry]: print geometry guessed from the partition table
-x [or --show-extended]: also list extended partitions on output
or expect descriptors for them on input
-L [or --Linux]: do not complain about things irrelevant for Linux
-q [or --quiet]: suppress warning messages
You can override the detected geometry using:
-C# [or --cylinders #]:set the number of cylinders to use //設置要使用的氣缸數
-H# [or --heads #]: set the number of heads to use //設置要使用的磁頭數
-S# [or --sectors #]: set the number of sectors to use //設置要使用的扇區數
柱面大小=512*256(磁頭數)*64(扇區)
eg.
#!/bin/sh
export LANG=C
export LANGUAGE=en
device="/dev/mmcblk0"
PC_HIBERNATE=32
PC_ROOTFS=112
PC_PRODUCT=32
PC_DATA=224
PC_LOG=32
PC_VR=150
PC_BACKUP=16
PC_MAP=3000
PC_EXTEND=$((${PC_DATA}+${PC_LOG}+${PC_VR}+${PC_BACKUP}+${PC_MAP}))
PC_TOTAL=$((${PC_HIBERNATE}+${PC_ROOTFS}+${PC_PRODUCT}+${PC_EXTEND}))
FORMAT_P9=1
FMT_HIB="0xA0"
FMT_FAT="0x0C"
FMT_LINUX="0x83"
FMT_EXTEND="0x05"
if [ -e "/dev/mmcblk0p9" ]; then
echo "/dev/mmcblk0p9 is exist"
FORMAT_P9=0
fi
execute ()
{
$* >/dev/null
if [ $? -ne 0 ]; then
echo
echo "ERROR: executing $*"
echo
exit 1
fi
}
#echo "************************************************************"
#echo "* THIS WILL DELETE ALL THE DATA ON $device "
#echo "* *"
#echo "* Press to confirm.... *"
#echo "************************************************************"
#read junk
{
echo ,${PC_HIBERNATE},${FMT_HIB},-
echo ,${PC_ROOTFS},${FMT_LINUX},-
echo ,${PC_PRODUCT},${FMT_LINUX},-
echo ,${PC_EXTEND},${FMT_EXTEND},-
echo ,${PC_DATA},${FMT_LINUX},-
echo ,${PC_LOG},${FMT_LINUX},-
echo ,${PC_VR},${FMT_LINUX},-
echo ,${PC_BACKUP},${FMT_LINUX},-
echo ,${PC_MAP},${FMT_LINUX},-
} | sfdisk -D -H 255 -S 63 -C ${PC_TOTAL} ${device}
echo "Formatting ${device}p2"
execute "mkfs.ext4 -L rootfs -b 4096 -j ${device}p2"
execute "tune2fs -c 0 -i 0 ${device}p2"
echo "Formatting ${device}p3"
execute "mkfs.ext4 -L product -b 4096 -j ${device}p3"
execute "tune2fs -c 0 -i 0 ${device}p3"
echo "Formatting ${device}p5"
execute "mkfs.ext4 -L external -b 4096 -j ${device}p5"
execute "tune2fs -c 0 -i 0 ${device}p5"
echo "Formatting ${device}p6"
execute "mkfs.ext4 -L log -b 4096 -j ${device}p6"
execute "tune2fs -c 0 -i 0 ${device}p6"
echo "Formatting ${device}p7"
execute "mkfs.ext4 -L vr -b 4096 -j ${device}p7"
execute "tune2fs -c 0 -i 0 ${device}p7"
echo "Formatting ${device}p8"
execute "mkfs.ext4 -L backup -b 4096 -j ${device}p8"
execute "tune2fs -c 0 -i 0 ${device}p8"
if [ $FORMAT_P9 -eq 1 ];then
echo "Formatting ${device}p9"
execute "mkfs.ext4 -L map -b 4096 -j ${device}p9"
execute "tune2fs -c 0 -i 0 ${device}p9"
else
echo "FORMAT_P9=${FORMAT_P9},skip Formatting ${device}p9"
fi