Partition, format and mount a large harddrive to RPi 4 to available USB 3 port.
This drive will be used as a NAS for movies, pictures, data. There are lots of tutorials on how to do this. I will just run through the steps quickly.
- Raspberry Pi 4
- External harddrive
- Enclosure with its own power supply
- Attach drive. Insert HDD into enclosure; plug in drive into wall; plug in drive to USB 3.0 port (lower) on RPi4.
- Confirm connection. Use sudo fdisk -l to list drives. Your drive will likely show up at the bottom of the list.
- Partition the drive. Assuming the drive was attached at /dev/sdb, use parted /dev/sdb.
- Then mklabel gpt which is needed if drive is more than 2gb
- Then mkpart primary ext4 0 2.7tb [change size of drive, i.e., 2.7tb to whatever you have]
- Format the drive. Use: sudo mkfs.ext4 /dev/sdb1
- Create a mount location. Use sudo mkdir /mnt/hdd
- Mount the drive. Use sudo mount /dev/sdb1 /mnt/hdd
The drive is not mounted on your RPi if all went well. You can now type df -h and get a list of drives and you should see your newly mounted drive. However, to boot this drive automatically at startup, you will need the following.
Create Auto Mount.
sudo nano /boot/cmdline.txt
- Pi Hut, How to Mount an External Hard Drive, January 2015.
- Sik Ho Sang, Medium, Partitioning, Formatting and Mounting in Linux Ubunto, January 2020
- RaspberryPi.org, External Storage Configuration
- Answertopia, Adding a New Disk to an Ubuntu 20.04 System, June 2020
- StackExchange, Automounding USB Drive on Raspberry Pi