ZetCode

Linux mount and lsblk Commands

last modified October 24, 2026

On Linux, all files live in a single directory tree that starts at /. File systems on disks, partitions, USB sticks, disk images, or in memory become part of the tree when they are mounted on a directory, the mount point. The lsblk command lists the block devices, blkid shows the file systems on them, mount and umount attach and detach file systems, findmnt shows what is mounted where, and /etc/fstab lists the file systems mounted at boot.

The examples were run in a Debian 12 virtual machine (util-linux 2.38.1) with a system disk vda, two new empty disks vdb (2 GB) and vdc (1 GB), and a small CD-ROM image. The user jano has sudo rights. Most of these commands change the system and must be run as root.

Listing block devices

The lsblk command shows the block devices as a tree of disks and partitions.

lsblk

vda is the system disk with three partitions: the root file system vda1, a small BIOS boot partition vda14, and the EFI system partition vda15. vdb and vdc have no partitions yet, and sr0 is the CD-ROM drive. MAJ:MIN are the device numbers, RM marks removable devices, RO read-only ones, and MOUNTPOINTS shows where a device is mounted. On a physical machine, disks are named sda, sdb, … (SATA, SCSI, USB) or nvme0n1 (NVMe), with partitions sda1 or nvme0n1p1; vd is the name of virtio disks in virtual machines.

$ lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sr0      11:0    1  366K  1 rom
vda     254:0    0    8G  0 disk
├─vda1  254:1    0  7.9G  0 part /
├─vda14 254:14   0    3M  0 part
└─vda15 254:15   0  124M  0 part /boot/efi
vdb     254:16   0    2G  0 disk
vdc     254:32   0    1G  0 disk

Showing file systems

The -f option adds information about the file systems.

lsblk -f

The root partition holds an ext4 file system, the EFI partition a FAT16 (vfat) one, and the CD an ISO 9660 file system with the label cidata. The UUID uniquely identifies a file system; unlike device names, which can change when disks are added, it stays the same. FSAVAIL and FSUSE% are shown only for mounted file systems.

$ lsblk -f
NAME    FSTYPE  FSVER            LABEL  UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sr0     iso9660 Joliet Extension cidata 2026-10-24-19-45-26-00
vda
├─vda1  ext4    1.0                     689251b4-7efe-43c2-8033-20c0a11b58a5    6.5G    11% /
├─vda14
└─vda15 vfat    FAT16                   271B-1801                             111.9M    10% /boot/efi
vdb
vdc

Choosing columns

The -o option selects the columns, and other options limit or change the output.

lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS
lsblk -d
lsblk -p /dev/vda
lsblk -b -o NAME,SIZE /dev/vdb

-d lists only whole devices without partitions, -p prints full device paths, a device argument restricts the output to that device, and -b prints sizes in bytes. The list of all columns is in lsblk --help.

$ lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS
NAME     SIZE TYPE FSTYPE  MOUNTPOINTS
sr0      366K rom  iso9660
vda        8G disk
├─vda1   7.9G part ext4    /
├─vda14    3M part
└─vda15  124M part vfat    /boot/efi
vdb        2G disk
vdc        1G disk
$ lsblk -d
NAME MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sr0   11:0    1  366K  1 rom
vda  254:0    0    8G  0 disk
vdb  254:16   0    2G  0 disk
vdc  254:32   0    1G  0 disk
$ lsblk -p /dev/vda
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
/dev/vda     254:0    0    8G  0 disk
├─/dev/vda1  254:1    0  7.9G  0 part /
├─/dev/vda14 254:14   0    3M  0 part
└─/dev/vda15 254:15   0  124M  0 part /boot/efi
$ lsblk -b -o NAME,SIZE /dev/vdb
NAME       SIZE
vdb  2147483648

The blkid command

blkid reads the file system signatures and prints their attributes.

sudo blkid
sudo blkid -s UUID -o value /dev/vda1

Besides the file system UUID, GPT partitions have a PARTUUID, the identifier of the partition itself. With -s and -o value, blkid prints a single value, which is handy in scripts. On Debian, blkid, mkfs, losetup, and other administration tools are in /usr/sbin, which is not in the PATH of regular users; run them with sudo or with their full path.

