|  | 
| Edited by campioncino at 2016-2-27 01:36 
 and that's the dev folderCopy code#!/bin/bash
if [ "$(id -u)" != "0" ]; then
   echo "Script must be run as root !"
   exit 0
fi
echo ""
date
echo -e "\033[36m==============================="
echo "Installing Linux system to emmc"
echo -e "===============================\033[37m"
setterm -default
echo ""
_format=${1}
fatsize=64
sdcard="/dev/mmcblk1"
odir="/tmp/_extdir"
bootdir="/tmp/_fatdir"
if [ ! -b ${sdcard}boot0 ]; then
    echo "Error: EMMC not found."
    exit 1
fi
if [ ! -f /boot/boot0_OPI.fex ]; then
    echo "Error: boot0_OPI.fex not found."
    exit 1
fi
if [ ! -f /boot/u-boot_OPI-emmc.fex ]; then
    echo "Error: u-boot_OPI-emmc.fex not found."
    exit 1
fi
umount ${sdcard}* > /dev/null 2>&1
#----------------------------------------------------------
echo ""
echo -n "WARNING: EMMC WILL BE ERASED !, Continue (y/N)?  "
read -n 1 ANSWER
if [ ! "${ANSWER}" = "y" ] ; then
    echo "."
    echo "Canceled.."
    exit 0
fi
echo ""
#----------------------------------------------------------
echo "Erasing EMMC ..."
dd if=/dev/zero of=${sdcard} bs=1M count=32 > /dev/null 2>&1
sync
sleep 1
echo "Creating new filesystem on EMMC ..."
echo -e "o\nw" | fdisk ${sdcard} > /dev/null 2>&1
sync
echo "  New filesystem created on $sdcard."
sleep 1
partprobe -s ${sdcard} > /dev/null 2>&1
if [ $? -ne 0 ]; then
    echo "ERROR."
    exit 1
fi
sleep 1
echo "Partitioning EMMC ..."
sfat=40960
efat=$(( $fatsize * 1024 * 1024 / 512 + $sfat - 1))
echo "  Creating boot & linux partitions"
sext4=$(( $efat + 1))
eext4=""
echo -e "n\np\n1\n$sfat\n$efat\nn\np\n2\n$sext4\n$eext4\nt\n1\nb\nt\n2\n83\nw" | fdisk ${sdcard} > /dev/null 2>&1
echo "  OK."
sync
sleep 2
partprobe -s ${sdcard} > /dev/null 2>&1
if [ $? -ne 0 ]; then
    echo "ERROR."
    exit 1
fi
sleep 1
echo "Formating fat partition ..."
dd if=/dev/zero of=${sdcard}p1 bs=1M count=1 oflag=direct > /dev/null 2>&1
sync
sleep 1
mkfs.vfat -n EMMCBOOT ${sdcard}p1 > /dev/null 2>&1
if [ $? -ne 0 ]; then
    echo "  ERROR formating fat partition."
    exit 1
fi
echo "  fat partition formated."
dd if=/dev/zero of=${sdcard}p2 bs=1M count=1 oflag=direct > /dev/null 2>&1
sync
sleep 1
if [ "${_format}" = "btrfs" ] ; then
    echo "Formating linux partition (btrfs), please wait ..."
    # format as btrfs
    mkfs.btrfs -O ^extref,^skinny-metadata -f -L emmclinux ${sdcard}p2 > /dev/null 2>&1
    if [ $? -ne 0 ]; then
        echo "ERROR formating btrfs partition."
        exit 1
    fi
else
    echo "Formating linux partition (ext4), please wait ..."
    mkfs.ext4 -L emmclinux ${sdcard}p2 > /dev/null 2>&1
    if [ $? -ne 0 ]; then
        echo "ERROR formating ext4 partition."
        exit 1
    fi
fi
echo "  linux partition formated."
#************************************************************************
echo ""
echo "Instaling u-boot to EMMC ..."
dd if=/boot/boot0_OPI.fex of=${sdcard} bs=1k seek=8 > /dev/null 2>&1
if [ $? -ne 0 ]; then
    echo "ERROR installing u-boot."
    exit 1
fi
dd if=/boot/u-boot_OPI-emmc.fex of=${sdcard} bs=1k seek=16400 > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "ERROR installing u-boot."
exit 0
fi
sync
#************************************************************************
# -------------------------------------------------------------------
    
if [ ! -d $bootdir ]; then
    mkdir -p $bootdir
