download fomat install rootfs script

download.sh

#!/bin/sh

# check the network first

serverip=$(cat /tmp/serverip)

while true; do
ping -c 5 $serverip;
if [ $? = 0 ];then
break;
fi
done

# then disable the firewall
/etc/init.d/firewall stop

cd /tmp

tftp -g -r rootfs.tar.gz $serverip

cd /

format.sh

#!/bin/sh

mmcdev=/dev/mmcblk0
# check device
while true;do
if [ -e $mmcdev ];then
break;
else
sleep 1;
fi
done

echo "d
n
p
1


w" |/usr/sbin/fdisk $mmcdev

mmcpart=${mmcdev}p1

while true;do
if [ -e $mmcpart ];then
break;
else
sleep 1;
fi
done

echo "y
" | /usr/sbin/mkfs.ext4 $mmcpart

 

install.sh

#!/bin/sh

mmcpart=/dev/mmcblk0p1

if [ ! -e $mmcpart ];then
echo "format the eMMC device failed";
exit
fi

tarfile=/tmp/rootfs.tar.gz

if [ ! -f $tarfile ]; then
echo "download the armbian failed";
exit
fi

mount $mmcpart /mnt

if [ $? = 1 ];then
echo "format the eMMC device failed";
exit
fi

cd /mnt

tar vxzf $tarfile

cd /

umount /mnt

echo "install finish"

 

posted @ 2019-01-15 17:38  嵌入式实操  阅读(113)  评论(0编辑  收藏  举报