How to Mount Storage Devices in Ubuntu: A Complete Beginner-to-Advanced Guide

目次

1. What Does “Mount” Mean in Ubuntu?

The Meaning and Role of Mounting

In Linux and Ubuntu, “mounting” refers to the process of attaching a storage device to the file system.
For example, simply plugging a USB flash drive or external hard drive into a PC does not immediately make its contents accessible. Ubuntu performs a process called “mounting” to make the contents of that storage device visible at a specific location, such as /media or /mnt, known as a mount point.

You can think of it as physically attaching a “component” (the storage device) to the “main system” (Ubuntu) so that its contents can finally be used.

This concept applies not only to removable media like USB drives, but also to internal hard drive partitions, SSDs, and even shared folders on a network.

The Relationship Between File Systems and Devices

In Linux, including Ubuntu, all files and directories exist within a single hierarchical structure that starts at the root directory (/).
To integrate an external device, you create an empty directory called a mount point and “attach” the device to it. Once mounted, the system treats the device as if it had always been part of the file system.

For example, if you mount a USB drive at /media/usb, its contents will appear under that directory and can be copied, edited, or deleted like any other files.

The key point is that Ubuntu cannot access a device unless it is mounted.
Even if the system recognizes the hardware, file read/write operations are impossible until mounting is complete.

Differences Between Ubuntu and Other Operating Systems (Windows / macOS)

On Windows, inserting a USB device usually results in it being automatically assigned a drive letter such as D: or E:. In Ubuntu, however, whether a device is automatically mounted depends on system settings.
In desktop environments, most storage devices are auto-mounted, but in server environments or terminal-focused setups, manual mounting is often required.

Another difference is file system awareness. Windows users rarely need to think about file system types such as NTFS or FAT32, but on Ubuntu, mount options and compatibility vary depending on the file system.
For example, to fully handle NTFS devices, you may need to install the ntfs-3g package.

In short, mounting in Ubuntu is not just about connecting hardware—it is a critical process that integrates storage into the operating system’s file system. In the following sections, we will explore practical mounting methods and configuration examples in detail.

2. Manual Mounting in Ubuntu: Basic Methods

Basic Syntax and Usage of the mount Command

To manually mount a storage device in Ubuntu, you use the mount command.
Although its syntax is simple, it is extremely powerful and flexible.

sudo mount [options] device_path mount_point

For example, to mount a USB drive (/dev/sdb1) to the directory /mnt/usb, use the following command:

sudo mount /dev/sdb1 /mnt/usb

After executing this command, the files on the USB drive will appear inside /mnt/usb, and you will be able to read and write them.

Note that mounting requires root privileges, so the command must be executed with sudo.

Creating and Managing Mount Points

A mount point is an empty directory used as the attachment location for a device.
You must create this directory in advance.

sudo mkdir -p /mnt/usb

The -p option automatically creates parent directories if they do not exist.
Temporary manual mounts are commonly placed under /mnt or /media, but you are free to use any directory you prefer.

Once the device is mounted, the mount point directory will contain the device’s files. After unmounting, it returns to being an empty directory.

How to Identify Device Names and UUIDs

To mount a device, you must know its device name (such as /dev/sdb1). You can check this using the following command:

lsblk

The lsblk command lists all connected block devices (HDDs, SSDs, USB drives, etc.), including their sizes and mount status.

If you need to check the UUID (Universally Unique Identifier), use:

sudo blkid

The blkid command displays the UUID and file system type (ext4, ntfs, fat32, and so on) for each device. UUIDs are especially important for automatic mounting with fstab, which we will discuss later.

Unmounting Devices with umount

To safely detach a mounted device, use the umount command.
For example, to unmount a device mounted at /mnt/usb:

sudo umount /mnt/usb

You can also specify the device name directly:

sudo umount /dev/sdb1

Physically removing a device without unmounting it first may cause data corruption. Always unmount devices before disconnecting them.

3. Automatic Mounting at Boot Time (fstab)

