How to Mount Drives on Linux: Command Line & GUI
How to Mount Drives on Linux: Command Line & GUI
If you've connected a new SSD, HDD, or other external or internal disk type to your Linux system, you'll need to mount the drive to access its files. To mount a drive on Linux, you'll need to find the default name of the drive (e.g., /dev/sdc), create a directory for your mount point, and then use the "mount" command to mount that default drive name to the new directory. If you're using Ubuntu, you can also use the Disks utility to mount and unmount drives. Mounting a drive in Linux is simple, and this wikiHow will show you two ways to get the job done.
Things You Should Know
  • Use the command "lsblk -lf" to find the new drive's name (e.g., sdb or sdc).
  • Create a new directory for your new mount point. For example, sudo mkdir /media/myflashdrive.
  • To mount the drive to the directory, use the syntax mount /dev/<drivename> </new/directory>.

Using the Mount Command

Open a Terminal window. If you want to mount an internal or external drive in Linux, you can do so easily from the command line. You can open a terminal on most Linux distributions by pressing Ctrl + Alt + T.

Run the lsblk -lf command to find the path to the drive. When you run this command, you'll see an entry for each drive that's connected to your system—including any internal drives. Make note of the new drive's "NAME" column value (e.g., sdc or sdc1) and the file system type (e.g., ext4, vfat). If the drive is already mounted, you will see a path under "MOUNTPOINTS." You can use cd to enter that directory to access the files on the drive.

Create a new directory for the mount point. For example, use sudo mkdir /media/myflashdrive to create a directory called myflashdrive in /media.

Use mount to mount the drive to the new directory. The syntax is mount /dev/drivename . For example, if the drive is /dev/sdc1 and you want to mount the drive at /media/myflashdrive, use sudo mount /dev/sdc1 /media/myflashdrive.

Mount the drive permanently (optional). If you don't want to have to mount the drive every time you sign into Linux, you can add an entry for it to /etc/fstab so it mounts automatically. This will be helpful if you've installed a new internal drive. Don't do this for removable drives—if the drive isn't connected at boot time, your system will not boot at all. Open /etc/fstab in a text editor like Vim or Nano. Add a line to the file using this syntax: /dev/sdc1 /media/myflashdrive ext4 defaults 0 0 Replace "ext4" with the file system type you found with lsblk -lf earlier. Save and exit the file.

Unmount a drive with umount. To unmount the drive, just run the command sudo umount /media/myflashdrive.

Using Ubuntu Disks Utility

Open the Disks utility in Ubuntu. If you're running Ubuntu and want to use a graphical option to mount a drive, the Disks utility makes it easy. Just go to the Activities overview, type disks, and click Disks in the search results.

Select the new drive in the left panel. Details about the drive will appear.

Click the Play button to mount the drive. If the drive is not mounted, you'll see a Play button (a sideways triangle). Clicking it will mount the drive. If the drive is already mounted, you'll see a Stop button (a square).

Click the gear icon and select Edit Mount Options…. This displays a window with several customization options.

Choose your mounting preferences. If you want this drive to mount automatically each time Ubuntu boots up, check the box next to "Mount at system startup." Keep in mind that you shouldn’t do this for a flash drive or SD card, as your system may not boot if the drive is not connected. If you want to be able to access this drive in your file manager and other GUI apps, check the box next to "Show in user interface." To change the mount point to something that's easier to remember and type, you can edit the mount point. Just make sure you're entering a directory that already exists (e.g., if you want to mount the drive at /mnt/media/mydrive, you will need to sudo mkdir /mnt/media/mydrive before entering that path. Click OK when you're finished.

To unmount a drive, select it, then click the Stop button. It's the square to the left of the gear button. This unmounts the drive.

What's your reaction?

Comments

https://ugara.net/assets/images/user-avatar-s.jpg

0 comment

Write the first comment for this!