$ sudo blkid
/dev/sr0: BLOCK_SIZE="2048" UUID="2026-10-24-19-45-26-00" LABEL="cidata" TYPE="iso9660"
/dev/vda15: SEC_TYPE="msdos" UUID="271B-1801" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="f8ba111e-6d41-4805-b6e9-a675e98fa4de"
/dev/vda1: UUID="689251b4-7efe-43c2-8033-20c0a11b58a5" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="bffbeacd-9a3f-4c7f-9137-c48892ef554a"
/dev/vda14: PARTUUID="2e3a9791-d081-4cc7-a697-7e36b33cfeae"
$ sudo blkid -s UUID -o value /dev/vda1
689251b4-7efe-43c2-8033-20c0a11b58a5

Partitioning a new disk

Before a new disk can store files, it usually gets a partition table and a partition. parted can do it in one non-interactive command.

sudo parted -s /dev/vdb mklabel gpt mkpart data ext4 1MiB 100%
sudo parted -s /dev/vdb print
lsblk /dev/vdb

mklabel gpt creates an empty GPT partition table, and mkpart a partition named data from 1 MiB to the end of the disk; starting at 1 MiB aligns the partition for good performance. The ext4 argument is only a hint for the partition type; it does not create a file system. Interactive tools such as fdisk and cfdisk do the same job. Be sure to pick the right disk: mklabel destroys the existing partition table.

$ sudo parted -s /dev/vdb mklabel gpt mkpart data ext4 1MiB 100%
$ sudo parted -s /dev/vdb print
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  2146MB  2145MB               data

$ lsblk /dev/vdb
NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
vdb    254:16   0   2G  0 disk
└─vdb1 254:17   0   2G  0 part

Creating a file system

The mkfs family of commands creates file systems.

sudo mkfs.ext4 -L data /dev/vdb1
lsblk -f /dev/vdb

-L sets a label. mkfs.ext4 reports the size, the new UUID, and the locations of backup superblocks, which e2fsck can use to repair a damaged file system. Other file systems have their own tools, such as mkfs.xfs, mkfs.btrfs, or mkfs.vfat.

$ sudo mkfs.ext4 -L data /dev/vdb1
mke2fs 1.47.0 (5-Feb-2023)
Discarding device blocks: done
Creating filesystem with 523776 4k blocks and 131072 inodes
Filesystem UUID: 692641d5-775b-4ab9-ad1a-906ee20eb0ed
Superblock backups stored on blocks:
	32768, 98304, 163840, 229376, 294912

Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

$ lsblk -f /dev/vdb
NAME   FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
vdb
└─vdb1

Mounting a file system

The mount command attaches a file system to an existing directory.

sudo mkdir /mnt/data
sudo mount /dev/vdb1 /mnt/data
findmnt /mnt/data
df -h /mnt/data
ls -la /mnt/data

mount detects the file system type by itself; it can be given explicitly with -t ext4. From now on, everything under /mnt/data is stored on vdb1. A new ext4 file system contains only the lost+found directory, where e2fsck places recovered files. /mnt is the traditional place for temporary mounts; permanent ones often go to /srv, /data, or similar directories.

$ sudo mkdir /mnt/data
$ sudo mount /dev/vdb1 /mnt/data
$ findmnt /mnt/data
TARGET    SOURCE    FSTYPE OPTIONS
/mnt/data /dev/vdb1 ext4   rw,relatime
$ df -h /mnt/data
Filesystem      Size  Used Avail Use% Mounted on
/dev/vdb1       2.0G   24K  1.9G   1% /mnt/data
$ ls -la /mnt/data
total 24
drwxr-xr-x 3 root root  4096 Oct 24 21:45 .
drwxr-xr-x 3 root root  4096 Oct 24 21:45 ..
drwx------ 2 root root 16384 Oct 24 21:45 lost+found

Permissions on a new file system

The root directory of a new file system belongs to root, so regular users cannot write to it.

touch /mnt/data/test.txt
sudo mkdir /mnt/data/projects
sudo chown jano: /mnt/data/projects
echo "Project notes" > /mnt/data/projects/notes.txt
ls -l /mnt/data /mnt/data/projects

After mounting, the permissions of the mount point directory are replaced by those of the file system's root directory. We create a directory for the user and give it to jano; the jano: form sets the owner and the user's login group.

$ touch /mnt/data/test.txt
touch: cannot touch '/mnt/data/test.txt': Permission denied
$ sudo mkdir /mnt/data/projects
$ sudo chown jano: /mnt/data/projects
$ echo "Project notes" > /mnt/data/projects/notes.txt
$ ls -l /mnt/data /mnt/data/projects
/mnt/data:
total 20
drwx------ 2 root root 16384 Oct 24 21:45 lost+found
drwxr-xr-x 2 jano jano  4096 Oct 24 21:45 projects

