Getting Started with Python for the Internet of Things
上QQ阅读APP看书,第一时间看更新

Accessing the RECOVERY/BOOT partition

Windows and macOS X do not support the ext4 format, so when you read the SD card, only the File Allocation Table (FAT) partitions will be accessible. In addition, Windows only supports the first partition on an SD card, so if you've installed NOOBS, only the RECOVERY partition will be visible. If you've written your card manually, you will be able to access the BOOT partition.

The data partition (if you installed one via NOOBS) and the root partition are in ext4 format and won't usually be visible on non-Linux systems.

If you do need to read files from the SD card using Windows, a freeware program, Linux Reader (available at www.diskinternals.com/linux-reader) can provide read-only access to all of the partitions on the SD card.

Access the partitions from Raspberry Pi. To view the currently mounted partitions, use df, as shown in the following screenshot:

The result of the df command

To access the BOOT partition from within Raspbian, use the following command:

cd /boot/  

To access the RECOVERY or data partition, we have to mount it by performing the
following steps:

  1. Determine the name of the partition as the system refers to it by listing all the partitions, even the unmounted ones. The sudo fdisk -l command lists the partitions, as shown in the following screenshot:
NOOBS installation and data partition

The following table shows the names of partitions and their meanings

 

If you have installed additional operating systems on the same card, the partition identifiers shown in the preceding table will be different.

  1. Create a folder and set it as the mount point for the partition; for the RECOVERY partition, use the following command:
mkdir ~/recovery
sudo mount -t vfat /dev/mmcblk0p1 ~/recovery  

To ensure that they are mounted each time the system is started, perform the following steps:

  1. Add the sudo mount commands to /etc/rc.local before exit 0. If you have a different username, you will need to change pi to match:
sudo nano /etc/rc.local
sudo mount -t vfat /dev/mmcblk0p1 /home/pi/recovery  
  1. Save and exit by pressing Ctrl + X, Y, and Enter.
Commands added to /etc/rc.local will be run for any user who logs on to Raspberry Pi. If you only want the drive to be mounted for the current user, the commands can be added to .bash_profile instead.

If you have to install additional operating systems on the same card, the partition identifiers shown here will be different.