Technical Anshu
Tutorials Blog
Ubuntu Basics

Unmount a Windows Share in Ubuntu Without Breaking Anything

Mounting gets all the attention, but shares are usually broken at the other end of the day - a laptop closed mid-copy, a Windows PC switched off under a live mount, a folder yanked away from a program using it. Unmounting properly is a thirty-second habit that prevents the weird errors.

Technical AnshuUbuntu and WindowsStep-by-step guide
Watch the video for the complete process shown live, step-by-step

A mounted share is a live connection between two machines, with your programs potentially holding files open across it. Ending it cleanly is part of the skill: close what is using it, run one command, and confirm it let go. This page covers the clean way, the honest way to handle the famous target is busy refusal, the lazy unmount that exists for emergencies and deserves its bad reputation when used casually, and - for a share that is gone for good - how to retire the fstab entry and its credentials so nothing tries to mount a ghost at every boot.

Terminal - clean unmount and the busy refusal (example output)
$ sudo umount /mnt/SharedDocs $ mount | grep cifs (no output - the share has let go)
When something is still holding it
$ sudo umount /mnt/SharedDocs umount: /mnt/SharedDocs: target is busy.
✓ Busy is information, not defiance - a program, or your own terminal, is standing in the folder
Example output. The empty grep result after a successful umount is the confirmation to look for - no output means no CIFS mounts remain.
1

Step 1 - The Clean Unmount, In Order

Thirty seconds, three moves.

  1. Close the programs using the share - editors with files open from it, players, the file manager window showing it, and any terminal whose current folder is inside it
  2. Move your terminal out of the share if it is in there: cd ~
  3. Run: sudo umount /mnt/SharedDocs
  4. Confirm it released: mount | grep cifs should show nothing for that share, and the mount-point folder should look empty again - empty here means disconnected, not deleted; the files are safe on the Windows PC
2

Step 2 - Target Is Busy - Find Who Is Holding the Folder

The busy message is the kernel protecting open files. Do not reach for force first - find the holder; it is embarrassingly often you.

  1. List what is using the mount: sudo fuser -vm /mnt/SharedDocs shows the processes with files or folders open under it, including terminals sitting in a directory there
  2. Alternatively: sudo lsof /mnt/SharedDocs lists the open files themselves
  3. Close or move those things properly - save the document, close the player, cd the stray terminal out - then repeat the plain sudo umount /mnt/SharedDocs
  4. A forgotten terminal in the folder is the number one cause; check your own windows before suspecting any software
3

Step 3 - The Lazy Unmount - a Labelled Last Resort

Sometimes the holder cannot be closed - the Windows PC already crashed or was switched off, and every access to the folder hangs. The lazy unmount exists for exactly this: sudo umount -l /mnt/SharedDocs detaches the folder from your directory tree immediately and finishes the real cleanup whenever the holders finally release it.

  1. Understand the risk honestly: a program still writing when you lazy-unmount can lose or corrupt that write, because the floor vanished mid-save. It is a rescue tool, not a shortcut
  2. For a server that has gone away entirely, sudo umount -f /mnt/SharedDocs forces the issue - same warning, stronger hand
  3. After a lazy or forced unmount, treat any file that was mid-edit as suspect and check it on the server side
4

Step 4 - Retiring a Share for Good

When the Windows PC is replaced or the folder unshared, retire the configuration or every boot will keep trying to mount a ghost.

  1. Unmount it if mounted: sudo umount /mnt/SharedDocs
  2. Open sudo nano /etc/fstab and delete the share's line - or comment it with a # if there is any chance of return. If the line was an automount, this also removes the on-demand trigger
  3. Refresh: sudo systemctl daemon-reload
  4. Remove the now-pointless mount point if you created it only for this: sudo rmdir /mnt/SharedDocs - it succeeds only when empty, which is the safety check built in
  5. Delete its credentials file if the account is used nowhere else: sudo rm /root/.smbcredentials - a stored password for a dead share is pure leftover risk
  6. And complete the job on the Windows side: stop sharing the folder there too, so the network stops offering it
🔴 Do you need to unmount before shutting Ubuntu down? No - a normal shutdown unmounts everything in order as part of going down. Manual unmounting matters at three other moments: before the Windows PC or the network goes away, before you declare a mount fixed and test it fresh, and when a share is being retired. Learn it for those, not as a daily ritual.

Watch the Complete Video Guide

Watch the video for the mounting side of this pair - a clean setup makes every unmount and removal this page describes equally uneventful.

Watch Full Video
Common Questions (FAQ)

I unmounted the share but it came back by itself. Is something wrong?

No - if your fstab line uses automount, opening the folder is supposed to remount it; that is the feature working. To stop it, you stop the automount behaviour: comment or remove the fstab line and run systemctl daemon-reload. A plain boot-time mount, by contrast, never returns on its own after umount until the next reboot or mount command.

Can I unmount without sudo?

Only when the mount was set up for it - an fstab entry carrying the user option lets that user mount and unmount it themselves. The permanent mounts in this series are created by root at boot and are root's to release. On your own machine the sudo prompt is a small price; on a shared machine it is the correct boundary.

The folder shows empty after unmounting. Did I delete the shared files?

No. The mount point is just a window: mounted, you see the share through it; unmounted, you see the empty local folder that was always underneath. The files never lived in that folder - they live on the Windows PC and are untouched. Remount and they will all be exactly where they were.

This guide is based on the Technical Anshu video on mounting a Windows share in Ubuntu - stuck on any step, ask in the video comments and you will get an answer.