Gentoo Archives: gentoo-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] recovering from corrupted vdb
Date: Thu, 03 Nov 2011 15:10:53
Message-Id: 4EB2AECB.9060607@gentoo.org
In Reply to: [gentoo-dev] recovering from corrupted vdb by "Paweł Hajdan
1 On 11/03/2011 04:15 AM, "Paweł Hajdan, Jr." wrote:
2 > Shouldn't portage offer some means to recover from a corrupted vdb?
3 >
4 > I just stumbled upon
5 > <http://forums.gentoo.org/viewtopic-t-900382-start-0-postdays-0-postorder-asc-highlight-.html>
6 > and it seems really bad.
7 >
8 > It would suck if the only solution to this is reinstall (I remember
9 > package database becoming corrupted in some RPM-based distro I had years
10 > ago and I hated it).
11
12 Your best protection is to have a redundant backup on a separate disk.
13 When I do updates, I always clone my root partition to another partition
14 on a separate disk and chroot into that for the updates, and I keep that
15 spare partition as a backup in case one of my disks fails. For cloning,
16 a command like `rsync -axH --delete / /mnt/backup_rootfs/` works well
17 for me. I've also used btrfs subvolume snapshots for quick and efficient
18 cloning of my root filesystem, but that doesn't give the kind of
19 redundancy that a separate filesystem on a separate disk gives.
20
21 > If the recovery is already possible, we should get a doc explaining what
22 > to do. Otherwise it'd be really great to implement some recovery logic.
23 >
24 > I think we can't salvage much from a corrupted db (anything can happen,
25 > and the reporter mentions some code being present in the files), but at
26 > least "emerge -e world" or equivalent should be possible.
27
28 Due to circular dependencies, you need a seed vdb to start with. If you
29 don't have a redundant backup, another option would be to simply remove
30 the corrupt /var/db/pkg and replace it with a copy from a stage3 tarball.
31 --
32 Thanks,
33 Zac