Here's a concise guide on how to format a drive as ext4 and mount it using UUID on a Debian system:
1. Identify the Drive
First, identify the drive you want to format. You can use the lsblk command:
lsblk
2. Format the Drive as ext4
Assuming your drive is /dev/sdX (replace X with the appropriate letter), format it as ext4:
sudo mkfs.ext4 /dev/sdX
3. Get the UUID of the Drive
Retrieve the UUID of the newly formatted drive:
sudo blkid /dev/sdX
Note the UUID, which will look something like UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".
4. Create a Mount Point
Create a directory where you want to mount the drive. For example:
sudo mkdir /mnt/mydrive
5. Edit the fstab File
Open the /etc/fstab file in a text editor:
sudo nano /etc/fstab
Add the following line at the end of the file, replacing xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx with the actual UUID and /mnt/mydrive with your desired mount point:
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /mnt/mydrive ext4 defaults 0 2
6. Mount the Drive
Mount all filesystems mentioned in /etc/fstab to apply the new configuration:
sudo mount -a
7. Verify the Mount
Check that the drive is mounted correctly:
df -h
You should see the drive listed with the mount point you specified.
That's it! You've successfully formatted the drive as ext4 and mounted it using its UUID.
