An additional utility that is not described in Chapter 3 is the tree program. It allows you to obtain a visual display of the directory tree using only the Linux terminal. The command is not installed by default, so begin with:
molloyd@beaglebone:~/$ sudo apt-get install tree
Once the tree program is installed, you can test it on a directory of your choice, for example:
molloyd@beaglebone:~$ cd exploringBB/
License.txt chp02 chp05 chp08 chp10 chp12 extras
README.md chp03 chp06 chp09 chp11 chp13 library
molloyd@beaglebone:~/exploringBB$ tree library
| |-- BusDevice.cpp
| |-- BusDevice.h
| |-- I2CDevice.cpp
| |-- I2CDevice.h
| |-- SPIDevice.cpp
| `-- SPIDevice.h
| |-- LCDCharacterDisplay.cpp
| |-- LCDCharacterDisplay.h
| |-- SevenSegmentDisplay.cpp
| `-- SevenSegmentDisplay.h
| |-- GPIO.cpp
| |-- GPIO.h
| |-- PWM.cpp
| |-- PWM.h
| |-- util.cpp
| `-- util.h
| |-- DCMotor.cpp
| |-- DCMotor.h
| |-- Servo.cpp
| |-- Servo.h
| |-- StepperMotor.cpp
| `-- StepperMotor.h
| |-- SocketClient.cpp
| |-- SocketClient.h
| |-- SocketServer.cpp
| `-- SocketServer.h
6 directories, 35 files
You can also use options (use man tree to see the full list) such as: -a display all files including hidden files, -l follows symbolic links, -u displays the owner, -C turns on colorization, -L 2 displays only the first two levels, and -d displays only directories. So, for example:
molloyd@beaglebone:~$ tree -dL 1 ~/exploringBB/
displays only the first level of directories in the exploringBB directory.
Mounting the SD Card Automatically
In the Example, Mount an SD card as additional storage on the BBB
, there is one final step that is alluded to but not discussed in the book as it is a very specific usage. This step ensures that the SD card is mounted automatically when the BBB is booted, and is as follows:
Step 5: If you want the SD card to be automatically mounted when the BBB is booted, you could add an entry to the file /etc/fstab. In theory you should be able to add the entry as follows, using nano:
/dev/mmcblk1p1 /media/store ext4 defaults,nofail,user,auto 0 0
However, the /dev/mmcblk1p1 can change to /dev/mmcblk0p1 when you reboot the BBB (depending on whether the card is present or not). Therefore, you have to mount the device using its UUID (universally unique identifier). Find the UUID by typing blkid (or ls -l /dev/disk/by-uuid/):
root@beaglebone:/# blkid /dev/mmcblk1p1
Highlight the UUID by using the left mouse button at the beginning and use the middle-mouse button at the end to copy. Type nano /etc/fstab, and when you get to the bottom of the file, right-click the mouse button to paste the text into the editor. The entry in the /etc/fstab file should look like (where the last two lines are all on the same line, i.e. two spaces after ext4 then defaults)─be very careful or your BBB may not reboot properly:
root@beaglebone:/etc# more /etc/fstab
# /etc/fstab: static file system information.
UUID=964f0ed7-dcbd-49f2-862e-3f40bff88186 /media/store ext4 defaults,nofail,user,auto 0 0
The SD card is mounted with that UUID at the mount point /media/store. It is an ext4 file system. The options are as follows:
- defaults: Use default settings
- nofail: Mount the device when present but ignore if it is absent
- user: The user gives permissions to mount the file system
- auto: The card will be mounted on start-up, or if the user types mount -a
The 0 0 values are the dump frequency (archive schedule) and pass number (order for fsck at boot) and should be these values by default.
On reboot you can do the following:
root@beaglebone:/# cd /media/store/
Regardless if the SD card is absent or present, the BBB will boot perfectly.
VirtualBox: Installing a Linux Guest Under a Windows Host
Here are some tips on installing a Linux guest VirtualBox VM under a Windows host:
- Enable VT-x/AMD-V in the system BIOS settings of your physical computer in order to run a 64-bit guest OS.
- Install VirtualBox (virtualbox.org) on your host OS.
- Download your favourite Linux distribution as an ISO file. In this book 64-bit Debian is used. Download the Net debian-jessie-DI-rc1-amd64-netinst.iso or equivalent from the page www.debian.org/releases/. Do not use the ia64 branch unless you are using a high-end Itanium-based server. Important: see note at the top of the page about Debian Wheezy.
- Start Oracle VM VirtualBox Manager and choose New. If available, give the installation 2GB+ memory. Create a virtual hard drive (VDI format, dynamic allocated) and make the size much greater than the 8GB it recommends. Choose the location on your computer to store the disk and use a minimum of 25–30GB! It is difficult to resize a disk after the fact. If you choose “dynamically allocated”, it will only occupy real disk space when you fill the Linux disk, so feel free to choose a large disk size.
- You now have a new VM that is powered off. Select it and click on settings. Under storage you should see your VDI (under SATA) and an “Empty” entry (under IDE). Select the “Empty” entry and click the disk icon under Attributes. Find and select the Linux ISO file that you downloaded, as shown in the figure below.
Figure 2-A1: The VirtualBox VM configuration pane
- Start your VM and install Linux by booting off the virtual drive. If you see a message “No Boot Device,” go to Settings System and disable the floppy drive.
- Once your guest OS is running, choose Devices Install Guest Additions from the menu bar of your VirtualBox window. If all goes well, you will now be able to resize the window and cut-and-paste text between the host and guest OSs (by enabling Devices ⇒ Shared ⇒ Clipboard Bidirectional).
- Choose “Devices”->”Insert Guest Additions CD image…”
- If the guest additions do not install automatically, follow these steps (for Debian desktop — tested on Wheezy and Jessie images) in a terminal window:
molloyd@debian:~$ su -
root@debian:~# apt-get update
root@debian:~# apt-get install build-essential module-assistant
root@debian:~# m-a prepare
root@debian:~# cd /media/cdrom
root@debian:~# sh ./VBoxLinuxAdditions.run
- With your network settings set as NAT on Adapter 1 (default setting) you should now be able to ping 192.168.7.2 (your BBB when using Internet-over-USB), or its equivalent network IP address (if connected by regular Ethernet).
If you go to the VirtualBox System ⇒ Processor settings, you will see the number of cores that can be allocated to the guest OS. On an Intel i7 processor you will see either 16 or 24 as the upper limit, depending on your exact processor. On a 4-core processor, you will see one core per thread, so 8 “real” cores, and you will also see that number again in “virtual” cores. Do not use virtual cores, as they will be provided through time slicing and your machine may slow down considerably. The maximum number of cores you should allocate to your guest OS is the total number of real cores minus one.
Useful tools – Cairo Dock
The latest windowing interface for Debian Jessie contains some very nice features, but it is quite lean. One tool that is useful and will be familiar to Mac OS X users is the Cairo Dock. It is illustrated in Figure 2-A2 below. You can install it using the following step:
molloyd@DebianJessieVM:~$ sudo apt-get install cairo-dock
: The Cairo Dock in action under Debian 8 (Jessie)
Debian 8 Jessie uses Gnome 3. To start up this dock automatically on boot you can perform the following steps:
And then click “Startup Applications” on the left-hand menu. On the right-hand pane click on the “+” icon and add Cairo-Dock to the list.