What Is /etc/fstab?

If you want Ubuntu to automatically mount devices at startup, you use the /etc/fstab file.
This file is a system-wide configuration file that defines which devices are mounted during boot.

For example, if you regularly use an external drive or an additional partition and want to avoid mounting it manually each time, adding an entry to fstab will automate the process.

However, be careful: incorrect entries can prevent the system from booting properly.

Using UUIDs for Safer Configuration

Devices can be specified in fstab using either device names (such as /dev/sdb1) or UUIDs. Using UUIDs is strongly recommended.
Device names may change depending on connection order, while UUIDs remain constant.

First, check the UUID:

sudo blkid

Example output:

/dev/sdb1: UUID="1234-ABCD" TYPE="vfat"

Then add the following line to /etc/fstab:

UUID=1234-ABCD /mnt/usb vfat defaults 0 0

The meaning of each field is as follows:

FieldDescription
UUID=…Unique identifier of the target device
/mnt/usbMount point
vfatFile system type
defaultsStandard mount options
0 0Backup and filesystem check settings

Tips to Avoid Errors When Editing fstab

Errors in fstab can cause serious boot problems.
To minimize risk, follow these precautions:

  • Always create a backup: sudo cp /etc/fstab /etc/fstab.bak
  • Ensure the mount point exists: create it with sudo mkdir -p /mnt/usb
  • Test the configuration using the following command:
sudo mount -a

This command attempts to mount all entries defined in fstab. If no errors appear, the configuration is valid.

4. How to Mount USB Flash Drives and External Hard Drives

Differences Between FAT32, exFAT, and NTFS File Systems

When mounting USB flash drives or external hard drives in Ubuntu, it is important to check the file system type. The following three are the most common:

File SystemCharacteristicsUbuntu Support
FAT32Readable on almost all operating systemsSupported by default
exFATSupports large files, high compatibilitySupported by default on Ubuntu 20.04+, older versions require exfat-fuse
NTFSStandard file system on WindowsRead support by default; ntfs-3g recommended for full write support

To fully handle NTFS-formatted devices, install ntfs-3g:

sudo apt update
sudo apt install ntfs-3g

Checking Devices and Manual Mounting Steps

After connecting a USB device, first check the device name using:

lsblk

Example output:

sdb      8:16   1   16G  0 disk 
└─sdb1   8:17   1   16G  0 part /mnt/usb

In this case, /dev/sdb1 is the target partition. Create a mount point:

sudo mkdir -p /mnt/usb

Then mount the device:

sudo mount /dev/sdb1 /mnt/usb

The contents of the device will appear under /mnt/usb and can be accessed normally.

What to Do When Auto-Mount Does Not Work

In desktop environments such as GNOME, USB devices are usually mounted automatically. However, auto-mount may not work in server environments or under certain configurations.

Try the following solutions:

  1. Reconnect using a file manager (desktop environments)
  2. Use the udisksctl command:
udisksctl mount -b /dev/sdb1
  1. Check kernel messages with dmesg:
dmesg | tail

If messages such as “new USB device” do not appear, the issue may be a faulty cable or physical connection.

Safely Removing Devices (umount)

Removing a USB device without unmounting it can lead to data corruption. Always unmount before unplugging:

sudo umount /mnt/usb

If the mount point is unknown, you can specify the device directly:

sudo umount /dev/sdb1

Once unmounted successfully, the device can be safely removed.

5. Mounting Network Drives (NAS)

Mounting Windows Shares (SMB / CIFS)

Ubuntu can mount shared folders from Windows systems or NAS devices using the SMB/CIFS protocol, allowing them to be accessed like local directories.

First, install the required package:

sudo apt update
sudo apt install cifs-utils

Create a mount point:

sudo mkdir -p /mnt/share

Then mount the shared folder:

sudo mount -t cifs //192.168.1.100/share /mnt/share -o username=USERNAME,password=PASSWORD,iocharset=utf8