/mnt/data/projects:
total 4
-rw-r--r-- 1 jano jano 14 Oct 24 21:45 notes.txt

Listing mounted file systems

Without arguments, mount lists all mounted file systems. The list is long, because it includes many virtual file systems, so it is usually filtered or replaced by findmnt.

mount | grep vd
mount -t ext4
findmnt --real
findmnt -n -o SOURCE,FSTYPE,SIZE /mnt/data
findmnt -T /mnt/data/projects/notes.txt

mount -t lists file systems of a type. findmnt shows the mounts as a tree; --real hides pseudo file systems such as proc, sysfs, and cgroups. -o selects columns and -n drops the header. -T finds the file system that contains a given path.

$ mount | grep vd
/dev/vda1 on / type ext4 (rw,relatime,discard,errors=remount-ro)
/dev/vda15 on /boot/efi type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)
/dev/vdb1 on /mnt/data type ext4 (rw,relatime)
$ mount -t ext4
/dev/vda1 on / type ext4 (rw,relatime,discard,errors=remount-ro)
/dev/vdb1 on /mnt/data type ext4 (rw,relatime)
$ findmnt --real
TARGET      SOURCE     FSTYPE OPTIONS
/           /dev/vda1  ext4   rw,relatime,discard,errors=remount-ro
├─/boot/efi /dev/vda15 vfat   rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro
└─/mnt/data /dev/vdb1  ext4   rw,relatime
$ findmnt -n -o SOURCE,FSTYPE,SIZE /mnt/data
/dev/vdb1 ext4    1.9G
$ findmnt -T /mnt/data/projects/notes.txt
TARGET    SOURCE    FSTYPE OPTIONS
/mnt/data /dev/vdb1 ext4   rw,relatime

Unmounting and busy file systems

The umount command (without the first n) detaches a file system. It fails while a process uses the file system.

(cd /mnt/data/projects && exec sleep 300) &
sudo umount /mnt/data
sudo fuser -vm /mnt/data
kill $!
sudo umount /mnt/data
findmnt /mnt/data; echo $?
ls /mnt/data

The background process has its working directory on the file system, which is enough to keep it busy. fuser -vm lists the processes that use a mounted file system; lsof /mnt/data gives similar information. After the process ended, the unmount succeeded, and /mnt/data is an empty directory again. The data is still on the disk. umount -l (lazy) detaches the file system at once and finishes when it is no longer used, but it hides the problem rather than solving it.

$ (cd /mnt/data/projects && exec sleep 300) &
$ sudo umount /mnt/data
umount: /mnt/data: target is busy.
$ sudo fuser -vm /mnt/data
                     USER        PID ACCESS COMMAND
/mnt/data:           root     kernel mount /mnt/data
                     jano        606 ..c.. sleep
$ kill $!
$ sudo umount /mnt/data
$ findmnt /mnt/data; echo $?
1
$ ls /mnt/data

Mount options

The -o option passes mount options. remount changes the options of a mounted file system without unmounting it.

sudo mount -o ro /dev/vdb1 /mnt/data
touch /mnt/data/projects/todo.txt
findmnt -n -o OPTIONS /mnt/data
sudo mount -o remount,rw /mnt/data
touch /mnt/data/projects/todo.txt
findmnt -n -o OPTIONS /mnt/data

ro mounts the file system read-only, which protects data during recovery or inspection. relatime is the default rule for updating access times; see the stat and file article.

$ sudo mount -o ro /dev/vdb1 /mnt/data
$ touch /mnt/data/projects/todo.txt
touch: cannot touch '/mnt/data/projects/todo.txt': Read-only file system
$ findmnt -n -o OPTIONS /mnt/data
ro,relatime
$ sudo mount -o remount,rw /mnt/data
$ touch /mnt/data/projects/todo.txt
$ findmnt -n -o OPTIONS /mnt/data
rw,relatime

The noexec option

The noexec option forbids running programs directly from a file system. It is often used for /tmp and for data partitions.

printf '#!/bin/sh\necho "Hello from hello.sh"\n' > /mnt/data/projects/hello.sh
chmod +x /mnt/data/projects/hello.sh
/mnt/data/projects/hello.sh
sudo mount -o remount,noexec /mnt/data
/mnt/data/projects/hello.sh
sh /mnt/data/projects/hello.sh
sudo mount -o remount,exec /mnt/data

