Difference between revisions of "Mksd-linux.sh"

From ESS-WIKI
Jump to: navigation, search
(Created page with " #!/bin/bash echo -e "\nTransfer U-Boot & Linux to target device\n" [ $# -lt 1 ] && echo "Please input target device, e.g. ./mksd-linux.sh /dev/mmcblk0" && exit 1<br/> [ ! -...")
 
(Blanked the page)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
  
#!/bin/bash
 
 
echo -e "\nTransfer U-Boot & Linux to target device\n"
 
 
[ $# -lt 1 ] && echo "Please input target device, e.g. ./mksd-linux.sh /dev/mmcblk0" && exit 1<br/> [ ! -e $1 ] && echo "Device $1 not found" && exit 1<br/> [ "`cat /sys/block/${1##*/}/device/type`" == "SD" ] && echo "Device $1 is type of SD." && exit 1
 
 
echo "All data on "$1" now will be destroyed! Continue? [y/n]"<br/> read ans<br/> if [ $ans != 'y' ]; then exit 1; fi
 
 
echo 0 > /proc/sys/kernel/printk
 
 
check_node=`echo $1 | grep mmc`<br/> if [ -n "$check_node" ];then<br/> &nbsp; &nbsp; &nbsp; &nbsp; part="p"<br/> fi
 
 
echo "[Unmounting all existing partitions on the device ]"
 
 
umount $1* &> /dev/null
 
 
echo "[Partitioning $1...]"<br/> DRIVE=$1
 
 
cd ../image
 
 
filename=`ls | grep wic`
 
 
if [ $filename ];then<br/> &nbsp; &nbsp; echo "[Copy $filename image]"<br/> &nbsp; &nbsp; dd if=$filename of=$1 &>/dev/null<br/> else<br/> &nbsp; &nbsp; echo No such Image file<br/> &nbsp; &nbsp; exit 1<br/> fi<br/> echo "[Resize filesystems...]"
 
 
rootfs_start=`fdisk -u -l ${DRIVE} | grep ${DRIVE}${part}2 | awk '{print $2}'`
 
 
# Create partition table for extend root file system (/dev/mmcblk1p2) partition<br/> fdisk -u $DRIVE << EOF &>/dev/null<br/> d<br/> 2<br/> n<br/> p<br/> $rootfs_start
 
 
w<br/> EOF
 
 
if [ -x /sbin/partprobe ]; then<br/> &nbsp; &nbsp; /sbin/partprobe ${DRIVE} &> /dev/null<br/> else<br/> &nbsp; &nbsp; sleep 1<br/> fi
 
 
e2fsck -f -y ${DRIVE}${part}2 &> /dev/null<br/> resize2fs ${DRIVE}${part}2 &> /dev/null
 
 
if [ -x /sbin/partprobe ]; then<br/> &nbsp; &nbsp; /sbin/partprobe ${DRIVE} &> /dev/null<br/> else<br/> &nbsp; &nbsp; sleep 1<br/> fi
 
 
echo 7 > /proc/sys/kernel/printk<br/> echo "[Done]"
 

Latest revision as of 08:52, 5 March 2024