You are not logged in.

#1 2022-09-23 17:32:13

gand@lf
Member
Registered: 2022-09-23
Posts: 6

Accidentally deleted /var/lib/pacman

Hi arch community,

As the subject states, I accidentally deleted my /var/lib/pacman directory and i'm trying to fix it by following this solution:

https://wiki.archlinux.org/title/Pacman … e_recovery

But I'm facing some issues following this fix, for instance:

*First:    $ paclog --pkglist --logfile=/var/log/pacman.log | ./pacrecover >files.list 2>pkglist.orig

creates an empty files.list file.

*secondly :

Performing the recovery

Define a bash function for recovery purposes:

recovery-pacman() {
    pacman "$@"  \
    --log /dev/null   \
    --noscriptlet     \
    --dbonly          \
    --overwrite "*"   \
    --nodeps          \
    --needed
}


after putting this in .bashrc and sourcing it, when i run recovery-pacman, I get "error: invalid option '--noscriptlet'"

How do i proceed now ?

Last edited by gand@lf (2022-09-23 17:33:10)

Offline

#2 2022-09-23 20:46:22

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,464

Re: Accidentally deleted /var/lib/pacman

when i run recovery-pacman

https://wiki.archlinux.org/title/Pacman … e_recovery tells you use pass some parameters to pacman, --noscriptlet is only valid for -R (you're not supposed to use that here), -S and -U

Offline

#3 2022-09-24 15:46:24

gand@lf
Member
Registered: 2022-09-23
Posts: 6

Re: Accidentally deleted /var/lib/pacman

I removed --noscriptlet from function..Now i get error" invalid option '--dbonly'"...Infact it gives invalid command error on all the reamining parameters too..

Last edited by gand@lf (2022-09-24 15:49:51)

Offline

#4 2022-09-24 15:58:46

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,464

Re: Accidentally deleted /var/lib/pacman

I removed --noscriptlet from function..Now i get error" invalid option '--dbonly'"...Infact it gives invalid command error on all the reamining parameters too..

D'OHH…

You're suppsoed to run

# recovery-pacman -U $(< files.list)

and

# recovery-pacman -S $(< pkglist)

NOT just "recovery-pacman"

Restore the function as it is in the wiki. Read the wiki again. Then once more. And a third time.
Don't get creative here. Follow the wiki.

Offline

#5 2022-09-24 16:13:30

gand@lf
Member
Registered: 2022-09-23
Posts: 6

Re: Accidentally deleted /var/lib/pacman

bro i've tried running them like number of times..when i run recovery-pacman -U $(< files.list) or recovery-pacman -S $(< pkglist), i just get recovery-pacman command not found...and when i run recovery-pacman standalone it gives invalid command error...I've tried what you're saying.. If somehow possible please come and have a look at it on anydesk.. I am frustrated cz it's my main pc and i'm not able to work because of this sad

Offline

#6 2022-09-24 16:20:31

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,464

Re: Accidentally deleted /var/lib/pacman

i just get recovery-pacman command not found.
type recovery-pacman
stat files.list pkglist

Also post the exact input and output,  https://bbs.archlinux.org/viewtopic.php?id=57855
Please also use code tags, https://bbs.archlinux.org/help.php#bbcode
And skip the bro-talk.

Offline

#7 2022-09-24 16:33:23

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,570
Website

Re: Accidentally deleted /var/lib/pacman

*First:    $ paclog --pkglist --logfile=/var/log/pacman.log | ./pacrecover >files.list 2>pkglist.orig

creates an empty files.list file.

The pacrecovery script is borked due to the use of curlybraces (mentioned in the talk page), so files.list will always be an empty file. However, I'm not sure what the point of identifying locally cached archives is when pacman will just use the local archive when you use -S anyway.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#8 2022-09-24 16:45:02

gand@lf
Member
Registered: 2022-09-23
Posts: 6

Re: Accidentally deleted /var/lib/pacman

