1

My Raspberry running Raspbian crashed but I would like to know which packages I had installed on that SD card. Is there a way to detect that without actually booting the system?

  • In general, you can mount the disk in a similar system, chroot into it, and run dpkg -l. This is a general method. I don't know if it would work for Raspbian, but I don't see why not. – Faheem Mitha Oct 30 '14 at 13:39
5

Debian's package databases are under /var/lib/dpkg. They're text files, fairly easy to parse manually even if you don't have Debian tools around. In particular, the file /var/lib/dpkg/status contains one paragraph of information for every package (not just installed packages but also some other packages known to the system), starting with Package: PACKAGENAME.

cd /media/sdcard0/var/lib/dpkg
<status awk -v RS= '/\nStatus: install ok installed\n/ {print $2}'

If you aren't on unix or other system with awk or other text processing tool, you can inspect the directory /var/lib/dpkg/info. Every package except for virtual dependency-only packages has several files there, including at least PACKAGENAME.list.

If you're on a system with dpkg, you can tell it to consult a database other than the normal one.

dpkg --admindir=/media/sdcard0/var/lib/dpkg -l
dpkg --root=/media/sdcard0 -l
  • excellent, exactly what I was looking for, thank you! – Hoffmann Oct 31 '14 at 20:42
  • yes, very helpful! I learned tonight my old raspbian image from bananapi.org had only 20MiB allocated on /boot. It ran out of space mid bpi-update and won't boot now. I have to re-install from scratch after backing up the old card – Scott Oct 14 '17 at 1:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.