Use your external hard drive formatted to Btrfs for your Raspberry Pi.
Select HDD
- Find your external HDD. It mostly starts at
/dev/sd.sudo fdisk -l - Enter fdisk for formatting by selecting your external HDD. For this example, we choose
/dev/sda.sudo fdisk /dev/sda
fdisk
- Create a new empty GPT partition table.
g - Create partition.
n - Select partition number.
1 - Select the first sector. The default shown is best so that the partition is aligned properly, so just enter it.
- Select the last sector. The default shown is the last sector, so just enter it.
- When asked to remove the filesystem signature, enter yes.
y - Write changes to disk. This will delete all data on the external HDD.
w
Btrfs format
- Format external HDD to Btrfs with label Raspberry-Pi-HDD, label is there for easier mounting. Also use xxHash for checksumming.
sudo mkfs.btrfs --csum xxhash -L Raspberry-Pi-HDD /dev/sda1
You can change label at any time by using this command:sudo btrfs filesystem label /dev/sda1 Raspberry-Pi-HDD
Mounting
- Create a mount point on
/mntfolder.sudo mkdir /mnt/HDD - Mount external HDD.
sudo mount /dev/disk/by-label/Raspberry-Pi-HDD /mnt/HDD - Own the external HDD. By default, it is owned by root.
sudo chown -R $USER:$USER /mnt/HDD
Now every time you reboot your Raspberry Pi, you can mount it again using:sudo mount /dev/disk/by-label/Raspberry-Pi-HDD /mnt/HDD
fstab
For automatic mount upon reboot, add this line on your /etc/fstab by using sudo nano /etc/fstab. Be careful with this file as it can easily cause your system not to boot.
| |
Nofail so that system will not error if the external HDD is disconnected upon boot, and systemd.device-timeout so that system will not wait 90 seconds for the device to appear if disconnected, only 5 seconds.