DevOps · K8s · Volleyball · Travel  •  DevOps · K8s · Volleyball · Travel  •  DevOps · K8s · Volleyball · Travel
Explore NY Stream

Block device XXXX is write protected, Error while mounting samba on linux

— ny_wk

Block device XXXX is write protected, Error while mounting samba on linux

The "block device is write protected, mounting read-only" error when mounting a Samba share on Linux almost always means the cifs-utils package is missing, not that your disk is actually locked. Install cifs-utils with your package manager and the mount -t cifs command will succeed normally.

What the "block device is write protected" Samba error really means

When you try to mount a Windows or Samba share and the kernel cannot find a working CIFS/SMB filesystem helper, the mount command silently falls back to treating your share path as if it were a raw block device. Because it cannot write to that pseudo-device, it prints a confusing message:

mount: block device //server/share is write-protected, mounting read-only

This message is misleading. Your network share is not write-protected, and there is no failing hard disk. The real problem is that the cifs-utils package, which provides the mount.cifs helper that mount -t cifs depends on, is not installed. Without it, the kernel has no way to speak the SMB protocol, so the mount either fails or degrades to a useless read-only fallback.

The solution: install cifs-utils to fix the Samba mount error

The fix is to install the cifs-utils package, then re-run the mount command. The package is available in the default repositories of every major distribution. Pick the command that matches your system.

Red Hat, CentOS, Rocky Linux, AlmaLinux, Fedora

On modern RHEL-family systems use dnf (older releases use yum, which still works as an alias):

  1. Install the package as root: sudo dnf install cifs-utils
  2. On legacy systems (RHEL/CentOS 7 and earlier): sudo yum install cifs-utils

Debian, Ubuntu, Linux Mint

On Debian-based systems update the package index first, then install:

  1. Refresh the index: sudo apt update
  2. Install the package: sudo apt install cifs-utils

SUSE / openSUSE

Use zypper: sudo zypper install cifs-utils

Arch Linux

Use pacman: sudo pacman -S cifs-utils

Installing from a local RPM file

If the machine has no internet access but you have the RPM, you can install it directly. Note that rpm -ivh does not resolve dependencies, so prefer dnf install ./file.rpm when possible:

  1. Direct RPM install: sudo rpm -ivh cifs-utils-*.rpm
  2. Dependency-aware local install (recommended): sudo dnf install ./cifs-utils-*.rpm

Step-by-step: mount a Samba share correctly

Once cifs-utils is installed, mounting becomes straightforward. The example below mounts a share called data on a server at 192.168.1.10 to the local directory /mnt/share.

  1. Create a mount point if it does not already exist: sudo mkdir -p /mnt/share
  2. Mount the share, supplying the remote username: sudo mount -t cifs //192.168.1.10/data /mnt/share -o username=youruser
  3. Enter the share password when prompted.
  4. Confirm it mounted: df -h /mnt/share or mount | grep cifs

If your server requires a newer protocol version, add vers=3.0 (or vers=2.1) to the options. Modern Samba and Windows servers reject the insecure SMBv1 protocol, so an explicit version is often required:

sudo mount -t cifs //192.168.1.10/data /mnt/share -o username=youruser,vers=3.0

Using a credentials file instead of a plaintext password

Putting a password directly on the command line or in /etc/fstab exposes it to anyone who can read the file or the process list. A dedicated credentials file is the safe, standard approach.

  1. Create the file: sudo nano /etc/samba/cred-data
  2. Add three lines:
    • username=youruser
    • password=yourpassword
    • domain=WORKGROUP
  3. Lock down its permissions so only root can read it: sudo chmod 600 /etc/samba/cred-data
  4. Mount using the file: sudo mount -t cifs //192.168.1.10/data /mnt/share -o credentials=/etc/samba/cred-data,vers=3.0

Making the mount persist across reboots with /etc/fstab

A manual mount disappears after a reboot. To make it permanent, add an entry to /etc/fstab. Always test the mount manually first so you do not create a line that blocks boot.

  1. Edit the file: sudo nano /etc/fstab
  2. Add a single line (one entry, space- or tab-separated):
    //192.168.1.10/data /mnt/share cifs credentials=/etc/samba/cred-data,vers=3.0,_netdev,nofail 0 0
  3. Reload systemd and test without rebooting: sudo systemctl daemon-reload then sudo mount -a

The _netdev option tells systemd to wait for the network before mounting, and nofail prevents a missing share from stalling the boot process. These two flags are essential for network mounts on servers.

Choosing the right SMB protocol version

The vers= option controls which dialect of the SMB protocol the client negotiates with the server. Picking the wrong one is the second most common cause of a failed mount after the missing package. SMBv1 (the original CIFS dialect) has well-known security flaws and was the vector for the WannaCry ransomware outbreak, so it is disabled by default on current Windows and Samba builds. You should never re-enable it just to make a mount work.