With noexec, the executable script cannot be started (Permission denied) even though it has the execute bit. Passing it to an interpreter still works, because then the interpreter sh is the program being executed. noexec stops mistakes and simple attacks, not a determined user. Related options are nosuid, which ignores set-user-ID bits, and nodev, which ignores device files.

$ printf '#!/bin/sh\necho "Hello from hello.sh"\n' > /mnt/data/projects/hello.sh
$ chmod +x /mnt/data/projects/hello.sh
$ /mnt/data/projects/hello.sh
Hello from hello.sh
$ sudo mount -o remount,noexec /mnt/data
$ /mnt/data/projects/hello.sh
bash: /mnt/data/projects/hello.sh: Permission denied
$ sh /mnt/data/projects/hello.sh
Hello from hello.sh
$ sudo mount -o remount,exec /mnt/data

Mounting at boot with /etc/fstab

File systems listed in /etc/fstab are mounted at boot. Each line has six fields: the source, the mount point, the type, the options, a dump flag (unused today, 0), and the order of file system checks (1 for the root file system, 2 for others, 0 for none).

cat /etc/fstab
uuid=$(sudo blkid -s UUID -o value /dev/vdb1)
echo "UUID=$uuid /mnt/data ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstab
sudo systemctl daemon-reload
sudo findmnt --verify
sudo umount /mnt/data
sudo mount -a
findmnt /mnt/data

The existing entries refer to partitions by their PARTUUID. We add the data file system by its UUID, which does not change when disks are renamed. The nofail option lets the system boot even if the disk is missing; without it, a missing disk stops the boot in emergency mode. sudo tee -a appends as root; a plain sudo echo ... >> /etc/fstab would fail, because the redirection is done by the user's shell. systemd generates mount units from /etc/fstab, so we reload it after the change. findmnt --verify checks the file, and mount -a mounts all entries that are not mounted yet. Testing with mount -a before a reboot catches errors that could otherwise make the system unbootable.

$ cat /etc/fstab
PARTUUID=bffbeacd-9a3f-4c7f-9137-c48892ef554a / ext4 rw,discard,errors=remount-ro,x-systemd.growfs 0 1
PARTUUID=f8ba111e-6d41-4805-b6e9-a675e98fa4de /boot/efi vfat defaults 0 0
$ uuid=$(sudo blkid -s UUID -o value /dev/vdb1)
$ echo "UUID=$uuid /mnt/data ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstab
UUID=692641d5-775b-4ab9-ad1a-906ee20eb0ed /mnt/data ext4 defaults,nofail 0 2
$ sudo systemctl daemon-reload
$ sudo findmnt --verify
Success, no errors or warnings detected
$ sudo umount /mnt/data
$ sudo mount -a
$ findmnt /mnt/data
TARGET    SOURCE    FSTYPE OPTIONS
/mnt/data /dev/vdb1 ext4   rw,relatime

Checking fstab and short mount commands

findmnt --verify reports entries that would fail. With an entry in /etc/fstab, it is also enough to name the mount point.

cp /etc/fstab bad-fstab
echo "UUID=0000-1111 /mnt/backup ext5 defaults 0 2" >> bad-fstab
sudo findmnt --verify --tab-file bad-fstab
sudo umount /mnt/data
sudo mount /mnt/data
findmnt -n -o SOURCE /mnt/data

We test a copy with a wrong entry: neither the UUID nor the mount point exists, and the line has no nofail, so these are errors that would break the boot. sudo mount /mnt/data looks up the source, type, and options in /etc/fstab.

$ cp /etc/fstab bad-fstab
$ echo "UUID=0000-1111 /mnt/backup ext5 defaults 0 2" >> bad-fstab
$ sudo findmnt --verify --tab-file bad-fstab

0 parse errors, 2 errors, 0 warnings
/mnt/backup
   [E] unreachable on boot required target: No such file or directory
   [E] unreachable on boot required source: UUID=0000-1111
$ sudo umount /mnt/data
$ sudo mount /mnt/data
$ findmnt -n -o SOURCE /mnt/data
/dev/vdb1

FAT file systems and USB sticks

FAT file systems, used on USB sticks and SD cards, do not store Unix owners and permissions. They are set for the whole file system by mount options.

