sfdisk命令使用问题

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
hengshanhu
帖子: 7
注册时间: 2018-05-18 9:54
系统: 16.04

sfdisk命令使用问题

#1

帖子 hengshanhu » 2018-05-18 9:59

我使用命sfdisk命令分区SD卡做一个启动盘,但是sfdisk -D和-H都不能识别,这个问题怎么解决,望大神指导
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: sfdisk命令使用问题

#2

帖子 poloshiao » 2018-05-18 10:11

sfdisk -D和-H都不能识别
系统: 16.04
http://manpages.ubuntu.com/manpages/xen ... isk.8.html
sfdisk - display or manipulate a disk partition table
sfdisk 沒有 -D, -H 參數
hengshanhu
帖子: 7
注册时间: 2018-05-18 9:54
系统: 16.04

Re: sfdisk命令使用问题

#3

帖子 hengshanhu » 2018-05-18 10:22

代码: 全选

echo DISK SIZE - $SIZE bytes

CYLINDERS=`echo $SIZE/255/63/512 | bc`

# Start single partition starting at 2MB offset. First 2MB is used for boot image loading
sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE << EOF
2,,,*
EOF
这是官方给的制作启动卡的脚本,不会也是错的吧?
hengshanhu
帖子: 7
注册时间: 2018-05-18 9:54
系统: 16.04

Re: sfdisk命令使用问题

#4

帖子 hengshanhu » 2018-05-18 10:30

代码: 全选

echo DISK SIZE - $SIZE bytes

CYLINDERS=`echo $SIZE/255/63/512 | bc`

# Start single partition starting at 2MB offset. First 2MB is used for boot image loading
sfdisk -D -H 255 -S 63 $CYLINDERS $DRIVE << EOF
2,,,*
EOF[/code这是官方给的制作启动卡的脚本,难道有问题?
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: sfdisk命令使用问题

#5

帖子 poloshiao » 2018-05-18 10:47

sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE << EOF
1. sfdisk 自 2.26 版本開始 不再支援 CHS (Cylinder-Head-Sector) addressing
1-1. http://manpages.ubuntu.com/manpages/xen ... isk.8.html
Since version 2.26 sfdisk supports MBR (DOS), GPT, SUN and SGI disk
labels, but no longer provides any functionality for CHS (Cylinder-
Head-Sector) addressing. CHS has never been important for Linux, and
this addressing concept does not make any sense for new devices.

2. Ubuntu 16.04 以後 sfdisk 已經是 2.27
2-1. https://packages.ubuntu.com/search?suit ... chon=names
xenial (16.04LTS) (utils): miscellaneous system utilities
2.27.1-6ubuntu3: amd64 arm64 armhf i386 powerpc ppc64el s390x
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: sfdisk命令使用问题

#6

帖子 poloshiao » 2018-05-18 10:48

这是官方给的制作启动卡的脚本,不会也是错的吧?
查閱 版本 是否適用
hengshanhu
帖子: 7
注册时间: 2018-05-18 9:54
系统: 16.04

Re: sfdisk命令使用问题

#7

帖子 hengshanhu » 2018-05-18 10:51

那上面这个脚本该怎么修改呢?
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: sfdisk命令使用问题

#8

帖子 poloshiao » 2018-05-18 10:58

官方给的制作启动卡的脚本
請提供該官方腳本的網址
hengshanhu
帖子: 7
注册时间: 2018-05-18 9:54
系统: 16.04

Re: sfdisk命令使用问题

#9

帖子 hengshanhu » 2018-05-18 11:15

文件在一个软件包里面,下载还不小,我就把整个代码贴在这里了!!!

代码: 全选

#!/bin/sh

user=`whoami`
if [[ $user != "root" ]];
then
echo "Should run by root only ! (use : sudo)"
exit 1
fi

if [ $# -eq 0 ]
  then
    echo "No arguments supplied ! (e.g, usage : sudo sh create-sdcard-omapl13x.sh /dev/sdb "
exit 1
fi

DRIVE=$1

# Un mount all the partitions.
echo "Un mounting all the partitions..."

sudo umount $DRIVE"1"

dd if=/dev/zero of=$DRIVE bs=1024 count=1024

SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`

echo DISK SIZE - $SIZE bytes

CYLINDERS=`echo $SIZE/255/63/512 | bc`

# Start single partition starting at 2MB offset. First 2MB is used for boot image loading
sfdisk -D -H 255 -S 63 $CYLINDERS $DRIVE << EOF
2,,,*
EOF

mkfs.vfat -F 32 -n "boot" ${DRIVE}1
umount ${DRIVE}1

echo "Done !"
万分感谢大神的帮助
头像
astolia
论坛版主
帖子: 6399
注册时间: 2008-09-18 13:11

Re: sfdisk命令使用问题

#10

帖子 astolia » 2018-05-18 16:41

稍微读了一下manpage,用新版程序的话脚本里sfdisk那段应该这么写

代码: 全选

sfdisk $DRIVE << EOF
label:dos
start=2MiB,bootable
EOF
不过反正目的是用DOS分区表再建个分区前面留2MB再格式化为fat32,用图形化的工具比如gparted来做就是了,或者用fdisk之类的交互式分区工具也好过研究半天命令行参数
hengshanhu
帖子: 7
注册时间: 2018-05-18 9:54
系统: 16.04

Re: sfdisk命令使用问题

#11

帖子 hengshanhu » 2018-05-18 17:42

好像不行哦,
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: sfdisk命令使用问题

#12

帖子 poloshiao » 2018-05-19 10:13

文件在一个软件包里面
1. 請提供該軟件包名稱及詳細版本(不要摘要)
2. 請提供文件檔案全名
回复