Linux Mount Disk

Aug 10, 2020
mount -t ext4 /dev/sdb /data

NOTE: Unmount - umount /dev/sdb or umount /data

NOTE: List all mountable drive - lsblk -o KNAME,TYPE,SIZE,MODEL

Setup Automount on Startup

Run blkid to get UUID of disk

/dev/sr0: UUID="2020-07-10-21-22-25-53" LABEL="VBox_GAs_6.1.12" TYPE="iso9660"
/dev/sda1: UUID="259c0e9f-c45a-4579-8b4b-ad5a86645607" TYPE="ext4" PARTUUID="75bed932-01"
/dev/sdb1: LABEL="code" UUID="0e36bdcf-377c-4a3d-b54c-3639af0766f8" TYPE="ext4" PARTUUID="0008b13e-01"
/dev/sdc1: LABEL="data" UUID="a055c10a-5028-4c38-a8f7-621b7139cd2f" TYPE="ext4" PARTUUID="00097481-01"

Make a mount point

sudo mkdir /mnt/sdb1

Edit /etc/fstab

nano /etc/fstab

Add the following line

UUID=0e36bdcf-377c-4a3d-b54c-3639af0766f8  /mnt/sdb1  ext4  defaults  0  2

Format is <file system> <mount point> <type> <options> <dump> <pass

  • defaults mount option allow read and write access
  • dump is usually zero
  • pass is used by fsck to determine the order of filesystem check. Root partion should be 1, swap should be 0 and other drive should be 2
# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=259c0e9f-c45a-4579-8b4b-ad5a86645607 /              ext4    defaults,discard 0 1
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.