Score:2

Accidentally moved a single folder from root, now can't boot anymore

cn flag

What happened:

I used a program with a really bad GUI file picker and as I tried to traverse the file system, I accidentally hit the "back" button on the side of the mouse which seemingly acted like a regular left mouse click that caused me to move a folder high up in the file system into another folder. I either moved a folder from root into anoter subfolder of root (e.g. moved /A into /B) or a folder from a subfolder from root into a sub-sub-folder (e.g. moved /A/B into /A/C). I also recall that this mistake likely happened near or in the /usr folder.

Problem:

Immediately after this mistake, all icons in Gnome were gone (although applications I had open seemed to work fine) and as I tried to open a shell to try to revert my mistake, it wouldn't open anymore (the click animation played, but no window opened). I restarted the system and after some wall of text that was too quick for me to read (it was the typical checklist-style wall of text) I was greeted with a white text on black background message reading:

/dev/nvme0n1p5: recovering journal
/dev/nvme0n1p5: clean, 897720/12004096 files, 21338613/51200000

I waited for some time but nothing really happened after that.

What I tried so far (using Grub's recovery root shell):

  1. I compared my / folder with that mentioned on the official Ubuntu website: https://help.ubuntu.com/lts/installation-guide/armhf/apcs02.html. My root folder is a superset of all folders mentioned on that website. Specifically, it contains:

    bin, boot, cdrom, dev, etc, home, lib, lib32, lib64, libx32, lost+found, media, mnt, opt, proc, root, run, sbin, snap, srv, swapfile, sys, tmp, usr, var

    My /usr folder contains: bin, games, include, lib, lib32, lin64, libexec, libx32, local, sbin, src

  2. I tried to find out which folders where edited roughly at the same time the error happened. For that, I executed ls -l and unfortunately no folder seemed to have a time matching that of the mistake.

  3. I read up online, most people recommend to somehow (Grub Recovery mode or via Live-CD) open a root shell and then do: fsck -f /. Those posts try to also fix the recovering journal issue, but theirs was caused by e.g. a power outage causing files to be corrupted. I refrained from trying that as I don't think the underlying file system is broken, I just moved a folder in the wrong spot.

Question:

How shall I proceed? If I could find out which folder I had moved, I could easily revert my mistake


Update 1:

System information:

  • Distro: Ubuntu 20.4.?. Unfortunately, running lsb_release in recovery mode gives a ModuleNotFound error, with the traceback ending in apt_pkg.Error: E: Error reading the CPU table, so I can't tell you which exact version.

  • Kernel: 5.4.0-81-generic

I ran fsck -f /dev/nvme0n1p5 from a USB drive as suggested, that yielded the following output:

ubuntu@ubuntu:~$ sudo fsck -f /dev/nvme0n1p5
fsck from util-linux 2.34
e2fsck 1.45.5 (07-Jan-2020)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/nvme0n1p5: 897720/12804096 files (0.4% non-contiguous), 21338886/51200000 blocks

Note the number of files and blocks checked is exactly the same as in the printout I get when just booting directly into Ubuntu

jpbrain avatar
ca flag
yes you can, but do the changes booting from a live pendrive...
guiverc avatar
cn flag
You've provided no OS & release details; however a GUI file-browser does not have permissions to do what you're asking for under Ubuntu, so what OS are you asking about? A GUI browser should only have access to directories in $HOME which will not impact the system boot.
hr flag
I wonder if `dpkg -C` (or `dpkg --audit`) might be helpful in identifying what was moved?
mook765 avatar
cn flag
I don't see `/usr/share` in your list.
iMrFelix avatar
cn flag
@guiverc Sorry I was not explicit on the system, I added the information. I agree with you that the application (MeshLab, a 3D viewer) doesn't have write access outside the `$HOME` directory and therefore isn't able to perform such modifications. Nevertheless, the problem appeared right when I used the file picker.
iMrFelix avatar
cn flag
@steeldriver running either command in Grub's recovery root shell doesn't produce any output
iMrFelix avatar
cn flag
@mook765 You just saved me! That indeed did the trick, my machine booted up like normal! Is there a principled way of discovering that to be the problem?
mook765 avatar
cn flag
If everything works normal I'd tend to say we found the culprit...
iMrFelix avatar
cn flag
Indeed, everything's back to normal!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.