sudo mkfs.vfat -n USBSTICK /dev/vdc
sudo mkdir /mnt/usb
sudo mount /dev/vdc /mnt/usb
touch /mnt/usb/photo.jpg
ls -ld /mnt/usb
sudo umount /mnt/usb
sudo mount -o uid=jano,gid=jano,umask=022 /dev/vdc /mnt/usb
touch /mnt/usb/photo.jpg
ls -l /mnt/usb
chmod 600 /mnt/usb/photo.jpg
ls -l /mnt/usb

Like many USB sticks, the disk is formatted as a whole, without a partition table. Mounted by root without options, every file belongs to root. The uid, gid, and umask options make all files belong to jano with permissions 755 (FAT has no execute bit, so all files look executable). chmod reports success but changes nothing, because there is nowhere to store the permissions. Desktop environments mount USB sticks automatically under /media/USER with such options.

$ sudo mkfs.vfat -n USBSTICK /dev/vdc
mkfs.fat 4.2 (2021-01-31)
$ sudo mkdir /mnt/usb
$ sudo mount /dev/vdc /mnt/usb
$ touch /mnt/usb/photo.jpg
touch: cannot touch '/mnt/usb/photo.jpg': Permission denied
$ ls -ld /mnt/usb
drwxr-xr-x 2 root root 4096 Jan  1  1970 /mnt/usb
$ sudo umount /mnt/usb
$ sudo mount -o uid=jano,gid=jano,umask=022 /dev/vdc /mnt/usb
$ touch /mnt/usb/photo.jpg
$ ls -l /mnt/usb
total 0
-rwxr-xr-x 1 jano jano 0 Oct 24 21:45 photo.jpg
$ chmod 600 /mnt/usb/photo.jpg
$ ls -l /mnt/usb
total 0
-rwxr-xr-x 1 jano jano 0 Oct 24 21:45 photo.jpg

Mounting disk images

A file that contains a file system can be mounted through a loop device, which makes a file look like a block device.

truncate -s 100M disk.img
/sbin/mkfs.ext4 -q -L imagefs disk.img
sudo mkdir /mnt/img
sudo mount disk.img /mnt/img
sudo losetup -l
lsblk -f /dev/loop0
sudo umount /mnt/img
sudo losetup -l

mkfs.ext4 works on a regular file as well. When given a file instead of a device, mount sets up a loop device automatically. losetup -l shows the loop device and its backing file; AUTOCLEAR means that the loop device is released on unmount, as the second, empty listing shows. Disk images of virtual machines and downloaded installer images are mounted the same way.

$ truncate -s 100M disk.img
$ /sbin/mkfs.ext4 -q -L imagefs disk.img
$ sudo mkdir /mnt/img
$ sudo mount disk.img /mnt/img
$ sudo losetup -l
NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE                DIO LOG-SEC
/dev/loop0         0      0         1  0 /home/jano/work/disk.img   0     512
$ lsblk -f /dev/loop0
NAME  FSTYPE FSVER LABEL   UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
loop0 ext4   1.0   imagefs f9e83334-e10b-4c2e-b0d3-aa5d4b116553   81.2M     0% /mnt/img
$ sudo umount /mnt/img
$ sudo losetup -l

Mounting a CD or ISO image

ISO 9660 file systems on CDs, DVDs, and ISO images are read-only.

sudo mkdir /mnt/cdrom
sudo mount /dev/sr0 /mnt/cdrom
ls -l /mnt/cdrom
cat /mnt/cdrom/meta-data
sudo umount /mnt/cdrom

mount notices that the medium is write-protected and mounts it read-only, with a warning. This CD carries the configuration that cloud-init used to set up the virtual machine. An ISO file is mounted with sudo mount file.iso /mnt/cdrom.

$ sudo mkdir /mnt/cdrom
$ sudo mount /dev/sr0 /mnt/cdrom
mount: /mnt/cdrom: WARNING: source write-protected, mounted read-only.
$ ls -l /mnt/cdrom
total 1
-rw-r--r-- 1 root root  42 Oct 24 21:45 meta-data
-rw-r--r-- 1 root root 492 Oct 24 21:45 user-data
$ cat /mnt/cdrom/meta-data
instance-id: zc-box-1
local-hostname: box
$ sudo umount /mnt/cdrom

tmpfs and hidden files

A tmpfs file system lives in memory. Mounting anything on a directory hides the directory's previous contents until the file system is unmounted.

