Error: database disk image is malformed

Mecanik

Well-Known Member
Mar 2, 2017
173
5
58
33
Following up my previous thread ( which has no solution at the moment ), I started searching what actually failed in my attempt to create clustering with running virtual machines.

Commands run adn output:

Code:
root@xxxxx:~# sqlite3 /var/lib/pve-cluster/config.db
SQLite version 3.8.7.1 2014-10-29 13:59:56
Enter ".help" for usage hints.
sqlite> .databases
seq  name             file
---  ---------------  ----------------------------------------------------------
0    main             /var/lib/pve-cluster/config.db
sqlite> .tables
tree
sqlite> .headers on
sqlite> select * from tree;

And the error is: "Error: database disk image is malformed"

So I run:
Code:
sqlite> PRAGMA integrity_check;

And the result is:

Code:
integrity_check
*** in database main ***
On tree page 25 cell 1: Rowid 8160904 out of order (previous was 8160915)
On tree page 25 cell 1: 2nd reference to page 85
Page 21 is never used

Is someone which has experienced this issue, can provide me a solution before I try fixing it myself, I would really appreciate it.
 
I fixed this issue with the following:

sqlite> .mode insert
sqlite> .output config.sql
sqlite> .dump
sqlite> .exit

root@xxxxx:~# mv /var/lib/pve-cluster/config.db config.db.original
root@xxxxx:~# sqlite3 /var/lib/pve-cluster/config.db < config.sql

root@xxxxx:~# sqlite3 /var/lib/pve-cluster/config.db
sqlite> analyze;
sqlite> PRAGMA integrity_check;
ok

Enjoy if you encounter this issue...
 
  • Like
Reactions: kDn