fi
rm $bootdir/* > /dev/null 2>&1
sync
umount $bootdir > /dev/null 2>&1
if [ ! -d $odir ]; then
    mkdir -p $odir
fi
rm -rf $odir/* > /dev/null 2>&1
sync
umount $odir > /dev/null 2>&1
sleep 1
# ================
# MOUNT PARTITIONS
# ================
if [ "${_format}" = "btrfs" ] ; then
    _mntopt="-o compress-force=lzo"
else
    _mntopt=""
fi
echo ""
echo "Mounting EMMC partitions..."
if ! mount ${sdcard}p1 $bootdir; then
    echo "ERROR mounting fat partitions..."
    exit 1
fi
if ! mount ${_mntopt} ${sdcard}p2 $odir; then
    echo "ERROR mounting linux partitions..."
    umount $bootdir
    exit 1
fi
echo "FAT partitions mounted to $bootdir"
echo "linux partition mounted to $odir"
#-----------------------------------------------------------------------------------------------
echo ""
echo "Copying file system to EMMC ..."
echo ""
#-----------------------------------------------------------------------------------------
rsync -r -t -p -o -g -x --delete -l -H -D --numeric-ids -s --stats / $odir/ > /dev/null 2>&1
if [ $? -ne 0 ]; then
    echo "  ERROR."
fi
#-----------------------------------------------------------------------------------------
sync
rm $odir/usr/local/bin/fs_resize_warning > /dev/null 2>&1
echo "  Creating "fstab""
echo "# OrangePI fstab" > $odir/etc/fstab
if [ "${_format}" = "btrfs" ] ; then
    echo "/dev/mmcblk0p2  /  btrfs subvolid=0,noatime,nodiratime,compress=lzo  0 1" >> $odir/etc/fstab
else
    echo "/dev/mmcblk0p2  /  ext4  errors=remount-ro,noatime,nodiratime  0 1" >> $odir/etc/fstab
fi
echo "/dev/mmcblk0p1  /media/boot  vfat  defaults  0 0" >> $odir/etc/fstab
echo "tmpfs /tmp  tmpfs nodev,nosuid,mode=1777  0 0" >> $odir/etc/fstab
sync
#-----------------------------------------------------------------------------------------
rsync -r -t -p -o -g -x --delete -l -H -D --numeric-ids -s --stats /media/boot/ $bootdir/ > /dev/null 2>&1
if [ $? -ne 0 ]; then
    echo "  ERROR."
fi
#-----------------------------------------------------------------------------------------
sync
# UMOUNT
if ! umount $bootdir; then
  echo "ERROR unmounting fat partition."
  exit 1
fi
rm -rf $bootdir/* > /dev/null 2>&1
rmdir $bootdir > /dev/null 2>&1
if ! umount $odir; then
    echo "ERROR unmounting linux partitions."
    exit 0
fi
rm -rf $odir/* > /dev/null 2>&1
rmdir $odir > /dev/null 2>&1
sync
echo ""
echo -e "\033[36m*******************************"
echo "Linux system installed to EMMC."
echo -e "*******************************\033[37m"
setterm -default
echo ""
exit 0
 Copy codeOpiElec:/dev # ls -a
.                   loop6               tty1                tty50
..                  loop7               tty10               tty51
apm_bios            mali                tty11               tty52
autofs              mem                 tty12               tty53
block               mmcblk0             tty13               tty54
bsg                 mmcblk0p1           tty14               tty55
btrfs-control       mmcblk0p2           tty15               tty56
bus                 mqueue              tty16               tty57
cachefiles          net                 tty17               tty58
cedar_dev           network_latency     tty18               tty59
char                network_throughput  tty19               tty6
console             null                tty2                tty60
cpu_dma_latency     ppp                 tty20               tty61
cuse                ptmx                tty21               tty62
deinterlace         pts                 tty22               tty63
disk                ram0                tty23               tty7
disp                ram1                tty24               tty8
fb0                 ram10               tty25               tty9
fb1                 ram11               tty26               ttyS0
fb2                 ram12               tty27               tv
fb3                 ram13               tty28               uhid
fb4                 ram14               tty29               uinput
fb5                 ram15               tty3                ump
fb6                 ram2                tty30               urandom
fb7                 ram3                tty31               usb
fd                  ram4                tty32               vcs
full                ram5                tty33               vcs1
fuse                ram6                tty34               vcs2
hdmi                ram7                tty35               vcs3
hidraw0             ram8                tty36               vcs4
hidraw1             ram9                tty37               vcs5
i2c-0               random              tty38               vcs6
initctl             rtc                 tty39               vcsa
input               rtc0                tty4                vcsa1
ion                 sda                 tty40               vcsa2
kmsg                shm                 tty41               vcsa3
lirc0               snd                 tty42               vcsa4
log                 spidev0.0           tty43               vcsa5
loop-control        stderr              tty44               vcsa6
loop0               stdin               tty45               vmouse
loop1               stdout              tty46               watchdog
loop2               sunxi-reg           tty47               zero
loop3               sunxi_soc_info      tty48
loop4               tty                 tty49
loop5               tty0                tty5
I think that sunxi-tools are missing
 
 | 
 |