seth wrote:
i just get recovery-pacman command not found.
type recovery-pacman
stat files.list pkglist

Also post the exact input and output,  https://bbs.archlinux.org/viewtopic.php?id=57855
Please also use code tags, https://bbs.archlinux.org/help.php#bbcode
And skip the bro-talk.




[alpha@alpha 0x01]$ type recovery-pacman
recovery-pacman is a function
recovery-pacman ()
{
    pacman "$@" --log /dev/null --dbonly --overwrite "*" --nodeps --needed
}
[alpha@alpha 0x01]$ stat files.list pkglist
  File: files.list
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 254,2   Inode: 5771314     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/   alpha)   Gid: (  984/   users)
Access: 2022-09-24 21:21:34.216721132 +0530
Modify: 2022-09-23 19:50:50.624559352 +0530
Change: 2022-09-23 19:50:50.624559352 +0530
Birth: 2022-09-23 19:50:50.624559352 +0530
  File: pkglist
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 254,2   Inode: 5771316     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/   alpha)   Gid: (  984/   users)
Access: 2022-09-24 21:31:59.875767473 +0530
Modify: 2022-09-23 20:56:15.968575010 +0530
Change: 2022-09-23 20:56:15.968575010 +0530
Birth: 2022-09-23 19:51:17.794517948 +0530

Offline

#9 2022-09-24 16:55:15

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,464

Re: Accidentally deleted /var/lib/pacman

seth wrote:

The function is there (just crippled for no reason) so there's no way you get anything like "recovery-pacman command not found.
=> Restore the correct function first.

seth also wrote:

post the exact input and output,  https://bbs.archlinux.org/viewtopic.php?id=57855

What do you enter and what does the system respond? Verbatim. No paraphrasing.

Edit: why is pkglist empty?
How did you create that file?

Because of the pacrecover script, not sure whetehr the braces are actually a problem (would have to check) but just using ".zst" instead of ".{xz,zst}" should™ be fine since the compression changed quite a while ago.

Last edited by seth (2022-09-24 17:02:05)

Offline

#10 2022-09-24 18:23:55

gand@lf
Member
Registered: 2022-09-23
Posts: 6

Re: Accidentally deleted /var/lib/pacman

seth wrote:
seth wrote:

The function is there (just crippled for no reason) so there's no way you get anything like "recovery-pacman command not found.
=> Restore the correct function first.

seth also wrote:

post the exact input and output,  https://bbs.archlinux.org/viewtopic.php?id=57855

What do you enter and what does the system respond? Verbatim. No paraphrasing.

Edit: why is pkglist empty?
How did you create that file?

Because of the pacrecover script, not sure whetehr the braces are actually a problem (would have to check) but just using ".zst" instead of ".{xz,zst}" should™ be fine since the compression changed quite a while ago.


Here's the full chain of commands I ran and their outputs :-


