Removed hard drive without unmounting, now it won't re-mount to original path where user data sits

I stupidly unplugged my external hard drive (containing the user data folder) from my Pi without first unmounting.

Without the hard drive being mounted, the drive manager still displays the user data path as it was when the hard drive was connected. Therefore, when I try to remount the drive the path conflicts as it interprets the path to already be in use (see screenshots below).

  1. Hard drive detected but not mounted




2. Attempting to mount hard drive to it’s automatically assigned path




3. Cannot mount as it conflicts with already assigned user data path




I can mount it by giving it a new custom path, however I can’t transfer the user data across to the drive as it obviously can’t connect to what it thinks is the current user data location.

Am I able to manually edit the user data location path? I’m guessing it’s located in a text file somewhere. That way I can re-mount my hard drive to a custom path and then edit the user data location to match, hopefully solving my issue.

I’d like to avoid a clean install if possible. Any tips appreciated!

You might need run fsck on the device and see if drive might be borked up and fix it

https://www.thegeekstuff.com/2012/08/fsck-command-examples

Ah wait…use the check & repair option right below the mount option

Jep fsck makes sense anyway and can only be done before mounting.

But the issue itself is the still existing mount location folder. Just remove it, it should be empty.

rmdir /mnt/38EA0C5AEA0C1732

The command throws an error, if the folder is not empty. In case check the content, but as it is drive mount target, it should be empty.

Alternatively you can mount the drive manually:

mount /dev/sda2 /mnt/38EA0C5AEA0C1732

Afterwards start dietpi-drive_manager to let it (re)write the mount to fstab (so it is mounted automatically on boot).

This is a dietpi-drive_manager specific issue. When you unmount a drive via drive manager, it removes the mount point directory. If you don’t unmount it, or use umount directly from terminal, the dir stays in place. For accident prevention, drive manager just allows to mount to non-existing folders and pre-creates them in case.

To have this handier, I will add the option to ignore folder existence and mount the drive anyway, if the folder is empty at least. If the folder is not empty, you will have the option (with big warning that you should know what you do!) to backup the existing folder+content to allow the drive mount.

€: I opened a feature request on GitHub, so will be not forgotten and bring it to Fourdees attention as well: https://github.com/Fourdee/DietPi/issues/2056
Should make it into v6.15 :slight_smile:.

Thanks WarHawk and MichaIng for your help! I actually ended up doing a fresh install the next morning as after further tinkering I thought it might be a lost cause. Thanks for raising a ticket about this. I’ll be sure to bookmark this for future reference (though hopefully I won’t need it!).