linux 查看emmc分区表_嵌入式linux系统开机自动检测emmc,如果没有分区就格式化及自动分区的一种方法...

本文说明利用shell脚本实现linux系统上电自动检测emmc的一种方法。不需要人工去配置emmc,提升工作效率。

该脚本已经在海思平台HI3516CV300验证可行。

#!/bin/sh

#1.Determines whether the /data directory is mounted

echo "Determines whether the /data directory is mounted"

if mountpoint -q /data

then

echo "The /data directory has been mounted,will exit the shell"

exit

else

echo "The /data directory not mounted"

fi

#2.Determine if /dev/mmcblk0p1 exists. If so, try mount it first

echo "Determine if /dev/mmcblk0p1 exists. If so, try mount it first"

if [ -e '/dev/mmcblk0p1' ]

then

echo "/dev/mmcblk0p1 already exist!"

echo "do- mount /dev/mmcblk0p1 /data"

mount /dev/mmcblk0p1 /data

if [ "$?" = 0 ]

then

echo "mount /dev/mmcblk0p1 /data successful!!!"

else

echo "first mount failed,then do- mkfs.vfat  -I  /dev/mmcblk0p1"

mkfs.vfat  -I  /dev/mmcblk0p1

echo "do- mount /dev/mmcblk0p1 /data"

mount /dev/mmcblk0p1 /data

fi

exit

fi

#3.Partition the disk at /dev/mmcblk0

echo "Partition the disk at /dev/mmcblk0"

echo "First enter: n"

echo "Second enter: p"

echo "Third enter: 1"

echo "Fourth enter: 1"

echo "Five enter 120832"

echo "Six enter w"

fdisk  /dev/mmcblk0 << EOF

n

p

1

1

120832

w

EOF

if [ "$?" = 0 ]

then

if [ -e '/dev/mmcblk0p1' ]

then

echo "/dev/mmcblk0p1 exist!"

else

echo "/dev/mmcblk0p1 not exist!!!"

fi

else

echo "The fdisk command failed"

exit

fi

#4.Format the partition /dev/mmcblk0p1 and mount

echo "Format the partition /dev/mmcblk0p1 and mount"

echo "do-- mkfs.vfat  -I  /dev/mmcblk0p1"

mkfs.vfat  -I  /dev/mmcblk0p1

echo "do-- mount /dev/mmcblk0p1 /data"

mount /dev/mmcblk0p1 /data

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值