How to permanently mount a drive in Linux (and why you should) (2024)

How to permanently mount a drive in Linux (and why you should) (1)

I currently have four hard drives inside of my System76 Thelio desktop. The primary drive serves as my operating system and the others are strictly for housing different types of files. I have one drive for virtual machines, one for music, and one for miscellaneous files. By laying out my system this way, even if the operating system fails, my data is still accessible.

I have those secondary drives set up such that they are automatically available at all times. In the Linux-verse, this is called "automounting" and it's an important task you'll want to understand.

Automounting is a thing because when you have secondary drives attached to a machine, they aren't automatically available to you upon boot of the machine. Yes, you can open your desktop file manager, navigate to the drive, and mount it by clicking the entry. However, this can be problematic if you forget to do that and you either have a backup configured to automatically save files to that drive or you simply go to save a file to that drive from an application. If the drive isn't mounted, the app (or backup) won't be able to access the drive.

Also:The best Linux laptops right now

And that's why we always want to configure these drives for automounting.

Let me show you how it's done.

How to automount a drive in Linux

What you'll need:To make this work, you'll need a running instance of Linux, a secondary drive plugged into your machine, and a user with sudo privileges. I'll demonstrate with Pop!_OS Linux but the process should be the same, regardless of which distribution you use. I will also assume the drive has been formatted. I always format my secondary Linux drives with the ext4 format.

1. Locate the name of your drive

The first thing to be done is to locate the name of the drive to be mounted. Here's a simple way to find the name.

Also: Can't remember the Linux command you ran earlier? Let history repeat itself

Without the drive plugged in, issue the following command:

lsblk

In the output of that command, you should see entries like this:

sda 8:0 0 931.5G 0 disk └─sda1 8:1 0 931.5G 0 part

Plug the drive in and run the command again and you'll see a new entry like:

sdb 8:16 0 931.5G 0 disk └─sdb1 8:17 0 931.5G 0 part

If you can't easily unplug the secondary disk, just run the lsblk command. If you see two drives, sda and sdb, chances are very good your secondary drive is sdb. For the purpose of showing this process, we'll assume the name of your drive is /dev/sdb.

2. Create a mount point

The mount point will be the directory on your primary drive that will serve as a location you will access the secondary drive from.

Also: The most important reason you should be using Linux at home

This doesn't copy or move the files from one to the other but, rather, creates a place for the operating system to "mount" the secondary drive. Let's create a mount point called /data with the command:

sudo mkdir /data

Next, change the ownership of the new directory to your user with the command:

sudo chown -R $USER:$USER /data

The -R option makes sure all child folders have the same ownership.

3. Create an entry in /etc/fstab

The /etc/fstab is the file responsible for mapping the secondary drive to the mount point.

Also: 8 things you can do with Linux that you can't do with MacOS or Windows

Assuming the name of your secondary drive is /dev/sdb, we'll tack on a 1 to the end (because /dev/sdb1 is the first usable partition). Open the fstab file for editing with the command:

sudo nano /etc/fstab

At the bottom of that file, add an entry like this:

/dev/sdb1 /data ext4 defaults 0 0

Here's an explanation:

  • /dev/sdb1 -- the secondary drive
  • /data -- the mount point
  • ext4 -- the secondary drive file system type.
  • defaults -- uses the default options
  • 0 0 -- these fields are for dump and fsck. Just leave them both as zeros

Save and close the file with Ctrl-X.

Testing the mount

All you need to do to test the mount is issue the command:

mount -a

If you receive no feedback, everything is good. You can now reboot your machine and the secondary drive will be automatically mounted so you can access the files from /data.

Also: How to choose the right Linux desktop distribution for you

Congratulations, you've just successfully set up a secondary drive automount on Linux. Next time around, we'll do the same thing with a GUI.

See also

  • How to replace Windows with Linux Mint on your PC
  • 5 best Linux commands for troubleshooting problems (and how I use them)
  • 5 reasons why Pop!_OS is this Linux pro's favorite distro
  • 5 best open-source email clients for Linux (and why Geary is my go-to)
How to permanently mount a drive in Linux (and why you should) (2024)

FAQs

How to mount a disk in Linux permanently? ›

Mount the drive permanently (optional).
  1. Open /etc/fstab in a text editor like Vim or Nano.
  2. 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.
Jul 31, 2024

How do I always mount a drive in Linux? ›

Open the terminal. Type sudo nano /etc/fstab and press Enter. Replace device_name with the device name of your drive (e.g., /dev/sda1 ), mount_point with the directory where you want to mount the drive (e.g., /mnt/mydrive ), and file_system_type with the file system type of your drive (e.g., ext4 , ntfs ).

Why do you mount drives in Linux? ›

Mount points in Unix, Linux and macOS

The mount command is used to make a device or file system accessible to the system, and then to connect its root directory to a mount point on the local file system.

How to mount persistent? ›

Creating the Persistent Volume
  1. As the admin, create the service, endpoint object, and persistent volume: $ oc create -f gluster-endpoints-service.yaml $ oc create -f gluster-endpoints.yaml $ oc create -f gluster-pv.yaml.
  2. Verify that the objects were created:

How to permanently mount a shared folder in Linux? ›

Mounting a Shared Folder on a Linux Computer
  1. Open a terminal with root privileges.
  2. Run the following command: mount <NAS Ethernet Interface IP>:/share/<Shared Folder Name> <Directory to Mount> Tip: ...
  3. Specify your NAS username and password.

What does fstab do? ›

In Linux, it is part of the util-linux package. The fstab file typically lists all available disk partitions and other types of file systems and data sources that may not necessarily be disk-based, and indicates how they are to be initialized or otherwise integrated into the larger file system structure.