[alpha@alpha 0x01]$ paclog --pkglist --logfile=/var/log/pacman.log | ./pacrecover >files.list 2>pkglist.orig
[alpha@alpha 0x01]$ ls
FastApi  files.list  hunts  pacrecover  pkglist.orig
[alpha@alpha 0x01]$ cat files.list
[alpha@alpha 0x01]$ du -sh files.list
0       files.list
[alpha@alpha 0x01]$ head -n 10 pkglist.orig
pacutils
nodejs
c-ares
libuv
nasm
yasm
python-protobuf
protobuf
ninja
gperf
[alpha@alpha 0x01]$ du -sh pkglist.orig
16K     pkglist.orig
[alpha@alpha 0x01]$ { cat pkglist.orig; pacman -Slq; } | sort | uniq -d > pkglist
[alpha@alpha 0x01]$ ls
FastApi  files.list  hunts  pacrecover  pkglist  pkglist.orig
[alpha@alpha 0x01]$ du -sh pkglist
16K     pkglist
[alpha@alpha 0x01]$ head -n 5 pkglist
a52dec
aalib
abseil-cpp
accounts-qml-module
accountsservice
[alpha@alpha 0x01]$ comm -23 <(pacman -Sgq base | sort) pkglist.orig >> pkglist
comm: file 2 is not in sorted order
comm: input is not in sorted order
[alpha@alpha 0x01]$ type recovery-pacman
recovery-pacman is a function
recovery-pacman ()
{
    pacman "$@" --log /dev/null --dbonly --overwrite "*" --nodeps --needed
}
[alpha@alpha 0x01]$ pacman -Sy
error: you cannot perform this operation unless you are root.
[alpha@alpha 0x01]$ sudo !!
sudo pacman -Sy
[sudo] password for alpha:
:: Synchronizing package databases...
core                               155.0 KiB  46.1 KiB/s 00:03 [##################################] 100%
extra                             1713.6 KiB  1544 KiB/s 00:01 [##################################] 100%
community                            7.0 MiB   696 KiB/s 00:10 [##################################] 100%
[alpha@alpha 0x01]$ recovery-pacman -U $(< files.list)
error: you cannot perform this operation unless you are root.
[alpha@alpha 0x01]$ sudo !!
sudo recovery-pacman -U $(< files.list)
sudo: recovery-pacman: command not found
[alpha@alpha 0x01]$ recovery-pacman
error: invalid option '--dbonly'
[alpha@alpha 0x01]$ sudo recovery-pacman -S $(< pkglist)
sudo: recovery-pacman: command not found
[alpha@alpha 0x01]$ recovery-pacman
error: invalid option '--dbonly'
[alpha@alpha 0x01]$

Also, I ran this after modifying pacrecover script as you recommended.

Offline

#11 2022-09-24 20:12:29

tucuxi
Member
From: Switzerland
Registered: 2020-03-08
Posts: 291

Re: Accidentally deleted /var/lib/pacman

You defined recovery-pacman in your alpha session, and then try to invoke it as root and in a different shell. That's not going to work. Define and run it as root.

Offline

#12 2022-09-25 10:03:20

gand@lf
Member
Registered: 2022-09-23
Posts: 6

Re: Accidentally deleted /var/lib/pacman

thanks all..Problem solved..I tried doing all in root session and it worked.. Previously was trying all commands with sudo and that was causing issues.

Offline

#13 2022-09-25 12:13:25

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,648

Re: Accidentally deleted /var/lib/pacman

Please remember to mark your thread [SOLVED] (edit the title of your first post).

Please also learn how to use code tags before you post again. This makes the output easier to read and provides a scroll box for long output.

https://wiki.archlinux.org/title/Genera … s_and_code
https://bbs.archlinux.org/help.php#bbcode

Offline

#14 2022-10-16 11:00:19

BoGy
Member
From: Antwerp, Belgium
Registered: 2022-10-16
Posts: 15
Website

Re: Accidentally deleted /var/lib/pacman

I'm not a real fine coder or whatsoever, but i managed to delete the files just like the Topicstarter; and my pacman.log is working.. (i tried to solve other errors by removing all 0-byte files, which worked fine until i removed a few too much)

My issue begins with pacrecover... I removed the brackets so that there is only .zst (and also removed the xz)

I still get empty files (both of them), and for some reason if i try to run pacrecover standalone, it doesn't do anything, although it is chmodded +x and is in groups root and root also owns it
when i do "sh pacrecover" it'll run it by itself, but then i get errors ofcourse as there is no data-ingestion.

when i run the next line: "paclog --pkglist --logfile=/var/log/pacman.log | ./pacrecover >files.list 2>pkglist.orig" i get empty files, but when i remove the pacrecover part and just pipe into "| less " , it clearly shows packagenames and versions; so it should get the data..

I also tried putting "sh pacrecover >files.list 2>pkglist.orig" after the pipe, but that also generates empty files

although in the pkglist.orig this can be found:
pacrecover: line2 $'\r' command not found
: no such file or directorykepkg.conf

so something must be going wrong in that script...

i actually copy-pasted the pacrecover script AS IS from the site, then saved it into a textfile,  then ftp'd it from my server with MC into the root directory, changed ownership and made it +x.  So that should all be in working condition.  The only thing i changed (later, after the OG files didn't do a thing) was removing the brackets so that it'll add .pkg.tar.zst at the end of pkgname.

in case i didn't mention it, i use a thumbdrive to archroot into the installed arch so all commands are being run as root by default.

I have already been able to reinstall mkinitcpio so i might also try to boot into arch and then run a sudo su terminal so everything is done in the same root-session (havn't tried that yet actually)

Offline

#15 2022-10-16 12:28:50

frostschutz
Member
Registered: 2013-11-15
Posts: 1,647

Re: Accidentally deleted /var/lib/pacman

$'\r': command not found is a strong indicator of using the wrong newline format in a script.

Windows uses \r\n newlines instead of just \n - but it does not work for Linux.

Try your luck with dos2unix, or open in nano, and disable DOS/MAC format in the File save dialog (Alt + D).

You can also try 'file thescript.sh' if it says "with CRLF line terminators" it's the wrong newlines in it.

Last edited by frostschutz (2022-10-16 12:30:06)

Offline

#16 2022-10-17 12:01:57

BoGy
Member
From: Antwerp, Belgium
Registered: 2022-10-16
Posts: 15
Website

Re: Accidentally deleted /var/lib/pacman

damn, and i especially used Notepad++ to save it as bash script ... must've overlooked something then... i think the easiest thing is just to open the existing file in nano, and backspace on every new line and create a CRLF by hitting enter and save that file smile

thx for the info guys!

Offline

#17 2022-10-17 12:39:19

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,464

Re: Accidentally deleted /var/lib/pacman

You do absolutely not want any CRLF, just LF - and better™ editors and some dedicated tools or just sed allows you to remove that.
https://en.wikipedia.org/wiki/Newline

Offline

#18 2022-10-17 12:51:53

frostschutz
Member
Registered: 2013-11-15
Posts: 1,647

Re: Accidentally deleted /var/lib/pacman

You can simply toggle it in nano... in the filesave dialog with Alt-D

Offline

#19 2022-10-18 06:28:52

shoelesshunter
Member
From: USA
Registered: 2014-05-18
Posts: 289

Re: Accidentally deleted /var/lib/pacman

this was in a .bashrc, yet executed with sudo... might that be a problem?

Offline

#20 2022-10-19 08:30:29

BoGy
Member
From: Antwerp, Belgium
Registered: 2022-10-16
Posts: 15
Website

Re: Accidentally deleted /var/lib/pacman

ok, i'm getting a step forward here ... the pkglist.orig is now actually getting data, the files.list stays 0-bytes... (as there are 0 files ofc)

I've also tried booting the system which now seems to do something, but it's a broken system... it goes from "init ramdisk" (not the usually long list of services/drivers) into a screenflick, then mouse is enabled (pointer on screen) and the weirdest thing of all is that it doesn't show a blank screen but i get this (and only this):
Starting version 251.6-1-arch
/dev/sda1 clean x/x files x/x blocks (the xx are numbers)

When i follow the manual and do the pacman -Su at the end, it says "error; could not open /var/lib/pacman/local/kde-cli-tools-5.26.0-1/files: no file or dir" and that it couldn't load metadata for the package..

I've also done the pacman -Qk and grepped all the errors out of the list, trying to reinstall those also doesn't work... i've tried reinstalling a few from that list manually, nothing seems to help though...
I guess i'll have to create a fresh partition, install arch again and then copy my files from sda1 to sda3 before removing sda1  (i'll fix the bootloader ofc)

Offline

Board footer

Powered by FluxBB