Operation Manual
Enter to accept this.
6. The next prompt will ask you how big the partition should be, in megabytes (MB). The default is to create a partition that
fills the entire available free space on the device, so again, just press Enter.
7. Next, the new details—known as a partition table—need to be written to the disk. Use the cursor keys to move the option
selection highlight to Write and press Enter.
8. You will be prompted to make sure that the changes are correct. Double-check that you’ve created the partition as
instructed, and then type yes and press Enter.
9. Exit cfdisk by moving the option selection highlight at the bottom of the screen to Quit with the cursor keys and then
pressing Enter.
Although the partition table has now been updated with the freshly created partition, it won’t be visible to the operating system
until it has been reloaded. The easiest way to achieve that is to restart the Pi by typing the following:
sudo reboot
When the Pi has restarted and you’ve logged back in, you can use fdisk to verify that the new partition is ready for use with the
following command:
sudo fdisk -l
Before you can store files on the new partition, however, you need to put a file system in place by formatting the drive using the
mkfs tool as follows.
1. Type fdisk -l to list the storage devices connected to the Pi and their current partitions. Note the new partition, which
will appear as /dev/mmcblk0pN where N is the partition number. If you’re doing this on the recommended Debian
distribution, the partition will be /dev/mmcblk0p3.
2. Create a new EXT4 file system in the partition by typing sudo mkfs.ext4 /dev/mmcblk0pN, replacing N with the new
partition’s number. Make sure that you’ve picked the right partition: the mkfs (make file system) command will wipe any data
on the partition it is told to format.
3. Before the new file system can be used, it must be mounted. Create a mount point (an empty directory) by typing sudo
mkdir /storage at the terminal.
4. Use the mount command to make the new partition accessible on the mount point you just created by typing sudo mount
/dev/mmcblk0pN /storage, where N is the new partition number.
When using mkfs to create a new, blank file system on a partition, always double-check the partition details before continuing. If you give mkfs the
wrong partition, it will erase any files you have stored there. If it’s the /boot or root file system that has been wiped, the Pi will no longer load until
you flash the SD card again.
While this gives you a storage device that the root superuser can access, the pi standard user and any user accounts you’ve
created yourself don’t currently have permission to store files there. That can be changed with a trio of commands: chown,
chgrp and chmod.
The first command, chown, is short for change ownership and allows files created by one user to be passed across to another;
chgrp changes the group to which a file belongs so all the members of that group can access it; and chmod modifies the
permissions on a file or directory.
To allow all users to access your new partition, change the group membership from root to users with the chgrp command,
using the -R (recursive) flag to affect the directory’s entire contents as follows:
sudo chgrp -R users /storage
You’ll also need to allow all members of the group to write to the directory. To do this, you use the chmod command with the
option g+w, which tells chmod to allow write access from the group:
sudo chmod -R g+w /storage
The new partition is now ready for use, but there’s still one more task to carry out. At present, the partition needs to be manually
mounted (using the mount command combined with the sudo command for running as the root user) each time the Pi reboots.
To save time, you can tell the Pi to automatically mount the new partition instead by editing the fstab file.
Short for file system table, the fstab file—located in the /etc directory—tells Linux what file systems should be mounted on