Folders under /var/lib missing

Hi all,

I have an installation of OSMC on Rapberri PI2, with Owncloud and Mysql, SSH and all the hardening suggestions. All was working fine and yesterday my 1 year old son “played” with the power supply, I had to hard reboot, then MySql didn´t start. Apache was running but, since mysql was KO, Owncloud was not up.

Also “sudo apt-get update” failed

Hit http://download.opensuse.org  Packages
Ign http://download.opensuse.org  Translation-en
Fetched 735 kB in 15s (46.2 kB/s)
Reading package lists... Error!
W: GPG error: http://download.opensuse.org  Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4ABE1AC7557BEFF9
E: Could not open file /var/lib/dpkg/status - open (2: No such file or directory)
E: The package lists or status file could not be parsed or opened.

After searching with systemctl what did it happen, also a samba mount on fstab failed. I kept on with the search and seems that, some folders under /var/lib are missing.
I just have an micro-sd card
I tryed to verify the sd with fsck and the disk /dev/mmcblk0p1 (/boot) had a dirty byte that I could finally clean.

/dev/mmcblk0p2 (/) was supposed to be fine (after unmounting in single user).

Any one had the same mysterious disappearance of files? Maybe I´m wrong and my son doesn´t have these files destruction skills and comes from another issue with the overall configuration… I´m lost and seems to me I´ll have to reinstall everything.
Is there any opportunity that I don´t need to?

This is the current contents of /var/lib

osmc@papaFrita:/var/lib$ ls -al
total 24
drwxr-xr-x  6 root root 4096 Jan 26 09:32 .
drwxr-xr-x 12 root root 4096 Jan 20 14:51 ..
drwxr-xr-x  3 root root 4096 Jan 25 23:50 apt
drwxr-xr-x  3 root root 4096 Jan 26 00:53 connman
drwx------  2 root root 4096 Jan 20 14:51 container
drwxr-xr-x  4 root root 4096 Jan 20 14:51 systemd

I also think it is too empty.

If anyone can provide some light to this issue I´d really appreciate.

Thanks in advance.

That does indeed sound like a nasty card corruption to me. :disappointed:

When I first set up my RPi and had to hard reboot after system crashs, it trashed two cards within two months. One of the cards also had no reported errors with fsck, still serveral files were broken. The conclusion is, I can only strongly recommend to move the root partition to a usb stick or hdd. These appear to be much more robust to removed power than SD cards.

If you do not have a recent back up to revert to, you could at least try to get by the GPG error in “apt-get update” by installing the missing certificate (although you actually should not need to do this in the first place):

gpg --keyserver pgpkeys.mit.edu --recv-key  4ABE1AC7557BEFF9
gpg -a --export 4ABE1AC7557BEFF9 | sudo apt-key add -

If more gpg errors occur just repeat with the reported missing keys.

But that will most likely only take you from one error to the next. I fear the system is beyond repair. If you do reinstall from scratch do not forget to “dd” your root partition after everything is set up for having an emergency back up in the future.

Thanks a lot!

Totally expected but, you know, never loose the hope in the answer about that magic command that does the job like

$sudo magic-command -save time&effort

Maybe next time :grin:

1 Like

If you have lost your dpkg status file then OSMC no longer knows what packages you have and which versions they’re at.

You should reinstall

Sam

That command actually does exist!

dd if=your-backup-img of=your-root-partition bs=1M

Cloning an image from root every couple weeks only takes ~10 sec of typing and in a situation like this will save you many hours of work. :grinning:

I had to learn it the hard way, but seriously backups can save your day. Also good if you want to try that new setting/software from an unknown author.

Thanks again for your answers.

dd will be a friend from now on.