# parted
### Format external storage using `parted`
Adapted from [this article](https://www.tecmint.com/create-new-ext4-file-system-partition-in-linux/)
Find your drive. The rest assumes that it's located at `/dev/sda`
```bash
sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
```
Enter parted shell
```bash
parted /dev/sda
```
Create partition
```bash
(parted) mklabel gpt
(parted) mkpart primary ext4 0% 100%
(parted) print
(parted) quit
```
- `mklabel` Options are `gpt` or `msdos`, see [this article](https://www.wikiwand.com/en/GUID_Partition_Table) for a comparison. See `help mklabel`
- The above `mkpart` command creates a primary partition of format ext4 that takes up the entire drive. See `help mkpart`.
Format the new partition
```bash
sudo mkfs.ext4 /dev/sda
```
Mount the drive
```bash
# Create mountpoint
mkdir -p ~/data
sudo mount -t auto /dev/sda ~/data
# Check that it's mounted
df -hT
```
See [[fs#Automatically mount external drive at startup https www binarytides com ubuntu-automatically-mount-partition-startup|here]] for instructions on automatically mounting external drives at startup.