sudo mkdir /mnt/scratch
sudo touch /mnt/scratch/hidden.txt
sudo mount -t tmpfs -o size=64M,mode=1777 tmpfs /mnt/scratch
ls -la /mnt/scratch
df -h /mnt/scratch
sudo umount /mnt/scratch
ls /mnt/scratch

The source name tmpfs is arbitrary, since there is no device. size limits the memory the file system may use, and mode=1777 makes it writable for everyone with the sticky bit, like /tmp. While the tmpfs was mounted, hidden.txt was invisible; it reappeared after the unmount. Files hidden under a mount point still take disk space, which sometimes explains why du and df disagree.

$ sudo mkdir /mnt/scratch
$ sudo touch /mnt/scratch/hidden.txt
$ sudo mount -t tmpfs -o size=64M,mode=1777 tmpfs /mnt/scratch
$ ls -la /mnt/scratch
total 4
drwxrwxrwt 2 root root   40 Oct 24 21:45 .
drwxr-xr-x 7 root root 4096 Oct 24 21:45 ..
$ df -h /mnt/scratch
Filesystem      Size  Used Avail Use% Mounted on
tmpfs            64M     0   64M   0% /mnt/scratch
$ sudo umount /mnt/scratch
$ ls /mnt/scratch
hidden.txt

Bind mounts

A bind mount makes a directory visible at a second place in the tree, optionally with different options.

sudo mkdir -p /srv/www
sudo mount --bind /mnt/data/projects /srv/www
ls /srv/www
findmnt /srv/www
sudo mount -o remount,bind,ro /srv/www
touch /srv/www/new.txt
touch /mnt/data/projects/new.txt
ls /srv/www

findmnt shows the source as /dev/vdb1[/projects], a subdirectory of the file system. After the remount, the view in /srv/www is read-only, while the original directory stays writable, and new files appear in both places. Containers use bind mounts to share host directories.

$ sudo mkdir -p /srv/www
$ sudo mount --bind /mnt/data/projects /srv/www
$ ls /srv/www
hello.sh
notes.txt
todo.txt
$ findmnt /srv/www
TARGET   SOURCE               FSTYPE OPTIONS
/srv/www /dev/vdb1[/projects] ext4   rw,relatime
$ sudo mount -o remount,bind,ro /srv/www
$ touch /srv/www/new.txt
touch: cannot touch '/srv/www/new.txt': Read-only file system
$ touch /mnt/data/projects/new.txt
$ ls /srv/www
hello.sh
new.txt
notes.txt
todo.txt

After a reboot

We reboot the machine and check which mounts are back.

uptime -p
findmnt /mnt/data
findmnt /srv/www; echo $?
systemctl status mnt-data.mount --no-pager

The file system from /etc/fstab was mounted at boot; the bind mount, made only with the mount command, is gone. A bind mount can be made permanent with an fstab line such as /mnt/data/projects /srv/www none bind 0 0. systemd turned the fstab entry into the unit mnt-data.mount, named after the mount point.

$ uptime -p
up 0 minutes
$ findmnt /mnt/data
TARGET    SOURCE    FSTYPE OPTIONS
/mnt/data /dev/vdb1 ext4   rw,relatime
$ findmnt /srv/www; echo $?
1
$ systemctl status mnt-data.mount --no-pager
● mnt-data.mount - /mnt/data
     Loaded: loaded (/etc/fstab; generated)
     Active: active (mounted) since Sat 2026-10-24 21:45:44 CEST; 7s ago
      Where: /mnt/data
       What: /dev/vdb1
       Docs: man:fstab(5)
             man:systemd-fstab-generator(8)
      Tasks: 0 (limit: 1743)
     Memory: 32.0K
        CPU: 3ms
     CGroup: /system.slice/mnt-data.mount

Oct 24 21:45:44 box systemd[1]: Mounting mnt-data.mount - /mnt/data...
Oct 24 21:45:44 box systemd[1]: Mounted mnt-data.mount - /mnt/data.

Best practices

Source

mount(8), lsblk(8), findmnt(8), fstab(5)

In this article, we have listed block devices with lsblk and blkid, partitioned and formatted a new disk, mounted and unmounted file systems, used mount options, made a mount permanent in /etc/fstab, and mounted FAT disks, disk images, ISO images, tmpfs, and bind mounts. See also the df, du, and lsof articles.

Author

I am Jan Bodnar, a programmer and technical writer. I have been writing programming tutorials at ZetCode since 2007 and have published eight e-books. See about the author.

List all Linux tutorials.