Search This Blog

2024/04/16

Ubuntu:Mount NTFS External drive automatically everytime you connect

Suppose you installed ubuntu and and your external ntfs drive

is not getting mounted then you can make this work.Follow with
me.

lsblk -f | grep -v loop
Output:
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sda
├─sda1 vfat FAT32 A64D-0CAC 1.7G 5% /boot/efi
├─sda2 zfs_member 5000 bpool 2206374728107504537
├─sda3 swap 1 5b4027c6-88ce-4eba-9b6d-e51691a214f8 [SWAP]
└─sda4 zfs_member 5000 rpool 13454510986414546587
sdb
└─sdb1 ntfs Elements 16820B95820B788F
sr0

Here out external drive has UUID 16820B95820B788F

sudo blkid
Output:
/dev/sdb1: LABEL="Elements" BLOCK_SIZE="512" UUID="16820B95820B788F"
TYPE="ntfs" PARTLABEL="Elements"
PARTUUID="6a7aa07d-2fd5-4ba7-8151-9d78acd5f6f1"
/dev/sda4: LABEL="rpool" UUID="13454510986414546587"
UUID_SUB="13423234998976234406" BLOCK_SIZE="4096"
TYPE="zfs_member"
PARTUUID="8c30f2cf-8c0f-4f48-b7af-78393fc3b4a9"

/dev/sda2: LABEL="bpool" UUID="2206374728107504537"
UUID_SUB="1054495319606689002" BLOCK_SIZE="4096"
TYPE="zfs_member" PARTUUID="0d412e1a-5cf2-4d8a-a232-03bee67ea7c5"

/dev/sda3: UUID="5b4027c6-88ce-4eba-9b6d-e51691a214f8" TYPE="swap"
PARTUUID="cacbf9dd-e138-4be7-b0e2-99653d10151f"

/dev/sda1: UUID="A64D-0CAC" BLOCK_SIZE="512" TYPE="vfat"
PARTUUID="f2ffb0ca-e713-4c70-aae8-b15cabff4d37"

/dev/loop1: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/loop8: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/loop6: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/loop4: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/loop2: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/loop0: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/loop9: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/loop7: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/loop5: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/loop3: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/loop10: BLOCK_SIZE="131072" TYPE="squashfs"

Here our external drive has type ntfs.

Keep backup of fstab file before modification:
sudo cp /etc/fstab /etc/fstab.orig
Lets see existing content of /etc/fstab
cat /etc/fstab
Output:
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/disk/by-uuid/5b4027c6-88ce-4eba-9b6d-e51691a214f8 none swap sw 0 0
# Use `zfs list` for current zfs mount info
# bpool none defaults 0 0
# Use `zfs list` for current zfs mount info
# rpool none defaults 0 0
# Use `zfs list` for current zfs mount info
# rpool / defaults 0 0
# Use `zfs list` for current zfs mount info
# bpool /boot defaults 0 0
# /boot/efi was on /dev/sda1 during curtin installation
/dev/disk/by-uuid/A64D-0CAC /boot/efi vfat defaults 0 1

Now we need to add new entry based on following

# <file system> <mount point> <type> <options> <dump> <pass>
/dev/disk/by-uuid/5b4027c6-88ce-4eba-9b6d-e51691a214f8 none swap sw 0 0
Our Entry
/dev/disk/by-uuid/16820B95820B788F /home/sangram/Elements ntfs defaults 0 1
Add this line to the end of /etc/fstab
sudo nano /etc/fstab
after adding above line at end save.
Now to make changes take effetct run:
mount -a
systemctl daemon-reload

No comments:

Post a Comment