Join the Ben Heck team every week for amazing hacks! Watch them build and mod community-inspired projects using electronics!
|Featured Bonus Content|
|See All Episodes|
Partitioning a hard drive divides the available space into sections that can be accessed independently. You can allocate an entire drive to a single partition, or use multiple partitions for dual-booting, maintaining swap partition, or to logically separate data such as audio or video files. The partition table stores the required information. Felix gives an overview of two types of partition tables, Master Boot Record (MBR) and Globally Unique Identifier Partition Table (GBT). The first 512 Bytes of a storage device is dedicated to the Master Boot Record (MBR). This comes from an older partitioning scheme that is designed to work with the boot process of the bios. During the boot process the bios loads the beginning 512 Bytes of the first valid disk in the bios disk order. The Global Unique Intentifier Partition Table (GPT) is a partitioning scheme that is part of unified extensible firmware interface specification. It uses globally unique identifiers (GUIDS), UUIDS in the Linux world, to define partitions and partition types. It is designed to succeed the master boot record partitioning scheme method. GPT is recommended for systems that boot via a UEFI system.
Felix uses a Raspberry Pi and a (Tux the Linux Penguin) USB dongle to demonstrate how this works. He takes Tux and plugs him into the USB. He utilizes command line to locate where his device comes up in the device tree. He uses the command lsblk to shows there are no partitions set up and the device comes up as SDA. He points out mmcblk0 which is the device. He shows you what mounted partitions look like by pointing to mmcblk2, mmcblk7, mmcblk5, mmcblk1, and mmcblk6. He also shows you the device directory which he gets to by typing in ls /dev.
The utility for modifying partitions that Felix is going to uses is f disk and pulled from the following command:
$ sudo fdisk /dev/sda
He shows you how you can pull up the menu by typing m or pull up the partition table by typing p. To create a DOS partition table he types in n for new partition. He then goes over the commands for creating a new partition table for DOS, how to make it the primary table, and how to set the size of the partition. Felix then goes over the steps for creating another partition. He does another primary partition and prints the partition table again and demonstrates that a second partition has been added. You how to use command “l” to display all the known partition types. He chooses a Linux partition and uses w2 to write out the partition table. After verifying the partition exists, he goes over formatting the partition. He formats the partition using the mkfs utility:
$ sudo mkfs.ext4 /dev/sda1
Ext4 is a journalized file system which is pretty much the standard Linux filing system allocation table of writing super clocks and filesystem account information. sudo fdisk –l/dev/sda Once the partition is formatted he’s then able to make a directory and mount it in the system.
Do you have any questions or advice on partitioning storage on the Raspberry Pi?