Use your external hard drive formatted to Btrfs for your Raspberry Pi.
Select HDD
- Find your external HDD.
lsblk | grep -i "sd"
- Find the partition on external HDD.
sudo fdisk -l
- Enter fdisk for formatting by selecting your external HDD.
sudo fdisk /dev/sda
fdisk
- Delete partition.
d
- Create partition.
n
- Select partition number.
1
- Select the first sector instead of using the default 2048, since my external HDD has range of 34-976773134, I choose 34.
34
- Select the last sector. The default is the last sector, so just enter it.
- 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.
sudo mkfs.btrfs -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
/mnt
folder.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.