• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
OpenTechTips

OpenTechTips

Comprehensive IT Guides for Pros and Enthusiasts

MENUMENU
  • HOME
  • ALL TOPICS
    • Exchange
    • InfoSec
    • Linux
    • Networking
    • Scripting
      • PowerShell
    • SSL
    • Tools
    • Virtualization
    • Web
    • Windows
  • ABOUT
  • SUBSCRIBE
Home » Mount NFS, SMB shares and local volumes in Linux | Cheat Sheet

Mount NFS, SMB shares and local volumes in Linux | Cheat Sheet

June 24, 2020 - by Zsolt Agoston - last edited on September 26, 2020

This a quick guide on how to mount different type of volumes or shares in Linux. We go through the most common scenarios: local volumes, NFS and SMB shares. For each we discuss the manual way to mount them, also how the automatic way works at boot, editing the /etc/fstab file.

1. Mount local (LVM) volume

Local LVM volume to mount: /dev/vg00/lvm

Automatically mount at boot in /mnt/lvm, editing the fstab file as follows

#
# /etc/fstab
# Created by anaconda on Tue Jun 23 12:09:56 2020
#
...

# Mount LVM local volume
/dev/vg00/lvm   /mnt/lvm        ext4    defaults        0 0

# or using the volume/s ID instead, see details below:
UUID=7ee8732a-c054-4b72-be83-9cefffacc62e /mnt/lvm ext4    defaults        0 0
NOTE: you can use the UID of the volume instead of the /dev/ location path. To get that ID, run the blkid command:
root@localhost /]# blkid
…
/dev/mapper/vg00-lvm: UUID="7ee8732a-c054-4b72-be83-9cefffacc62e" TYPE="ext4"

NOTE2: /dev/mapper/bg00-lvm and /dev/vg00/lvm are referring to the same thing

Manually

[root@localhost /]# mount /dev/vg00/lvm /mnt/lvm

2. Mount NFS share

NFS share to mount: 10.0.0.10:/nfs in /mnt/nfs

Prerequisites

# RHEL, CentOS:
yum install -y nfs-utils

#Debian, Ubuntu:
apt install -y nfs-utils

Auto-mount at boot in /mnt/nfs

#
# /etc/fstab
# Created by anaconda on Tue Jun 23 12:09:56 2020
#
…

# Mount nfs share
10.0.0.10:/nfs  /mnt/nfs        nfs     rw,hard,async,nosuid,intr        0 0

Manually

[root@localhost /]# mount 10.0.0.10:/nfs /mnt/nfs
Options explained:
rw:       read-write access to the share
hard:    if the nfs share is not responsive, requests are not timing out. This is to prevent possible data corruption
async:  changes are not immediately flushed to disk, resulting in faster, more optimized operation
nosuid:disabled the setuid and sgid bits, preventing users to gain undesired higher privileges
intr:     allows NFS requests to be interrupted. The data corruption is less likely than with the soft option set

3. Mount SMB share

SMB share to mount: 10.0.0.10:/nfs /mnt/nfs

Prerequisites

# RHEL, CentOS:
yum install -y cifs-utils

#Debian, Ubuntu:
apt install -y cifs-utils

Create credential file for the remote share

1. create /etc/smbcredential

user=smbuser
password=S3cretPasswd!
domain=a.com

2. Lock down the file from unathorized access:

[root@localhost /]# chmod 400 /etc/smbcredential

Auto-mount at boot in /mnt/smb

#
# /etc/fstab
# Created by anaconda on Tue Jun 23 12:09:56 2020
#
…

# Mount smb share
//10.0.0.100/c$/smb  /mnt/smb       cifs     uid=0,credentials=/etc/smbcredential,iocharset=utf8,vers=2.1,noperm        0 0

Manually

[root@localhost /]# mount -t cifs //10.0.0.100/c$/smb /mnt/smb -o domain=a.com,username=smbuser
Password for smbuser@//10.0.0.100/c$/smb:  *************

# or

[root@localhost /]# mount -t cifs //10.0.0.100/c$/smb /mnt/smb -o credentials=/etc/smbcredential
Options explained:
uid:      local user ID, without this declared, the share won't be mounted
vers:    for older Windows machines SMBv1 is probably needed, for newer systems version 2.1 or 3.0 is the right choice. All depends on the SMB server config
noperm:no permission check is performed by the client - this prevents UID mismatch issues between the server and the client

Reader Interactions

Comments

  1. mobile legends hacks says

    September 23, 2020 at 14:49

    For latest information you have to go to see world wide web and on the web I found this website as a best web page for latest
    updates.

    Reply
  2. fill that seat says

    September 28, 2020 at 14:34

    Wow, this article is nice, my younger sister is analyzing
    these things, therefore I am going to tell her.

    Reply
    • Zsolt Agoston says

      September 28, 2020 at 20:51

      Great, let me know if you have any questions or if she needs any help with her work.

      Reply
  3. Rose says

    June 28, 2021 at 04:34

    It is my understanding that a java app running on a linux server can access the SMB share by putting credentials in the application. Is there an advantage to mounting it versus just letting the app handle it?

    Reply

Comments Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Tools

Secondary Sidebar

CONTENTS

  • 1. Mount local (LVM) volume
  • Automatically mount at boot in /mnt/lvm, editing the fstab file as follows
  • Manually
  • 2. Mount NFS share
  • Prerequisites
  • Auto-mount at boot in /mnt/nfs
  • Manually
  • 3. Mount SMB share
  • Prerequisites
  • Create credential file for the remote share
  • Auto-mount at boot in /mnt/smb
  • Manually

  • Terms of Use
  • Disclaimer
  • Privacy Policy
Manage your privacy

To provide the best experiences, we and our partners use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us and our partners to process personal data such as browsing behavior or unique IDs on this site and show (non-) personalized ads. Not consenting or withdrawing consent, may adversely affect certain features and functions.

Click below to consent to the above or make granular choices. Your choices will be applied to this site only. You can change your settings at any time, including withdrawing your consent, by using the toggles on the Cookie Policy, or by clicking on the manage consent button at the bottom of the screen.

Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Statistics

Marketing

Features
Always active

Always active
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
Manage options
{title} {title} {title}
Manage your privacy
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Statistics

Marketing

Features
Always active

Always active
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
Manage options
{title} {title} {title}