Mounting An External Drive On Ubuntu Server
https://help.ubuntu.com/community/Mount/USB
1. Get device info:
$ lsblkor
$ sudo fdisk -l2. Create the Mount Point
In the example below, the mount point name is “external”. You can name it anything you want.
$ sudo mkdir /media/externalfor devices formatted in FAT16 or FAT32:
$ sudo mount /dev/sdb1 /media/externalfor devices formatted in ntfs:
$ sudo mount -t ntfs-3g /dev/sdb1 /media/external3. Unmounting the Drive
When you are finished with the device, don’t forget to unmount the drive before disconnecting it. Assuming /dev/sdb1 is mounted at /media/external, you can either unmount using the device or the mount point:
$ sudo umount /dev/sdb1or:
$ sudo umount /media/externalAutomount a Drive
https://askubuntu.com/questions/783061/automount-in-16-04
First get device info:
$ lsblkNote the device id of the disk to be mounted, for example ‘sda1’. Then we need the UUID of the disk to be mounted, find it with the code below replacing sdXX with the correct device id from the previous step:
$ blkid /dev/sdXXThe UUID looks like this:
40e554eb-6421-4813-88ea-3882a3a7a153Now open this file:
$ sudo nano /etc/fstabNow add this line to the end, changning the UUID for yours and /mnt/Disk should be changed to where you want to mount the disk:
UUID=40e554eb-6421-4813-88ea-3882a3a7a153 /mnt/Disk auto nosuid,nodev,nofail,x-gvfs-show 0 0Ctrl+X, then ‘Y’ to save and exit.
To mount a usb drive
To get the device info:
$ lsblkLocate the drive info(e.g. sdc2, sdb1, etc) and substitute this into ‘sdXN’ below
$ cd /media
$ sudo mkdir newdrive
$ sudo mount -t ntfs-3g /dev/sdXN /media/newdriveThe last line above is for an ntfs formatted drive. For any other drive, try:
http://askubuntu.com/questions/773406/how-do-i-mount-and-open-flash-drive
$ mount /dev/sdXN /media/newdriveif you try the code below on an ntfs formatted drive, you will get the error:
ntfs-3g-mount: bad mount point media/reddrive: No such file or directoryThe Importance of Unmounting
Before disconnecting devices, you must unmount them first. This is similar to “Safely Remove” in Windows in that the device won’t unmount until data is finished being written to the device, or until other programs are finished using it. This applies to all types of storage devices, including flash drives, flash cards, external hard drives, ipods and other media players, and even remote storage like Samba or NFS shares.
Failure to unmount before disconnecting the device can result in loss of data and/or a corrupted file system. There are no exceptions to this rule. Be safe – unmount your drives before disconnecting them!
ERRORS & SOLUTIONS
If you are trying to unmount a drive ( or USB drive) and are seeing the error:
$ sudo umount /media/yourdrive
umount: /media/thedrive: target is busy
(In some cases useful info about processes that
use the device is found by lsof(8) or fuser(1).)Do this to kill the busy processes and unmount the drive (substitute sdXN with the correct drive info:
$ sudo fuser -kim /dev/sdXNThe output will show runing processes, example:
/dev/sdXN: 8933 9628c
Kill process 8933 ? (y/N) yPress ‘y’ to kill the process and do the same for the next prompt, then:
$ sudo umount dev/sdXNor:
$ sudo /media/yourdrivenameThe code below is for mounting a device using a GUI.
The link below is used for the guide below, although it does not work when using ‘gksudo gedit …’ (presumably do to no display)
https://help.ubuntu.com/community/MountingWindowsPartitions
More info on fstab and mounting
https://help.ubuntu.com/community/Fstab
First, you need to find the device locations of the partition(s) you wish to mount. Open a terminal and run:
$ sudo blkidFor illustration purposes, an example output from a computer setup with a Vista/Ubuntu dual-boot and shared NTFS data partition is shown here:
/dev/sda1: LABEL="Recovery" UUID="B23613F43613B875" TYPE="ntfs"
/dev/sda2: LABEL="Windows" UUID="38CE9483CE943AD8" TYPE="ntfs"
/dev/sda3: LABEL="Data" UUID="519CB82E5888AD0F" TYPE="ntfs"
/dev/sda5: UUID="00d7d951-2a35-40fd-8e5d-411bb824ff3b" TYPE="swap"
/dev/sda6: LABEL="Ubuntu" UUID="6044b1d0-208e-4ab3-850d-03a92e1516fc" TYPE="ext4" The first three partitions, all NTFS, are the ones that concern us here. There are no FAT32 partitions. In this instance, all three NTFS partitions have partition labels, which makes it easier to identify the purpose of each. If your blkid output does not include partition labels, this means that the partitions do not have labels and you will have to determine which partition you wish to mount by another means. Of the three NTFS partitions, we are going to configure /etc/fstab with only the third, the Data partition. Partition /dev/sda1 is the OEM manufacturer’s recovery partition and should be left unmounted, or as described below. Partition /dev/sda2 is the Windows C: partition and is best not included in /etc/fstab for the reasons described above, or mounted read-only – see below.
You will now need to create a mountpoint for each NTFS partition that you wish to mount by means of /etc/fstab. In our illustration we are going to add one entry only for /dev/sda3. From a terminal:
$ sudo mkdir /media/DataIn this case we have created a mountpoint with the same name – Data – as the partition label. You may use (almost) any string you wish. Also note that in the example below ‘sda3’ is the
$ sudo mount -t ntfs-3g /dev/sda3 /media/DataBelow is the rest of the code used in the first link above that should only be used with a GUI:
https://help.ubuntu.com/community/MountingWindowsPartitions
…
Before editing /etc/fstab directly, it is a good idea to make a backup. From a terminal:
$ sudo cp /etc/fstab /etc/fstab.origNow open /etc/fstab in a text editor with root privileges:
$ gksudo gedit /etc/fstabIf you see the output below,
The program 'gksudo' is currently not installed. You can install it by typing:
sudo apt install gksutype:
$ sudo apt install gksuand again,
$ gksudo gedit /etc/fstabERROR
$ (gksudo:4578): Gtk-WARNING **: cannot open display:Will need to find a solution before continuing. Seems that this process for mounting is for use with gui.
GKSu is a library that provides a Gtk+ frontend to su and sudo. It supports login shells and preserving environment when acting as a su frontend. It is useful to menu items or other graphical programs that need to ask a user’s password to run another program as another user.
http://www.nongnu.org/gksu/
Uninstall gksu:
https://www.devmanuals.net/install/ubuntu/ubuntu-16-04-LTS-Xenial-Xerus/how-to-install-gksu.html
$ sudo apt-get remove gksu
$ sudo apt-get remove --auto-remove gksu
$ sudo apt-get purge gksuFor a general-purpose read-write mount, add this line to the end of /etc/fstab:
UUID=519CB82E5888AD0F /media/Data ntfs-3g defaults,windows_names,locale=en_US.utf8 0 0Replace the UUID with the one relevant for your partition as shown in your blkid output. “519CB82E5888AD0F” will not work for you.
Also, substitute your mountpoint for “/media/Data”. In case you have a blank space in the name of the mountpoint you want to use like “New Volume” instead of “Data” located in “/media” use “/media/New 40Volume”. The space character is created by using “