Mounting external drives
To list all drives run:
Mount and unmount external drives
One common need is to mount an external drive, be it an external hard drive, USB stick, or an external SSD.
Create a new mount point, and mount the drive there:
To unmount:
Add a new internal drive
1) List all drives:
This will output something like this:
nvme0n1 259:0 0 953.9G 0 disk
nvme1n1 259:1 0 931.5G 0 disk
├─nvme1n1p1 259:2 0 1G 0 part /boot/efi
├─nvme1n1p2 259:3 0 2G 0 part /boot
└─nvme1n1p3 259:4 0 928.5G 0 part
└─ubuntu--vg-ubuntu--lv 252:0 0 928.5G 0 lvm /
In the above we can see nvme1n1 is partition and mounted at /. Another new drive has been added but is still unpartitioned and unmounted.
2) If the disk is raw/unpartitioned, we need to partition the new drive:
Inside fdisk:
- n to create new partition
- p to set as primary
- Accept defaults for full disk
- w to write changes
After this, you should see /dev/nvme0n1p1.
3) Format the partition for ext4 (most common case):
Take note of the UUID. We will need it later.
4) Create a mount point for the new drive:
5) Mount the drive (temporarily):
You can verify with:
6) Get the UUID (required for permanent mount):
It will be something like UUID="e3b1c9a4-8c5d-4b8d-a9b2-123456789abc".
7) Mount automatically at boot using fstab:
Add this line and replace UUID and path:
To test fstab:
If no errors, it will mount correctly at boot.