You can rely on a desktop or file manager for the automounting of external USB disk but the problem is that it can be mounted in a different path (example, /media/1TB vs. /media/1TB_ ) therefor it seam wise to use the /etc/fstab for this purpose. But there is another problem, Linux system not always identifies a resource to the same device, I mean, an external USB disk can be associated to /dev/sdb1 today and tomorrow be assinged to /dev/sdc1. How to solve the problem in the /etc/fstab? Answer: Using a unique string called UUID (Universally Unique Identifier) which uniquely identifies the device.
The blkid command
In order to get the UUID’s of block devices, just use the blkid command:
root@moody:~# blkid /dev/sdb1: LABEL="350GB" UUID="AB64-3A17" TYPE="vfat" /dev/sdb2: LABEL="1TB" UUID="dbd6b68d-a690-4a77-a404-7b8880e938e0" TYPE="ext4" /dev/sda1: UUID="MfYt3S-Vlzs-MInW-xGWU-j28o-ssJU-Uw029u" TYPE="LVM2_member" /dev/mapper/vg-rootfs: UUID="0393994a-75d4-4435-b3fd-2fda39ccd9b3" TYPE="ext4" /dev/mapper/vg-swap: UUID="cd790b68-44ca-4f21-8596-850c32b54487" TYPE="swap" /dev/mapper/vg-home: UUID="83aa02aa-a68a-4536-8094-382a172d80df" TYPE="ext4"
Let’s take the second line as example. It says that the currently device currently associated to /dev/sdb2 has n UUID of “dbd6b68d-a690-4a77-a404-7b8880e938e0″, has “1TB” as tag and uses ext4 as file system. With all this information you can edit the /etc/fstab as follow:
# proc /proc proc defaults 0 0 /dev/mapper/vg-rootfs / ext4 errors=remount-ro 0 1 /dev/mapper/vg-home /home ext4 defaults 0 2 /dev/mapper/vg-swap none swap sw 0 0 /dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0 UUID="dbd6b68d-a690-4a77-a404-7b8880e938e0" /media/1TB ext4 defaults,users 0 0
Keep in mind the mount point must exist, i.e. folder /media/1TB. In order to try the above entry just mount it from a terminal or check it when the PC reboots, it it will be mounted automatically.
- man fstab
- Universally unique identifier