OptionProtocolWhen to use it
vers=3.1.1SMB 3.1.1Windows 10/11, Windows Server 2016+, Samba 4.x. Best security and performance.
vers=3.0SMB 3.0Windows 8/Server 2012 and most modern NAS devices. A safe default.
vers=2.1SMB 2.1Windows 7/Server 2008 R2 and older appliances.
vers=1.0SMB 1.0 (CIFS)Legacy only and insecure. Avoid; upgrade the server instead.

If you omit vers= entirely, recent kernels auto-negotiate the highest mutually supported version, which usually works. Specify it explicitly only when auto-negotiation fails or when you need to pin a version for compatibility with an old appliance.

Decoding common cifs mount error codes

When a mount fails, mount.cifs returns a numeric error code. Matching the number to its cause saves a great deal of guesswork. The table below maps the codes you are most likely to encounter to their real fix.

ErrorMeaningFix
block device write-protectedcifs-utils missingInstall cifs-utils.
mount error(2)No such file or directoryThe share name is wrong or does not exist on the server.
mount error(13)Permission deniedBad username, password, or domain. Check the credentials file.
mount error(112)Host is downSMBv1 disabled on server. Add vers=3.0.
mount error(115)Operation now in progressFirewall is blocking TCP port 445, or the server is unreachable.
mount error(22)Invalid argumentA malformed option, often a typo in the -o list or an unsupported vers.

If you get mount error(115), confirm the network path before touching mount options: ping 192.168.1.10 to check reachability, then test the SMB port directly with nc -vz 192.168.1.10 445. A blocked port 445 is a firewall issue on either end, not a Linux client problem.

Common pitfalls and how to avoid them

  • Forgetting cifs-utils on a fresh server. Minimal installs of RHEL, Rocky, and Ubuntu Server ship without it. This single missing package is the root cause of the write-protected message.
  • Using SMBv1. If you see mount error(112): Host is down, the server has disabled the legacy SMBv1 protocol. Fix it by adding vers=3.0 rather than re-enabling the insecure version.
  • Permission denied (error 13). This is a credentials problem, not a package problem. Recheck the username, password, and domain= value, and confirm the user has share-level access on the server.
  • Wrong slashes. The UNC path uses forward slashes on Linux: //server/share, not the Windows backslash form.
  • Mismatched UID/GID. If mounted files appear owned by root and a normal user cannot write, add uid=1000,gid=1000 (matching your user) to the mount options.
  • SELinux blocking access. On RHEL-family systems, set sudo setsebool -P use_samba_home_dirs on or apply the appropriate boolean if access is denied despite correct credentials.

Verification: confirm the mount is working

After installing the package and mounting, verify everything is healthy with a few quick checks:

  • Confirm the helper binary now exists: which mount.cifs should return a path such as /usr/sbin/mount.cifs.
  • Confirm the share is mounted as a CIFS filesystem: mount | grep cifs should list it with type cifs and not show ro (read-only) unless you intended it.
  • Test write access: touch /mnt/share/testfile && rm /mnt/share/testfile. If this succeeds, the earlier "write-protected" symptom is fully resolved.
  • Check capacity and usage: df -h /mnt/share.

If touch succeeds without error, the misleading write-protected message is gone for good, because the share is now mounted through the proper CIFS driver instead of the failed block-device fallback.

Why this error is so commonly misdiagnosed

The wording "block device is write-protected" sends administrators down the wrong path: they check disk health, run fsck, or inspect physical media. None of that is relevant here. The phrase comes from mount's generic fallback logic, which has nothing to do with your actual storage. Recognizing that the message is a symptom of a missing cifs-utils helper turns a frustrating dead end into a one-command fix.

Key Takeaways

  • The "block device is write protected" Samba error on Linux is caused by a missing cifs-utils package, not by a real disk fault.
  • Install it with dnf install cifs-utils, yum install cifs-utils, or apt install cifs-utils depending on your distribution.
  • Add vers=3.0 to your mount options because modern servers reject the insecure SMBv1 protocol.
  • Use a chmod 600 credentials file instead of plaintext passwords, and add _netdev,nofail for safe /etc/fstab entries.
  • Verify the fix with which mount.cifs, mount | grep cifs, and a quick touch write test.

Frequently Asked Questions

Is my hard drive really write-protected when I see this Samba error?

No. Your local disk and the remote share are fine. The message is a misleading fallback that mount prints when it cannot load the CIFS filesystem helper. Installing cifs-utils resolves it.

What is the difference between cifs-utils and Samba?

The samba package turns your machine into a file server that shares folders. The cifs-utils package is the client tooling that lets your machine mount shares hosted elsewhere. To mount a remote share you only need cifs-utils.

Why does my mount fail with "Host is down" even after installing cifs-utils?

That error usually means the server has disabled the old SMBv1 protocol for security. Add an explicit protocol version to your options, for example -o vers=3.0, and the mount will negotiate a supported version.

How do I unmount a CIFS share safely?

Run sudo umount /mnt/share. If it reports the target is busy, close any programs or shells using the directory, or run sudo umount -l /mnt/share for a lazy unmount that detaches it once it is no longer in use.

For more Linux administration walkthroughs and troubleshooting guides, subscribe to YouTube @explorenystream.