Skip to content

Instantly share code, notes, and snippets.

@darknessnerd
Created November 16, 2023 14:54
Show Gist options
  • Save darknessnerd/305b08c871119d40d5a8dfc2bb8e8658 to your computer and use it in GitHub Desktop.
Save darknessnerd/305b08c871119d40d5a8dfc2bb8e8658 to your computer and use it in GitHub Desktop.
How to format and mount a disk permanently using its's UUID.
Find the disk name
sudo lsblk
This will show you a list of disks. Usually the first disk is vda and bootable. The second disk will be vdb, third vdc etc.
vda will typically be split in to multiple partitions, e.g. vda1 (/boot) and vda2 (/).
The new disk will have no partitions and no mountpoint.
Format the new disk
sudo mkfs.ext4 /dev/vdX
Where X is the correct letter for the disk.
The output will include the UUID of the disk, you will need this later.
Mount the disk
sudo mkdir /archive
sudo mount /dev/vdX /archive
This is only temporary and the mount will be lost on reboot.
Add mount to fstab
Add to /etc/fstab:
UUID=XXXX-XXXX-XXXX-XXXX-XXXX /archive ext4 errors=remount-ro 0 1
You can find the UUID, if you didn't note it down earlier, with sudo blkid.
@darknessnerd
Copy link
Author

How to format and mount a disk permanently using its's UUID.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment