You are not logged in.

#1 2012-04-02 23:08:27

trusktr
Banned
From: .earth
Registered: 2010-02-18
Posts: 907
Website

[SOLVED] I accidentally did "rm -rf /lib/" as root.

Hahaha... Well, as you can imagine, I'm in a very interesting predicament now. My fingers moved too fast and now /lib is gone. Obviously, I can't reboot, or even terminate anything that's currently running or it won't start again. If I close this browser window, I might be done for. My 'pacman' command is gone, my 'ls' command is gone, even my 'bash' command is gone... Everything is gone. haha

Shoot.

Hmmmm... Any suggestions?

Last edited by trusktr (2012-05-20 11:12:34)


joe@trusktr.io - joe at true skater dot io.

Offline

#2 2012-04-02 23:11:45

Roken
Member
From: South Wales, UK
Registered: 2012-01-16
Posts: 1,253

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

I would have suggested having a go at reinstalling the latest version of everything in the cache, but to be honest it would probably take you longer than a fresh install would (much longer). And if pacman is dead you're going to struggle with that anyway. I'd be tempted to recover what you need from the drive, and start again. (You can use a live CD to recover data, as long as you have somewhere to put it).


Ryzen 5900X 12 core/24 thread - RTX 3090 FE 24 Gb, Asus Prime B450 Plus, 32Gb Corsair DDR4, Cooler Master N300 chassis, 5 HD (1 NvME PCI, 4SSD) + 1 x optical.
Linux user #545703

Offline

#3 2012-04-02 23:30:49

ConnorBehan
Package Maintainer (PM)
From: Long Island NY
Registered: 2007-07-05
Posts: 1,359
Website

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

If glibc is gone I think you need a recovery CD. Boot into a CD, mount your root partition to /mnt and run:

mount -o bind /dev /mnt/dev
mount -t proc /proc /mnt/proc/
mount -t sysfs /sys /mnt/sys/

Then you can install packages to that root with pacman -U -r. Either get them from the cache or a USB drive or portable storage or something. At the very least you'll want to reinstall everything from core.


6EA3 F3F3 B908 2632 A9CB E931 D53A 0445 B47A 0DAB
Great things come in tar.xz packages.

Offline

#4 2012-04-02 23:47:51

trusktr
Banned
From: .earth
Registered: 2010-02-18
Posts: 907
Website

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

The only thing gone are all the *.so files that were in /lib, the rest of the filesystem is intact... Is glibc still useable?

Hmmm... I don't have a thumb drive or any blank CDs. All I have is Windows that I can boot from my other drive.

Last edited by trusktr (2012-04-02 23:54:48)


joe@trusktr.io - joe at true skater dot io.

Offline

#5 2012-04-03 00:04:06

ConnorBehan
Package Maintainer (PM)
From: Long Island NY
Registered: 2007-07-05
Posts: 1,359
Website

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

I think those libraries are important for glibc. Do you have a 32 bit system? Do you have tar or zip or some other archive manager working? If so I could probably email you my copies of them. As long as you're aware of how insecure this is (having a recovery CD handy is a must!)


6EA3 F3F3 B908 2632 A9CB E931 D53A 0445 B47A 0DAB
Great things come in tar.xz packages.

Offline

#6 2012-04-03 00:07:53

trusktr
Banned
From: .earth
Registered: 2010-02-18
Posts: 907
Website

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

Lol, thanks, but no, all my commands are gone including tar or zip and except for 'cd' and 'pwd' from what I can tell. I can't execute anything in /bin/ or /usr/bin for some reason considering I only deleted /lib/...

I just realized I have an android phone. I wonder if I can boot from that.

Last edited by trusktr (2012-04-03 00:08:23)


joe@trusktr.io - joe at true skater dot io.

Offline

#7 2012-04-03 00:19:58

ConnorBehan
Package Maintainer (PM)
From: Long Island NY
Registered: 2007-07-05
Posts: 1,359
Website

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

The binaries you still have depend on libc, that's why. I might be willing to transfer one at a time.


6EA3 F3F3 B908 2632 A9CB E931 D53A 0445 B47A 0DAB
Great things come in tar.xz packages.

Offline

#8 2012-04-03 00:38:30

trusktr
Banned
From: .earth
Registered: 2010-02-18
Posts: 907
Website

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

Sure, I'm down to try it. I still have my email open and access to file manager by opening folders from the desktop.

Last edited by trusktr (2012-04-03 00:43:30)


joe@trusktr.io - joe at true skater dot io.

Offline

#9 2012-04-03 00:49:21

trusktr
Banned
From: .earth
Registered: 2010-02-18
Posts: 907
Website

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

@ConnorBehan I sent you my email. I have no way of creating the /lib/ directories in this state though. It seems I'll have to put Arch on my Android so I can boot and re-install the packages... But the question is which packages do I have to re-install?


joe@trusktr.io - joe at true skater dot io.

Offline

#10 2012-04-03 01:07:36

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,543

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

trusktr wrote:

But the question is which packages do I have to re-install?

Once you have reinstalled pacman, you may be able to run testdb to identify which files are missing

Offline

#11 2012-04-03 01:13:03

trusktr
Banned
From: .earth
Registered: 2010-02-18
Posts: 907
Website

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

skunktrader wrote:
trusktr wrote:

But the question is which packages do I have to re-install?

Once you have reinstalled pacman, you may be able to run testdb to identify which files are missing


oh ok, sweet.

So I've downloaded all the .so files that ConnorBehan sent me into a directory in my user's home folder. I gotta figure out how to export this location now. Do I add it to LD_LIBRARY_PATH?

EDIT: I tried exporting LD_LIBRARY_PATH to include the folder where I downloaded the files, but then there's no effect.


If I try the pacman command, I get

-bash: /usr/bin/pacman: No such file or directory

but I the only thing I deleted is /lib. /usr/bin/pacman actually exists. I wonder if it won't work because bash is missing?

Last edited by trusktr (2012-04-03 01:56:55)


joe@trusktr.io - joe at true skater dot io.

Offline

#12 2012-05-19 20:12:28

trusktr
Banned
From: .earth
Registered: 2010-02-18
Posts: 907
Website

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

@ConnorBehan Alright, I'm gunna try booting the live CD and installing packages. I wonder how to get the latest packages. I have to mount root, but my pacman cache is in the home partition (/home/pacman/cache) so I have to mount that too I suppose.


joe@trusktr.io - joe at true skater dot io.

Offline

#13 2012-05-20 05:34:47

Awebb
Member
Registered: 2010-05-06
Posts: 6,298

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

Here, in case you haven't seen this yet: https://wiki.archlinux.org/index.php/Change_Root

Offline

#14 2012-05-20 07:54:24

trusktr
Banned
From: .earth
Registered: 2010-02-18
Posts: 907
Website

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

@Awebb Thanks! I did see that and am about to try it right now because the following two commands don't seem to work:

# pacman -r /mnt/path/to/root -S $(pacman -Qeq -r /mnt/path/to/root) --noconfirm
# pacman -r /mnt/path/to/root -S $(pacman -Qdq -r /mnt/path/to/root) --noconfirm --asdeps

joe@trusktr.io - joe at true skater dot io.

Offline

#15 2012-05-20 08:28:43

trusktr
Banned
From: .earth
Registered: 2010-02-18
Posts: 907
Website

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

@ConnorBehan I tried mounting the root partition along with the other mount commands you mentioned then chrooting into it but when I try to chroot into it I get this error:

# mount <root_partition> /mnt
# mount -o bind /dev /mnt/dev 
# mount -t proc /proc /mnt/proc/
# mount -t sysfs /sys /mnt/sys/ 
# chroot /months /bin/bash
chroot: failed to run command `/bin/bash': No such file or directory.

Is there a simple way to re-install all packages like I attempted in my previous comment? Or should I stick to the chroot method and how?


joe@trusktr.io - joe at true skater dot io.

Offline

#16 2012-05-20 11:10:01

trusktr
Banned
From: .earth
Registered: 2010-02-18
Posts: 907
Website

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

Alright, I came up with a solution after mounting my root partition from a LiveCD like @ConnorBehan suggested, but I'm sure it would've been cleaner had I more experience with Bash:

#!/bin/bash

pacman -Qe -r /mnt/arch/root/ > explicit_pkgs.txt
while read line; do
	pkgFile=/mnt/arch/home/pacman/pkg/${line// /-}-x86_64.pkg.tar.xz
	if [ ! -e $pkgFile ]; then
		pkgFile=/mnt/arch/home/pacman/pkg/${line// /-}-x86_64.pkg.tar.gz
		#echo "test 1"
	fi
	if [ ! -e $pkgFile ]; then
		pkgFile=/mnt/arch/home/pacman/pkg/${line// /-}-any.pkg.tar.xz
		#echo "test 2"
	fi
	if [ ! -e $pkgFile ]; then
		pkgFile=/mnt/arch/home/pacman/pkg/${line// /-}-any.pkg.tar.gz
		#echo "test 3"
	fi

	echo
	echo
	echo "Installing $pkgFile"
	echo "-----------------------------"

	pacman -r /mnt/arch/root -U $pkgFile --noconfirm
done < "explicit_pkgs.txt"

pacman -Qd -r /mnt/arch/root/ > dependancy_pkgs.txt
while read line; do
	pkgFile=/mnt/arch/home/pacman/pkg/${line// /-}-x86_64.pkg.tar.xz
	if [ ! -e $pkgFile ]; then
		pkgFile=/mnt/arch/home/pacman/pkg/${line// /-}-x86_64.pkg.tar.gz
		#echo "test 1"
	fi
	if [ ! -e $pkgFile ]; then
		pkgFile=/mnt/arch/home/pacman/pkg/${line// /-}-any.pkg.tar.xz
		#echo "test 2"
	fi
	if [ ! -e $pkgFile ]; then
		pkgFile=/mnt/arch/home/pacman/pkg/${line// /-}-any.pkg.tar.gz
		#echo "test 3"
	fi

	echo
	echo
	echo "Installing $pkgFile"
	echo "-----------------------------"

	pacman -r /mnt/arch/root -U $pkgFile --noconfirm --asdeps
done < "dependancy_pkgs.txt"

Last edited by trusktr (2012-05-20 11:11:02)


joe@trusktr.io - joe at true skater dot io.

Offline

#17 2012-05-20 11:24:03

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

You've been trying to fix this for one and a halve month now..?


ᶘ ᵒᴥᵒᶅ

Offline

#18 2012-05-20 11:38:29

trusktr
Banned
From: .earth
Registered: 2010-02-18
Posts: 907
Website

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

Haha yeah, I left my desktop unfixed and installed Arch on my laptop to get me through classes. The semester's over now though.


joe@trusktr.io - joe at true skater dot io.

Offline

#19 2012-05-20 11:56:33

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,399
Website

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

FYI....

pacman -r /mnt/arch/root --cachedir /mnt/arch/root/var/cache/pacman -S $(pacman -r /mnt/arch/root -Qqk | cut -f1 -d" " | sort -u)

Offline

#20 2012-05-20 12:26:21

trusktr
Banned
From: .earth
Registered: 2010-02-18
Posts: 907
Website

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

@Allan Nice!... Hey, but what about packages installed by -U or from AUR?  Users who've installed AUR packages will see an error along the lines of "error: target not found: aur-package" if they try that command.


joe@trusktr.io - joe at true skater dot io.

Offline

#21 2012-05-20 15:54:30

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

Install those manually.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#22 2012-05-21 03:46:22

trusktr
Banned
From: .earth
Registered: 2010-02-18
Posts: 907
Website

Re: [SOLVED] I accidentally did "rm -rf /lib/" as root.

@fsckd That's what I ended up doing. What I mean is that @Allan's suggestion will only work if every single package of is from an official repo, otherwise the command will error out and won't complete when it encounters a package not in the official repos.

@kano wrote a nice one that takes that into consideration: https://bbs.archlinux.org/viewtopic.php … 99#p263399

A combination of @Allan's and @kano's would have done the trick in my case. smile

Last edited by trusktr (2012-05-21 03:47:45)


joe@trusktr.io - joe at true skater dot io.

Offline

Board footer

Powered by FluxBB