A question about Beaglebone black boot image

Hi
I installed debian on sd card by referring to the following site.
[https://www.digikey.com/eewiki/display/linuxonarm/BeagleBone+Black]

When I insert the sd card into the BBB and power it on, linux runs fine.

But when I install debian on emmc using a shell script,
the message ‘file has vanished’ keeps appearing and execution ends.
then when I boot from emmc, linux stops booting with error message and doesnot work any more.
I don’t know why.
could you let me know how to do fix it?

Error message - ‘file has vanished’

the following is the shell script for installing debian on sd card

#!/bin/bash

countdown() {
  local from_time=${1:-10}
  echo -n "wait for ${from_time} sec : "
  while [ $from_time -gt 0 ] ; do
    echo -n "${from_time} "
    sleep 1
    : $((from_time--))
  done
  echo ""
}

# select sd card
echo "[***] select sd card --------------------------------"
ROOTDRIVE=`mount | grep 'on / ' | awk {'print $1'} |  cut -c6-9`
if [ "$ROOTDRIVE" = "root" ]; then
    ROOTDRIVE=`readlink /dev/root | cut -c1-3`
else
    ROOTDRIVE=`echo $ROOTDRIVE | cut -c1-3`
fi

echo "root drive is ${ROOTDRIVE}"

echo "\nAvailable Drives to write images to: \n"
echo "#  major   minor    size   name "
cat /proc/partitions | grep -v $ROOTDRIVE | grep '\<sd.\>\|\<mmcblk.\>' | grep -n ''
echo " "

DEVICEDRIVENUMBER=
while true;
do
    read -p 'Enter Device Number or 'n' to exit: ' DEVICEDRIVENUMBER
    echo " "
        if [ "$DEVICEDRIVENUMBER" = 'n' ]; then
                exit 1
        fi

        if [ "$DEVICEDRIVENUMBER" = "" ]; then
                echo -e "These are the Drives available to write images to:"
                echo "#  major   minor    size   name "
                cat /proc/partitions | grep -v $ROOTDRIVE | grep '\<sd.\>\|\<mmcblk.\>' | grep -n ''
                echo " "
               continue
        fi

    DEVICEDRIVENAME=`cat /proc/partitions | grep -v $ROOTDRIVE | grep '\<sd.\>\|\<mmcblk.\>' 
| grep -n '' | grep "${DEVICEDRIVENUMBER}:" | awk '{print $5}'`
if [ -n "$DEVICEDRIVENAME" ]
then
        DRIVE=/dev/$DEVICEDRIVENAME
        DEVICESIZE=`cat /proc/partitions | grep -v $ROOTDRIVE | grep '\<sd.\>\|\<mmcblk.\>' | grep -n '' | grep "${DEVICEDRIVENUMBER}:" | awk '{print $4}'`
	break
else
	echo -e "Invalid selection!"
            echo -e "These are the only Drives available to write images to: \n"
            echo "#  major   minor    size   name "
            cat /proc/partitions | grep -v $ROOTDRIVE | grep '\<sd.\>\|\<mmcblk.\>' | grep -n ''
            echo " "
fi
done

DISK=/dev/$DEVICEDRIVENAME
NUM_OF_DRIVES=`df | grep -c $DEVICEDRIVENAME`

# Erase partition table/labels on microSD card
echo "[***] Erase partition table/labels on microSD card ----------"
sudo dd if=/dev/zero of=${DISK} bs=1M count=10
echo ""
countdown 5

# Install bootloader
echo "[***] Install bootloader ------------------------------------"
sudo dd if=./u-boot/MLO of=${DISK} count=1 seek=1 bs=128k
sudo dd if=./u-boot/u-boot.img of=${DISK} count=2 seek=1 bs=384k
echo ""
countdown 5

# Create partition layout : sfdisk version = 2.31.1
echo "[***] Create partition layout -------------------------------"
sudo sfdisk ${DISK} <<-__EOF__
4M,,L,*
__EOF__
sync
countdown 5
echo ""

#format partition : mkfs.ext4 version = 1.44.1
echo "[***] Format partition ---------------------------------------"
sudo mkfs.ext4 -L rootfs -O ^metadata_csum,^64bit ${DISK}1
sync
countdown 5
echo ""

# mount partition : son is username
echo "[***] Mount partition ---------------------------------------"
sudo mount ${DISK}1 /media/son/rootfs/
sync
countdown 5
echo ""

# backup bootloader
echo "[***] Backup bootloader -------------------------------------"
sudo mkdir -p /media/son/rootfs/opt/backup/uboot/
sudo cp -v ./u-boot/MLO /media/son/rootfs/opt/backup/uboot/
sudo cp -v ./u-boot/u-boot.img /media/son/rootfs/opt/backup/uboot/
echo ""

# kernel version : 4.14.106-bone-rt-r20
kernel_version=`cat ./bb-kernel/kernel_version`

# copy root file system
echo "[***] Copy root file system ---------------------------------"
sudo tar xfvp ./debian-9.8-*-armhf-*/armhf-rootfs-*.tar -C /media/son/rootfs/
sync
sudo chown root:root /media/son/rootfs/
sudo chmod 755 /media/son/rootfs/
echo ""

# set uEnv.txt : uname-r in /boot/uEnv.txt
echo "[***] Set uEnv.txt -------------------------------------------"
sudo sh -c "echo 'uname_r=${kernel_version}' >> /media/son/rootfs/boot/uEnv.txt"
sudo sh -c "echo 'enable_uboot_overlays=1' >> /media/son/rootfs/boot/uEnv.txt"
sudo sh -c "echo 'uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo' >> /media/son/rootfs/boot/uEnv.txt"
sudo sh -c "echo 'enable_uboot_cape_universal=1' >> /media/son/rootfs/boot/uEnv.txt"
sudo sh -c "echo 'cmdline=coherent_pool=1M net.ifnames=0 quiet' >> /media/son/rootfs/boot/uEnv.txt"
sudo sh -c "echo '#cmdline=init=/boot/flash_to_eMMC.sh' >> /media/son/rootfs/boot/uEnv.txt"
echo ""

# copy kernel image
echo "[***] Copy kernel image --------------------------------------"
sudo cp -v ./bb-kernel/deploy/${kernel_version}.zImage /media/son/rootfs/boot/vmlinuz-${kernel_version}
echo ""

# copy kernel device tree binaries
echo "[***] Copy kernel device tree binaries -----------------------"
sudo mkdir -p /media/son/rootfs/boot/dtbs/${kernel_version}/
sudo tar xfv ./bb-kernel/deploy/${kernel_version}-dtbs.tar.gz -C /media/son/rootfs/boot/dtbs/${kernel_version}/
echo ""

# copy kernel modules
echo "[***] Copy kernel modules ------------------------------------"
sudo tar xfv ./bb-kernel/deploy/${kernel_version}-modules.tar.gz -C /media/son/rootfs/
echo ""

# set file system table
echo "[***] Set file system table ----------------------------------"
sudo sh -c "echo '/dev/mmcblk0p1 / auto errors=remount-ro 0 1' >> /media/son/rootfs/etc/fstab"
echo ""

# copy network interface file
echo "[***] Copy network interface file ----------------------------"
sudo cp -v ./lib/interfaces /media/son/rootfs/etc/network/
sudo cp -v ./lib/networking.service /media/son/rootfs/lib/systemd/system/
echo ""

# using a shared sd card with multiple beaglebone
echo "[***] Using a shared sd card with multiple beaglebone --------"
sudo cp -v ./lib/70-persistent-net.rules /media/son/rootfs/etc/udev/rules.d/
echo ""

# copy flasher script
echo "[***] copy flasher script ------------------------------------"
sudo cp -v ./lib/bbb-eMMC-flasher-eewiki-ext4.sh /media/son/rootfs/opt/scripts/tools/eMMC/
sudo cp -v ./lib/flash_to_eMMC.sh /media/son/rootfs/boot/

sync
sync
sync
countdown 3

# copy flasher script
echo "[***] unmount sd card ------------------------------------"
sudo umount /media/son/rootfs
countdown 3
echo "[***] finished setting up sd card ------------------------"

the following is the shell script for installing debian on eMMC ( /boot/flash_to_eMMC.sh)

#!/bin/bash

countdown() {
  local from_time=${1:-10}
  echo -n "wait for ${from_time} sec : "
  while [ $from_time -gt 0 ] ; do
    echo -n "${from_time} "
    sleep 1
    : $((from_time--))
  done

  echo ""
}

sudo /bin/sh /opt/scripts/tools/version.sh
echo "================================================="
countdown 5
echo ""

sudo /bin/sh /opt/scripts/tools/eMMC/bbb-eMMC-flasher-eewiki-ext4.sh

Please, Let me know how to resolve it.
thank you.

@taek8461, You broke “bbb-eMMC-flasher-eewiki-ext4.sh” by calling it with /bin/sh…

sudo /bin/sh /opt/scripts/tools/eMMC/bbb-eMMC-flasher-eewiki-ext4.sh

bbb-eMMC-flasher-eewiki-ext4.sh contains a bash-ism in all the rsync calls…

rsync -aAx /* /tmp/rootfs/ --exclude={/dev/*,/proc/*....}

So by running it with /bin/sh, the --exclude parameter breaks and rsync tries to copy things it can’t… /proc/* etc…

So change your script to call it with /bin/bash

sudo /bin/bash /opt/scripts/tools/eMMC/bbb-eMMC-flasher-eewiki-ext4.sh

and it’ll work.

Regards,

Hi RobertCNelson

You are right. I resolved it.

Thank you so much~~~~~

1 Like