Key points:

  • //192.168.1.100/share: IP address and share name
  • /mnt/share: Local mount point
  • -o options: Username, password, character encoding
  • iocharset=utf8: Prevents garbled Japanese filenames

If you do not want to expose passwords on the command line, see the section on secure credential management below.

Mounting NFS Shares

NFS (Network File System) is well suited for file sharing between Linux systems.

Install the required client package:

sudo apt install nfs-common

Create a mount point:

sudo mkdir -p /mnt/nfs

Mount the NFS share:

sudo mount -t nfs 192.168.1.200:/export/share /mnt/nfs

Adjust the path according to your server configuration.

To enable automatic mounting at boot, add the following entry to /etc/fstab:

192.168.1.200:/export/share /mnt/nfs nfs defaults 0 0

Secure Management of Credentials (Username / Password)

Including passwords directly in mount commands is not recommended for security reasons. Instead, you can use a credentials file.

  1. Create a credentials file (for example):
sudo nano /etc/samba/credentials

File contents:

username=your_username
password=your_password
  1. Restrict file permissions:
sudo chmod 600 /etc/samba/credentials
  1. Add the following entry to fstab:
//192.168.1.100/share /mnt/share cifs credentials=/etc/samba/credentials,iocharset=utf8 0 0

This allows automatic mounting at boot without exposing passwords.

Preventing Garbled Japanese Filenames (Locale Settings)

If Japanese filenames appear as “????.txt” when mounting SMB shares, the issue is usually related to character encoding.

Ensure the following option is specified:

iocharset=utf8

Also verify your system locale:

locale

If ja_JP.UTF-8 is not present, install and enable the Japanese locale:

sudo apt install language-pack-ja
sudo update-locale LANG=ja_JP.UTF-8

Log out or reboot to apply the changes.

6. Common Errors and Troubleshooting

When “Target Is Busy” Appears

Error message:

umount: /mnt/usb: target is busy.

This error occurs when the device you are trying to unmount is currently being used by one or more processes.

Common causes:

  • Another terminal is currently cd-ed into the directory
  • A file is open in a GUI application
  • A background process is accessing files on the device

Solutions:

  1. Identify the processes using the mount point:
lsof /mnt/usb
  1. Terminate or close the identified processes
  2. If the issue persists, use fuser:
sudo fuser -km /mnt/usb

This command forcibly terminates processes using the mount point. Use it with caution.

Resolving “Permission Denied” Errors

Error message:

mount: /mnt/share: permission denied.

This error indicates insufficient permissions for the mount point or device.

Solutions:

  1. Ensure sudo is used:
sudo mount /dev/sdb1 /mnt/usb
  1. Adjust mount point ownership if necessary:
sudo chown $USER:$USER /mnt/usb
  1. For SMB shares, verify credentials and access permissions on the server

When Automatic Mounting Does Not Work

Even after configuring fstab, devices may fail to mount automatically at boot.

Things to check:

  • Syntax errors in fstab (spacing, filesystem type)
  • Correct UUID (verify with sudo blkid)
  • Mount point exists (create with mkdir)
  • Network shares not yet available at boot time (SMB / NFS)

Debugging:

sudo mount -a

If errors appear, correct the corresponding fstab entry.

Checking Logs with dmesg and journalctl

Detailed error information is often recorded in system logs.

dmesg | tail -n 20

For more detailed logs:

journalctl -xe

These logs help identify hardware issues or invalid mount options.

Other Common Mount-Related Errors

SymptomCauseSolution
mount: unknown filesystem type ‘exfat’exFAT not supportedsudo apt install exfat-fuse exfat-utils
I/O error when mounting SMBSMB version mismatchAdd vers=1.0 or vers=3.0 to mount options
Filenames appear as ????Locale / encoding issueAdd iocharset=utf8 or review locale settings

7. Reference: Common Mount Commands and Usage

■ Checking Devices

lsblk

Displays connected devices and partition structure.

lsblk

