I run ArchLinux ARM on my BBB from the on board eMMC. I create a microSD
image on another ARM Linux system (a PogoPlug) and install that image on
the eMMC using a series of three scripts.
Script 1 - partitions/formats the microSD card
Script 2 - installs the ArchLinux files on the microSD card
Script 3 - I execute on the BBB once I've booted the BBB with the microSD I
just prepared.
There are some custom/unique items in my scripts (e.g., to run Script 2 it
assume the Script 3 file called *bbb-make-emmc-arch.sh* is actually on your
Linux system so it can be copied to the microSD card and executed as the
last step in my installation process). Even if you don't use ArchLinux ARM, there
is still helpful information for folks who may want to create their own
eMMC initialization scripts. Below are my three scripts ... enjoy.
Script 1
# bbb-fdisk-sd.sh
# This script partitions SD media for use as a boot device for a BeagleBone
# or BeagleBone black. The first partition (boot) is sized at 16MB. If you
# want a larger partition, change the code below (look for +16M). This
script
# assumes the device you want to partition is located at /dev/sd?. Make
sure
# you verify the correct device name before proceeding.
DEVICELIST=`ls /dev/sd? 2> /dev/null | sed s:/dev/::`
if [ -z "${DEVICELIST}" ]; then
echo "ERROR: No /dev/sd? devices"
exit
fi
clear
echo Device Choices: $DEVICELIST
echo
while true
do
read -p "Enter device name: " DEVICECHOICE
if echo "$DEVICECHOICE" | grep -q "$DEVICELIST"
then
break
else
echo "ERROR: You entered an invalid device name."
fi
done
echo
while true
do
read -p "Are you sure you want to use /dev/$DEVICECHOICE (answer yes or
no)? " ANSWER
case $ANSWER in
yes ) break;;
no ) exit;;
* ) echo "ERROR: Please answer yes or no.";;
esac
done
fdisk /dev/$DEVICECHOICE << EOF
+16M
EOF
Script 2
# bbb-make-sd-arch.sh
# This script is used to create a new (clean) install of ArchLinux for the
BeagleBone or
# BeagleBoneBlack on a microSD card. Verify your media devices before you
proceed. This
# script assumes your media device is /dev/sd?. Ensure you have
partitioned (fdisk) your
# media before proceeding. You will need two partitions. The first
partition does not need
# to be large, but needs to be set to bootable and must be type 'e' which
is FAT 16.
# The second partition is a normal Linux partition, probably ext4. If you
can't mkfs.vfat,
# download the dosfstools (pacman -Sy dosfstools).
clear
DEVICELIST=`ls /dev/sd? 2> /dev/null | sed s:/dev/::`
if [ -z "${DEVICELIST}" ]; then
echo "ERROR: No /dev/sd? devices"
exit
fi
echo Device Choices: $DEVICELIST
echo
while true
do
read -p "Enter device name: " DEVICECHOICE
if echo "$DEVICECHOICE" | grep -q "$DEVICELIST"
then
break
else
echo "ERROR: You entered an invalid device name."
fi
done
echo
while true
do
read -p "Are you sure you want to use /dev/$DEVICECHOICE (answer yes or
no)? " ANSWER
case $ANSWER in
yes) break;;
no) exit;;
*) echo "ERROR: Please answer yes or no.";;
esac
done
BOOTLOADER=BeagleBone-bootloader.tar.gz
ARCHLINUX=ArchLinuxARM-am33x-latest.tar.gz
WORKINGDIR=.
BOOTDEV=/dev/$DEVICECHOICE'1'
BOOTTMP=$WORKINGDIR/boot
ROOTDEV=/dev/$DEVICECHOICE'2'
ROOTTMP=$WORKINGDIR/root
BOOTIMAGE=$ROOTTMP/boot/zImage
BBBSCRIPT=/home/public/bbb-make-emmc-arch.sh
mkfs.vfat -F 16 -n "bootloader" $BOOTDEV
sleep 1
mkfs.ext4 -L "rootfs" $ROOTDEV
sleep 1
mkdir $BOOTTMP
mkdir $ROOTTMP
mount $BOOTDEV $BOOTTMP
mount $ROOTDEV $ROOTTMP
wget http://archlinuxarm.org/os/omap/$BOOTLOADER -O $WORKINGDIR/$BOOTLOADER
sleep 1
wget http://archlinuxarm.org/os/$ARCHLINUX -O $WORKINGDIR/$ARCHLINUX
sleep 1
if which pv > /dev/null
then
pv $WORKINGDIR/$BOOTLOADER | tar xzf - -C $BOOTTMP
pv $WORKINGDIR/$ARCHLINUX | tar xzf - -C $ROOTTMP
else
tar xvf $WORKINGDIR/$BOOTLOADER -C $BOOTTMP
tar xvf $WORKINGDIR/$ARCHLINUX -C $ROOTTMP
fi
echo "Copying Boot Image"
cp $BOOTIMAGE $BOOTTMP
echo "Copying" $BBBSCRIPT "script to /"
cp $BBBSCRIPT /
echo "Synching"
sync
umount $BOOTTMP
umount $ROOTTMP
rmdir $BOOTTMP
rmdir $ROOTTMP
clear
echo "Upload Complete"
echo
while true
do
read -p "Delete downloaded files (answer yes or no)? " ANSWER
case $ANSWER in
yes )
rm $WORKINGDIR/$BOOTLOADER
rm $WORKINGDIR/$ARCHLINUX
exit
;;
no ) exit;;
* ) echo "ERROR: Please answer yes or no.";;
esac
done
Script 3
# bbb-make-emmc-arch.sh
# This script is used to create a new (clean) install of ArchLinux ARM to
the BeagleBone Black's
# onboard eMMC storage. This script assumes you have booted the BeagleBone
Black using a microSD
# card with the appropriate ArchLinux ARM files and now want to install
ArchLinux in the onboard
# eMMC memory.
BOOTLOADER=BeagleBone-bootloader.tar.gz
ARCHLINUX=ArchLinuxARM-am33x-latest.tar.gz
WORKINGDIR=/tmp
BOOTDEV=/dev/mmcblk1p1
BOOTTMP=$WORKINGDIR/boot
ROOTDEV=/dev/mmcblk1p2
ROOTTMP=$WORKINGDIR/root
BOOTIMAGE=$ROOTTMP/boot/zImage
clear
while true
do
echo "You need the mkfs.vfat format and wget commands."
echo "Use pacman -Sy wget AND pacman -Sy dosfstools (for vfat format)."
echo
read -p "Are these two commands installed (answer yes or no)? " ANSWER
case $ANSWER in
yes) break;;
no) exit;;
*) echo "ERROR: Please answer yes or no.";;
esac
done
mkfs.vfat -F 16 -n "bootloader" $BOOTDEV
sleep 1
mkfs.ext4 -L "rootfs" $ROOTDEV
sleep 1
mkdir $BOOTTMP
mkdir $ROOTTMP
mount $BOOTDEV $BOOTTMP
mount $ROOTDEV $ROOTTMP
wget http://archlinuxarm.org/os/omap/$BOOTLOADER -O $WORKINGDIR/$BOOTLOADER
sleep 1
wget http://archlinuxarm.org/os/$ARCHLINUX -O $WORKINGDIR/$ARCHLINUX
sleep 1
if which pv > /dev/null
then
pv $WORKINGDIR/$BOOTLOADER | tar xzf - -C $BOOTTMP
pv $WORKINGDIR/$ARCHLINUX | tar xzf - -C $ROOTTMP
else
tar xvf $WORKINGDIR/$BOOTLOADER -C $BOOTTMP
tar xvf $WORKINGDIR/$ARCHLINUX -C $ROOTTMP
fi
echo "Copying Boot Image"
cp $BOOTIMAGE $BOOTTMP
echo "Synching"
sync
umount $BOOTTMP
umount $ROOTTMP
rmdir $BOOTTMP
rmdir $ROOTTMP
clear
while true
do
read -p "Delete downloaded files (answer yes or no)? " ANSWER
case $ANSWER in
yes)
rm $WORKINGDIR/$BOOTLOADER
rm $WORKINGDIR/$ARCHLINUX
exit
;;
no) exit;;
*) echo "ERROR: Please answer yes or no.";;
esac
done
image on another ARM Linux system (a PogoPlug) and install that image on
the eMMC using a series of three scripts.
Script 1 - partitions/formats the microSD card
Script 2 - installs the ArchLinux files on the microSD card
Script 3 - I execute on the BBB once I've booted the BBB with the microSD I
just prepared.
There are some custom/unique items in my scripts (e.g., to run Script 2 it
assume the Script 3 file called *bbb-make-emmc-arch.sh* is actually on your
Linux system so it can be copied to the microSD card and executed as the
last step in my installation process). Even if you don't use ArchLinux ARM, there
is still helpful information for folks who may want to create their own
eMMC initialization scripts. Below are my three scripts ... enjoy.
Script 1
# bbb-fdisk-sd.sh
# This script partitions SD media for use as a boot device for a BeagleBone
# or BeagleBone black. The first partition (boot) is sized at 16MB. If you
# want a larger partition, change the code below (look for +16M). This
script
# assumes the device you want to partition is located at /dev/sd?. Make
sure
# you verify the correct device name before proceeding.
DEVICELIST=`ls /dev/sd? 2> /dev/null | sed s:/dev/::`
if [ -z "${DEVICELIST}" ]; then
echo "ERROR: No /dev/sd? devices"
exit
fi
clear
echo Device Choices: $DEVICELIST
echo
while true
do
read -p "Enter device name: " DEVICECHOICE
if echo "$DEVICECHOICE" | grep -q "$DEVICELIST"
then
break
else
echo "ERROR: You entered an invalid device name."
fi
done
echo
while true
do
read -p "Are you sure you want to use /dev/$DEVICECHOICE (answer yes or
no)? " ANSWER
case $ANSWER in
yes ) break;;
no ) exit;;
* ) echo "ERROR: Please answer yes or no.";;
esac
done
fdisk /dev/$DEVICECHOICE << EOF
+16M
EOF
Script 2
# bbb-make-sd-arch.sh
# This script is used to create a new (clean) install of ArchLinux for the
BeagleBone or
# BeagleBoneBlack on a microSD card. Verify your media devices before you
proceed. This
# script assumes your media device is /dev/sd?. Ensure you have
partitioned (fdisk) your
# media before proceeding. You will need two partitions. The first
partition does not need
# to be large, but needs to be set to bootable and must be type 'e' which
is FAT 16.
# The second partition is a normal Linux partition, probably ext4. If you
can't mkfs.vfat,
# download the dosfstools (pacman -Sy dosfstools).
clear
DEVICELIST=`ls /dev/sd? 2> /dev/null | sed s:/dev/::`
if [ -z "${DEVICELIST}" ]; then
echo "ERROR: No /dev/sd? devices"
exit
fi
echo Device Choices: $DEVICELIST
echo
while true
do
read -p "Enter device name: " DEVICECHOICE
if echo "$DEVICECHOICE" | grep -q "$DEVICELIST"
then
break
else
echo "ERROR: You entered an invalid device name."
fi
done
echo
while true
do
read -p "Are you sure you want to use /dev/$DEVICECHOICE (answer yes or
no)? " ANSWER
case $ANSWER in
yes) break;;
no) exit;;
*) echo "ERROR: Please answer yes or no.";;
esac
done
BOOTLOADER=BeagleBone-bootloader.tar.gz
ARCHLINUX=ArchLinuxARM-am33x-latest.tar.gz
WORKINGDIR=.
BOOTDEV=/dev/$DEVICECHOICE'1'
BOOTTMP=$WORKINGDIR/boot
ROOTDEV=/dev/$DEVICECHOICE'2'
ROOTTMP=$WORKINGDIR/root
BOOTIMAGE=$ROOTTMP/boot/zImage
BBBSCRIPT=/home/public/bbb-make-emmc-arch.sh
mkfs.vfat -F 16 -n "bootloader" $BOOTDEV
sleep 1
mkfs.ext4 -L "rootfs" $ROOTDEV
sleep 1
mkdir $BOOTTMP
mkdir $ROOTTMP
mount $BOOTDEV $BOOTTMP
mount $ROOTDEV $ROOTTMP
wget http://archlinuxarm.org/os/omap/$BOOTLOADER -O $WORKINGDIR/$BOOTLOADER
sleep 1
wget http://archlinuxarm.org/os/$ARCHLINUX -O $WORKINGDIR/$ARCHLINUX
sleep 1
if which pv > /dev/null
then
pv $WORKINGDIR/$BOOTLOADER | tar xzf - -C $BOOTTMP
pv $WORKINGDIR/$ARCHLINUX | tar xzf - -C $ROOTTMP
else
tar xvf $WORKINGDIR/$BOOTLOADER -C $BOOTTMP
tar xvf $WORKINGDIR/$ARCHLINUX -C $ROOTTMP
fi
echo "Copying Boot Image"
cp $BOOTIMAGE $BOOTTMP
echo "Copying" $BBBSCRIPT "script to /"
cp $BBBSCRIPT /
echo "Synching"
sync
umount $BOOTTMP
umount $ROOTTMP
rmdir $BOOTTMP
rmdir $ROOTTMP
clear
echo "Upload Complete"
echo
while true
do
read -p "Delete downloaded files (answer yes or no)? " ANSWER
case $ANSWER in
yes )
rm $WORKINGDIR/$BOOTLOADER
rm $WORKINGDIR/$ARCHLINUX
exit
;;
no ) exit;;
* ) echo "ERROR: Please answer yes or no.";;
esac
done
Script 3
# bbb-make-emmc-arch.sh
# This script is used to create a new (clean) install of ArchLinux ARM to
the BeagleBone Black's
# onboard eMMC storage. This script assumes you have booted the BeagleBone
Black using a microSD
# card with the appropriate ArchLinux ARM files and now want to install
ArchLinux in the onboard
# eMMC memory.
BOOTLOADER=BeagleBone-bootloader.tar.gz
ARCHLINUX=ArchLinuxARM-am33x-latest.tar.gz
WORKINGDIR=/tmp
BOOTDEV=/dev/mmcblk1p1
BOOTTMP=$WORKINGDIR/boot
ROOTDEV=/dev/mmcblk1p2
ROOTTMP=$WORKINGDIR/root
BOOTIMAGE=$ROOTTMP/boot/zImage
clear
while true
do
echo "You need the mkfs.vfat format and wget commands."
echo "Use pacman -Sy wget AND pacman -Sy dosfstools (for vfat format)."
echo
read -p "Are these two commands installed (answer yes or no)? " ANSWER
case $ANSWER in
yes) break;;
no) exit;;
*) echo "ERROR: Please answer yes or no.";;
esac
done
mkfs.vfat -F 16 -n "bootloader" $BOOTDEV
sleep 1
mkfs.ext4 -L "rootfs" $ROOTDEV
sleep 1
mkdir $BOOTTMP
mkdir $ROOTTMP
mount $BOOTDEV $BOOTTMP
mount $ROOTDEV $ROOTTMP
wget http://archlinuxarm.org/os/omap/$BOOTLOADER -O $WORKINGDIR/$BOOTLOADER
sleep 1
wget http://archlinuxarm.org/os/$ARCHLINUX -O $WORKINGDIR/$ARCHLINUX
sleep 1
if which pv > /dev/null
then
pv $WORKINGDIR/$BOOTLOADER | tar xzf - -C $BOOTTMP
pv $WORKINGDIR/$ARCHLINUX | tar xzf - -C $ROOTTMP
else
tar xvf $WORKINGDIR/$BOOTLOADER -C $BOOTTMP
tar xvf $WORKINGDIR/$ARCHLINUX -C $ROOTTMP
fi
echo "Copying Boot Image"
cp $BOOTIMAGE $BOOTTMP
echo "Synching"
sync
umount $BOOTTMP
umount $ROOTTMP
rmdir $BOOTTMP
rmdir $ROOTTMP
clear
while true
do
read -p "Delete downloaded files (answer yes or no)? " ANSWER
case $ANSWER in
yes)
rm $WORKINGDIR/$BOOTLOADER
rm $WORKINGDIR/$ARCHLINUX
exit
;;
no) exit;;
*) echo "ERROR: Please answer yes or no.";;
esac
done