Accessing a USB drive
To access data on a USB drive or SD card connected to Bela, the usual Linux way will work. Bela units that use a BeagleBone Black or Green, have an internal memory (eMMC) as well as support for an SD card. Bela and CTAG starter kits ship without an SD card, with the operating system stored in the eMMC. In this case, you can use an SD card for additional storage.
In case you want the SD card to be accessible from your computer’s operating system, as well as from Bela, you will have to format it to a filesystem that can be understood by both. If you have a Linux computer, then
ext4 will be the best choice. If you have Windows you may go for
FAT32. If you have macos, then you should probably use
FAT32 (unless you have special drivers installed that allow for R/W access to
ext4 partitions). These operations can be performed from the host computer using OS-specific tools (e.g.:
Disk Utility on macos,
sfdisk on Linux, and something else on Windows).
Below you will find step-by-step instructions. You will need to access the board’s command prompt through an
ssh client in order to perform some commands and edit some of the files on the board.
Warning: if you corrupt the file
/etc/fstab, and you are running a version of the Bela image <= v0.3.6b, then the board may stop showing up as a network interface. Make sure you have an alternative means to access the board, and/or backup your project files before you start the process below.
Note: Bela images <= v0.3.7x will require that the SD card is inserted when the board is powered on in order to be able to access it (hotplugging is disabled).
So, here we go:
- bring up a terminal emulator and
sshonto the board:
ssh firstname.lastname@example.org, depending on your OS and the version of the board you are running. See here for more details
- find out in
/dev/where your USB drive or SD cards are. The SD card will 99.9% of the times be
/dev/mmcblk0, and a USB drive will be in
/dev/sda. Anyhow, running
ls /devwith or without the USB drive/SD card and looking at the diff between the two should help, e.g.:
$ ls /dev > without # run this without the USB drive/SD card $ ls /dev > with # run this with the USB drive/SD card(requires reboot for SD card) $ diff without with 5a6 > bsg 82a84,86 > sda > sda1 > sg0
In this case
/dev/sdais the device, and
/dev/sda1is the first (and only) partition. It also shows up in
/dev/disk/by-id/usb-VendorCo_ProductCode_9207045B73296734835-0\:0-part1. You can use either, the former will be more generic and work for any USB drive that shows up as
/dev/sda1; the latter will be more specific and bound to the exact USB drive you have plugged in. Depending on your needs, you may decide to use one or the other. In the instructions that follow, I use
/dev/sda1for the device and
/mnt/usbas the mount point. Feel free to amend them according to your specific case.
- mount it manually and make sure it works:
mkdir -p /mnt/usb # create the mount point, only needed once. mount /dev/sda1 /mnt/usb ls /mnt/usb
this should show you the files on the USB drives
- save the configuration so that it mounts automatically, on boot or on hotplug: edit
nano /etc/fstaband add the following line to it
/dev/sda1 /mnt/usb auto defaults,nofail 0 2
then save and exit (ctrl-x, y, enter). The explanation for the fields, and more options are available by typing
man fstabon the board (or here).
- make sure everything is fine with
/etc/fstab: corrupting that file may cause problems at reboot. Some tests you could do before rebooting:
umount /mnt/usb mount /mnt/usb # this is shorter than previously, because the remaining information is picked from /etc/fstab ls /mnt/usb
note that at this point plugging/unplugging the USB drive will not automount it yet (it requires a reboot), and SD card hotplugging is disabled for some Bela images, as noted above.
- if all works fine, do a graceful
reboot. Upon reboot, the USB drive/SD card should automatically mount to the specified mount point, either at boot, or any time you plug it in. Remember that in order to avoid data corruption it is always recommended to run
umount /mnt/usbbefore hot-unplugging (or just gracefully shutdown the system, and the OS will take care of that for you).