Where should I mount my hard drive in Linux? ›

You can use a mountpoint in both /media and /mnt as well as in some other directory. The classic directory for permanent mount points is /mnt , for example sudo mkdir /mnt/exthdd and use that as a mountpoint. /mnt is for internal disks. /media for external.

What is automount in Linux? ›

An automounter system utility (daemon under Unix), when notified of file and directory access attempts under selectively monitored subdirectory trees, dynamically and transparently makes local or remote devices accessible.

Why is mounting required in Linux? ›

Mounting makes file systems, files, directories, devices, and special files available for use at a particular location. It is the only way a file system is made accessible. The mount command instructs the operating system to attach a file system at a specified directory.

What does mounting a drive do? ›

In the realm of technology and computing, "mount" refers to the process by which the operating system makes files and directories on a storage device (such as hard drive, solid state drive (SSD), compact disc read-only memory (CD-ROM), or network share) accessible to the user through the system's directory tree.

Why do we do mounting? ›

The purpose of mounting is to protect fragile or coated materials during preparation and to obtain perfect edge retention. Mounting is used when the protection of layers is imperative, and also it enables a safer and more convenient handling of small, sharp, or irregularly shaped specimens, for example.

How to permanent mount in Linux? ›

Mount a Disk Drive Permanently
  1. Open /etc/fstab with nano or another text editor (as root or using sudo ). ...
  2. Add a line at the bottom describing the new disk and its mount point. ...
  3. Press Ctrl + X , then Y and Enter to exit and save the file.
Sep 15, 2022

How to permanently mount NFS in Linux? ›

Use this procedure to manually mount to NFS on a Linux client.
  1. Install the NFS client. sudo yum install nfs-utils (Red Hat or CentOS) ...
  2. List the NFS shares exported on the server. ...
  3. Set up a mount point for an NFS share. ...
  4. Mount the cluster using NFS. ...
  5. List all mounted file systems to verify that the cluster is mounted.

How do you permanently mount the remote filesystem? ›

To mount remote filesystem permanently, you need to edit the file called /etc/fstab. To do, open the file with your favorite editor. Go to the bottom of the file and add the following line to it and save the file and exit. The below entry mount remote server file system with default settings.

How do I permanently mount an ISO file in Linux? ›

How to Mount ISO File on Linux
  1. Create the mount point directory on Linux: sudo mkdir /mnt/iso.
  2. Mount the ISO file on Linux: sudo mount -o loop /path/to/my-iso-image.iso /mnt/iso.
  3. Verify it, run: mount OR df -H OR ls -l /mnt/iso/
  4. Unmount the ISO file using: sudo umount /mnt/iso/
Aug 30, 2024

How to mount storage in Linux? ›

Mount Volume
  1. Find the UUID of the storage device disk partition. ...
  2. Create a target folder to be the mount point of the storage device ( container-registry in this example) ...
  3. Mount the storage device partition /dev/sda1 at the mount point /mnt/container-registry. ...
  4. Verify that the storage device is mounted successfully.
Jan 1, 2022

Top Articles
GSU Library Research Guides: CRJU: Criminal Law Online: Module 5: Criminal Defenses
Forex Brokers that Accept Bitcoin Deposit
417-990-0201
Metallica - Blackened Lyrics Meaning
Craigslist Benton Harbor Michigan
Botanist Workbench Rs3
Teenbeautyfitness
Craigslist Dog Sitter
Craigslist Phoenix Cars By Owner Only
Corporate Homepage | Publix Super Markets
Walgreens On Nacogdoches And O'connor
The Weather Channel Facebook
Syracuse Jr High Home Page
Newgate Honda
Local Dog Boarding Kennels Near Me
Diablo 3 Metascore
Craigslist Pets Sac
7 Low-Carb Foods That Fill You Up - Keto Tips
fort smith farm & garden - craigslist
N2O4 Lewis Structure & Characteristics (13 Complete Facts)
Daily Voice Tarrytown
Icommerce Agent
Noaa Ilx
Wausau Marketplace
Water Trends Inferno Pool Cleaner
Noaa Duluth Mn
Spn 520211
Jc Green Obits
At&T Outage Today 2022 Map
Bennington County Criminal Court Calendar
A Christmas Horse - Alison Senxation
2004 Honda Odyssey Firing Order
Co10 Unr
Puffin Asmr Leak
Craigslist Com Humboldt
آدرس جدید بند موویز
Indiana Wesleyan Transcripts
Does Iherb Accept Ebt
Aveda Caramel Toner Formula
Kelly Ripa Necklace 2022
Barber Gym Quantico Hours
The Attleboro Sun Chronicle Obituaries
✨ Flysheet for Alpha Wall Tent, Guy Ropes, D-Ring, Metal Runner & Stakes Included for Hunting, Family Camping & Outdoor Activities (12'x14', PE) — 🛍️ The Retail Market
Skyward Cahokia
Kjccc Sports
Keci News
Meee Ruh
6463896344
De boeken van Val McDermid op volgorde
Understanding & Applying Carroll's Pyramid of Corporate Social Responsibility
Latest Posts
Article information

Author: Kimberely Baumbach CPA

Last Updated:

Views: 6353

Rating: 4 / 5 (61 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Kimberely Baumbach CPA

Birthday: 1996-01-14

Address: 8381 Boyce Course, Imeldachester, ND 74681

Phone: +3571286597580

Job: Product Banking Analyst

Hobby: Cosplaying, Inline skating, Amateur radio, Baton twirling, Mountaineering, Flying, Archery

Introduction: My name is Kimberely Baumbach CPA, I am a gorgeous, bright, charming, encouraging, zealous, lively, good person who loves writing and wants to share my knowledge and understanding with you.