# 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" exitfi
clearecho Device Choices: $DEVICELISTechowhile truedo read -p "Enter device name: " DEVICECHOICE if echo "$DEVICECHOICE" | grep -q "$DEVICELIST" then break else echo "ERROR: You entered an invalid device name." fidone
echowhile truedo 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.";; esacdone
fdisk /dev/$DEVICECHOICE << EOFopnp1
+16Mnp2
a1t1epwEOF# 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).
clearDEVICELIST=`ls /dev/sd? 2> /dev/null | sed s:/dev/::`if [ -z "${DEVICELIST}" ]; then echo "ERROR: No /dev/sd? devices" exitfi
echo Device Choices: $DEVICELISTechowhile truedo read -p "Enter device name: " DEVICECHOICE if echo "$DEVICECHOICE" | grep -q "$DEVICELIST" then break else echo "ERROR: You entered an invalid device name." fidone
echowhile truedo 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.";; esacdone
BOOTLOADER=BeagleBone-bootloader.tar.gzARCHLINUX=ArchLinuxARM-am33x-latest.tar.gzWORKINGDIR=.BOOTDEV=/dev/$DEVICECHOICE'1'BOOTTMP=$WORKINGDIR/bootROOTDEV=/dev/$DEVICECHOICE'2'ROOTTMP=$WORKINGDIR/rootBOOTIMAGE=$ROOTTMP/boot/zImageBBBSCRIPT=/home/public/bbb-make-emmc-arch.sh
mkfs.vfat -F 16 -n "bootloader" $BOOTDEVsleep 1mkfs.ext4 -L "rootfs" $ROOTDEVsleep 1
mkdir $BOOTTMPmkdir $ROOTTMPmount $BOOTDEV $BOOTTMPmount $ROOTDEV $ROOTTMP
wget http://archlinuxarm.org/os/omap/$BOOTLOADER -O $WORKINGDIR/$BOOTLOADERsleep 1wget http://archlinuxarm.org/os/$ARCHLINUX -O $WORKINGDIR/$ARCHLINUXsleep 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 $ROOTTMPfi
echo "Copying Boot Image"cp $BOOTIMAGE $BOOTTMP
echo "Copying" $BBBSCRIPT "script to /"cp $BBBSCRIPT /
echo "Synching"sync
umount $BOOTTMPumount $ROOTTMPrmdir $BOOTTMPrmdir $ROOTTMP
clearecho "Upload Complete"echowhile truedo 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.";; esacdone# 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.gzARCHLINUX=ArchLinuxARM-am33x-latest.tar.gzWORKINGDIR=/tmpBOOTDEV=/dev/mmcblk1p1BOOTTMP=$WORKINGDIR/bootROOTDEV=/dev/mmcblk1p2ROOTTMP=$WORKINGDIR/rootBOOTIMAGE=$ROOTTMP/boot/zImage
clearwhile truedo 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.";; esacdone
mkfs.vfat -F 16 -n "bootloader" $BOOTDEVsleep 1mkfs.ext4 -L "rootfs" $ROOTDEVsleep 1
mkdir $BOOTTMPmkdir $ROOTTMPmount $BOOTDEV $BOOTTMPmount $ROOTDEV $ROOTTMP
wget http://archlinuxarm.org/os/omap/$BOOTLOADER -O $WORKINGDIR/$BOOTLOADERsleep 1wget http://archlinuxarm.org/os/$ARCHLINUX -O $WORKINGDIR/$ARCHLINUXsleep 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 $ROOTTMPfi
echo "Copying Boot Image"cp $BOOTIMAGE $BOOTTMP
echo "Synching"sync
umount $BOOTTMPumount $ROOTTMPrmdir $BOOTTMPrmdir $ROOTTMP
clearwhile truedo 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.";; esacdone