Example:

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb      8:16   1  16G  0 disk 
└─sdb1   8:17   1  16G  0 part /mnt/usb

blkid

Displays UUIDs and filesystem types.

sudo blkid

■ Mounting and Unmounting

mount

Basic command for mounting storage.

sudo mount /dev/sdb1 /mnt/usb

Specifying filesystem and options:

sudo mount -t vfat -o uid=1000,gid=1000 /dev/sdb1 /mnt/usb

umount

Unmounts a mounted device.

sudo umount /mnt/usb

Or specify the device:

sudo umount /dev/sdb1

■ Automatic Mounting

/etc/fstab

Configuration file for mounting devices at system startup.

sudo nano /etc/fstab

Example entry:

UUID=1234-ABCD /mnt/usb vfat defaults 0 0

mount -a

Validates and mounts all entries defined in fstab.

sudo mount -a

■ Troubleshooting Tools

dmesg

Checks kernel logs for mount-related errors.

dmesg | tail -n 20

journalctl

Displays detailed system logs.

journalctl -xe

lsof

Identifies processes using a mount point.

lsof /mnt/usb

fuser

Forcefully terminates processes using a mount point.

sudo fuser -km /mnt/usb

■ Network Shares

cifs-utils

Required for SMB/CIFS mounts.

sudo apt install cifs-utils

nfs-common

Required for NFS mounts.

sudo apt install nfs-common

udisksctl

Simple mounting/unmounting in non-GUI environments.

udisksctl mount -b /dev/sdb1
udisksctl unmount -b /dev/sdb1

8. FAQ: Frequently Asked Questions About Mounting in Ubuntu

Q1. Why is my USB device not automatically mounted?

A. USB devices are usually auto-mounted in desktop environments, but auto-mount may fail in the following cases:

  • You are using Ubuntu Server or a non-GUI environment
  • The device is not recognized correctly (cable or hardware issue)
  • The device has no filesystem or is corrupted

Check device recognition using lsblk or dmesg, then try manual mounting.

Q2. Ubuntu fails to boot after editing fstab. What should I do?

A. Incorrect fstab entries can cause the system to stop in maintenance mode.

Recovery steps:

  1. Log in to maintenance mode and edit fstab:
sudo nano /etc/fstab
  1. Comment out incorrect lines using #
  2. Run mount -a to confirm no errors
  3. Reboot the system

Always create a backup before editing:

sudo cp /etc/fstab /etc/fstab.bak

Q3. How can I automatically mount Windows shared folders?

A. Add an entry to /etc/fstab using a credentials file.

//192.168.1.100/share /mnt/share cifs credentials=/etc/samba/credentials,iocharset=utf8 0 0

Verify functionality with sudo mount -a.

Q4. How can I mount without entering a password each time?

A. Use a credentials file for SMB mounts. For local storage devices, proper fstab configuration eliminates password prompts.

Q5. How do I list currently mounted devices?

A. Use one of the following commands:

mount | column -t

Or a more visual view:

lsblk -f

Q6. “Target is busy” appears even after closing applications

A. Identify remaining processes:

lsof /mnt/usb

Or forcibly terminate them:

sudo fuser -km /mnt/usb

Then retry umount.

9. Summary

Mounting in Ubuntu is a fundamental skill for effectively managing storage devices and network shares.
This article covered everything from basic concepts to advanced configuration and troubleshooting.

Key Takeaways

  • Mounting integrates devices into the Linux file system
  • Manual mounting provides flexibility and control
  • fstab enables reliable automatic mounting
  • USB, external drives, and NAS require filesystem-aware handling
  • Proper unmounting prevents data corruption
  • Troubleshooting tools help resolve common issues efficiently

Once mastered, Ubuntu’s mounting system offers exceptional flexibility and power.
Apply the commands and concepts from this guide to build a stable and efficient storage environment tailored to your needs.

This knowledge will support everything from daily file management to server operations and NAS integration, helping you use Ubuntu with confidence and precision.

侍エンジニア塾