Skip to content

Instantly share code, notes, and snippets.

@goddoe
Last active January 19, 2018 17:37
Show Gist options
  • Save goddoe/66cb7c035a3701e04237cb5ebe72e91b to your computer and use it in GitHub Desktop.
Save goddoe/66cb7c035a3701e04237cb5ebe72e91b to your computer and use it in GitHub Desktop.
How to mount or unmount disk at ubuntu
# 1. find disks
sudo fdisk -l
# Sample of fdisk result
# Disk /dev/sda: 3.7 TiB, 4000787030016 bytes, 7814037168 sectors
# Units: sectors of 1 * 512 = 512 bytes
# Sector size (logical/physical): 512 bytes / 512 bytes
# I/O size (minimum/optimal): 512 bytes / 512 bytes
# Disklabel type: gpt
# Disk identifier: 4E3CC7A4-C60A-4B48-AE49-BAF3D2FD3B67
#
# Device Start End Sectors Size Type
# /dev/sda1 2048 7814037134 7814035087 3.7T Linux filesystem <<<<<<
# ...
# 2. mount the disk
# reference : https://askubuntu.com/questions/143718/mount-you-must-specify-the-filesystem-type , reverendj1
# You need to add the -t FILESYSTEMTYPE argument to the command, replacing FILESYSTEMTYPE with your filesystem type. This specifies the filesystem type of the filesystem to be mounted. In your case, this would be /dev/sdb2. Some common, valid filesystem types are:
# auto - this is a special one. It will try to guess the fs type when you use this.
# ext4 - this is probably the most common Linux fs type of the last few years
# ext3 - this is the most common Linux fs type from a couple years back
# ntfs - this is the most common Windows fs type or larger external hard drives
# vfat - this is the most common fs type used for smaller external hard drives
# exfat - is also a file system option commonly found on USB flash drives and other external drives
mkdir /mnt/data_disk
sudo mount -t ext4 /dev/sdb1 /mnt/data_disk
# 3. unmount disk
sudo umount /dev/sdb1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment