Updated: October 13, 2018
The issue you facing is as follows: you are trying to mount a partition on the command line. You've done this a thousand times before. Only now, for some odd reason, the system informs you that the particular partition you're trying to use is already mounted or mount point busy. This is an annoying and unexpected error.
I've encountered this issue while merrily testing OpenSUSE Leap 15. I wanted to check the contents of two specific partitions, in order to figure out which one was which - two different distros, and one had to be sacrificed for the upcoming openSUSE installation. But the installation wizard didn't have any labels, so I had to manually mount. Except I could not do this. I decided to explore the issue in more detail, and so this tutorial was born. After me.
Problem in more detail
You are trying to perform some kind of maintenance on your disks and partitions. To that end, you need to manually mount a device, e.g. inspect the folder hierarchy or permissions, copy files, search for a file, etc. But you cannot do this, because you get an error like:
mount /dev/sda7 /mnt
mount: /mnt: /dev/sda7 already mounted or mount point busy.
If you check with the commands like mount and df -l, you can see that the specific partition is NOT mounted, but something is holding it. Then, on further inspection, you also notice that the fdisk command returns a different notation to what you expect, something like:
/dev/mapper/vendor-ser-part1 4094 625141035
625136942 298.1G 5 Ext
/dev/mapper/vendor-ser-part5 4096 8392703 8388608 4G 82 Lin
/dev/mapper/vendor-ser-part6 8394752 417994751 409600000 195.3G 83 Lin
/dev/mapper/vendor-ser-part7 * 417996800 520397190 102400391 48.8G 83 Lin
/dev/mapper/vendor-ser-part8 520398848 625141035 104742188 50G 83 Lin
Instead of /dev/sdXY, you get something called /dev/mapper and the disks are listed with vendor/manufacturer, followed by serial number, followed by partition number.
The reason for this notation is because the operating system uses the device mapper, which maps the underlying physical devices into a higher-level hierarchy, like LVM, software RAID and disk encryption, as well as snapshots. If you're using openSUSE with BTRFS, this makes sense, as BTRFS has a snapshotting capability.
But if you are NOT using any of the above on your PHYSICAL DEVICES, you do not need the device mapping functionality. We need to fix this somehow.
So what I'm going to show you is how to restore your "classic" functionality. Please note that we will use the dmsetup command, which is a low-level LVM utility. We will remove the mapped devices, and this will allow you to utilize your disks as you expect.
We will not disable the kernel module, though. You may at some point want to use encryption or LVM, but not necessarily with your system disk (or any other specific device). This means we will not be running intrusive or destructive operations. Still, before we move on, a quick checklist:
- The device or the mountpoint you're trying to access is not in use (check with mount, df, lsof).
- You are not using BTRFS on the affected disks/partitions.
- You are not using LVM or software RAID on the affected disks/partitions.
- You are not using encryption (system or home) on the affected disks/partitions.
Now, we can safely remove the devices. First, list the devices:
Then, one by one, let's remove them:
dmsetup remove TOSHIBA_MK3252GSX_98G3C0HBT-part8
dmsetup remove TOSHIBA_MK3252GSX_98G3C0HBT-part7
Once the dmsetup command returns an empty list, you're good to go. Problem solved.
Please also take a look at the following guides:
There you go. You can safely perform these actions without any damage or data loss if you are not using LVM volumes. If you are, then you need to figure out why you're using them, and then use the relevant commands to examine the disk and partition contents (vg*, lv* tools), mount the mapped devices directly, or explore them through the existing mount points, if possible. But that's a separate topic.
We gathered here to work around an unexpected issue. If you are using advanced storage options, you will probably not be reading this. But if you're merely looking for simple ways to access and explore your partitions, and this little guide gives you the tools to do that. Once again, please be careful, don't do any hasty actions, and make sure you know exactly what you're doing with your disks. Backups, right! And we're done.