Project Wild Penguin 18.4.2017: Label Partitions and Automount on Startup

Label Partitions:

To label partitions on Linux based system from command line, follow the process given below:

Replace /dev/sdxN with your partition (e.g. /dev/sdc1).

  • for FAT32:
    sudo mlabel -i /dev/sdxN ::"my_label"
    
    or:
    sudo fatlabel /dev/sdxN my_label
    
  • for NTFS:
    sudo ntfslabel /dev/sdxN my_label
    
  • for exFAT:
    sudo exfatlabel /dev/sdxN my_label
    
  • for ext2/3/4:
    sudo e2label /dev/sdxN my_label
    
  • for BTRFS:
    sudo btrfs filesystem label /dev/sdxN my_label
    
To label them through GUI based app, you can use GParted tool.

Automount Partitions:


To automount partitions on startup, follow the process given below:

Fire up a terminal.
  1. [IMPORTANT] sudo cp /etc/fstab /etc/fstab.old - Create a backup of the fstab file just in case something unwanted happens.
  2. sudo blkid - Note the UUID of the partition you want to automount.
  3. sudo nano /etc/fstab - Copy the following line to the end of the file, save it and reboot afterwards to check if it worked.
UUID=<uuid> <pathtomount> <file system> uid=<userid>,gid=<groupid>,umask=0022,sync,auto,rw 0 0

Examples for the <> variables:
<uuid>=3087106951D2FA7E

<pathtomount>=/home/data/

<file system>=ntfs-3g (for an NTFS partition)

<userid>=1000

<groupid>=1000

Use id -u <username> to get the userid and id -g <username> to get the groupid.

(Note that specifying the sync option can slow down write performance as it disables the cache. async is the default.)

Screenshot of my computer's _fstab_ file

Sources:

  • https://askubuntu.com/questions/276911/how-to-rename-partitions
  • https://askubuntu.com/questions/164926/how-to-make-partitions-mount-at-startup-in-ubuntu-12-04

Comments

Popular posts from this blog

Project Wild Penguin 22.4.2017: To delete directories inside current directory whose contents are less than a given size

ANPR Project Day 1: Standard Format of Indian Number Plate

ANPR Day 5: User requirement Analysis