1

I removed libc6 manually (i.e. by sudo apt remove libc6 command) on my Ubuntu 18.04 system and after reboot, there is just grub command prompt:

GNU GRUB   version 2.02

Minimal BASH_like line editing is supported. For the first word TAB lists possible command completions. Anywhere else TAB lists possible device or file completions.


grub>  _

Is there any way to reinstall libc6 and put my system working as before?

UPDATE1:

This is screenshot of my partition structure (as GParted shows): enter image description here

/dev/sda2 is the partition that is encrypted and contains /etc/, /root/, /lib/, /run/ and other Linux OS default folders and was mounted (at my previous working Lubuntu) as / i.e. system root.

/dev/sda5 is the partition that is not encrypted and was mounted (at my previous working Lubuntu) as /home/ folder.

UPDATE2:

Although /dev/sda5/ is not an encrypted partition, but my /home/myusername/ folder is encrypted as follows and I do not remember how I did this encryption during OS installation and do not know how to recover my data in my /home/myusername/ folder:

lubuntu@lubuntu:~$ sudo ls /media/lubuntu/UUID/myusername/ -la
total 12
dr-x------ 3 1000 1000 4096 Aug  1  2013 .
drwxr-xr-x 7 root root 4096 Aug 25  2014 ..
lrwxrwxrwx 1 1000 1000   27 Aug  1  2013 .Private -> /home/.ecryptfs/myusername/.Private
drwx------ 3 1000 1000 4096 Aug  2  2013 .cache
lrwxrwxrwx 1 1000 1000   28 Aug  1  2013 .ecryptfs -> /home/.ecryptfs/myusername/.ecryptfs
lrwxrwxrwx 1 1000 1000   56 Aug  1  2013 Access-Your-Private-Data.desktop -> /usr/share/ecryptfs-utils/ecryptfs-mount-private.desktop
lrwxrwxrwx 1 1000 1000   52 Aug  1  2013 README.txt -> /usr/share/ecryptfs-utils/ecryptfs-mount-private.txt
3
  • 1
    How did you remove libc6? Using APT? Or directly deleted the binaries?
    – Kulfy
    Nov 24, 2019 at 16:42
  • 2
    I guess you could always boot to a LiveCD following askubuntu.com/a/88432/231142 and after it is in chroot reinstall the libc6.
    – Terrance
    Nov 24, 2019 at 17:12
  • 1
    @Kulfy I removed libc6 by apt command and added this information in my question. Nov 25, 2019 at 11:22

3 Answers 3

2

I think this will work.

Download the .iso of your operating system and make a bootable USB using something like rufus. Boot from USB and when the GRUB menu appears select Try Ubuntu without installing.

After it boots up, the LiveUSB environment open a terminal. If you enabled LUKS in your hard drive, open the file manager enter the password. Now in the terminal run :

sudo pvscan    
sudo lvscan    
sudo vgchange -a y

This will activate the LUKS volume for mounting. Read the volume name from the output.

sudo mount /dev/sdaX/root  /mnt

where sdaX is the volume name.

If you have a separate /boot drive: go to the /mnt of LiveUSB where the filesystem is mounted. Open /etc/fstab and check for a /boot [UUID] entry and remember the drive name. Do :

sudo mount /dev/sdaX /mnt/boot    
sudo mount --bind /sys /mnt/sys    
sudo mount --bind /dev /mnt/dev    
sudo mount --bind /proc /mnt/proc

where sdaX is the above drive name.

Now sudo nano /etc/hosts. You should have two or more entries like :

127.0.0 localhost    
127.0.0 username

Copy the host address to the next line and add the host name the one you find in your terminal prompt. Should be something like ubuntu. Save and exit. Now :

sudo chroot /mnt

Reinstall libc6 using apt-get.

sudo apt-autoremove
sudo apt-get update && sudo apt-get upgrade    
sudo apt install -f    
sudo update-grub    
exit

Unmount everything using sudo umount /mnt/... and reboot from OS.

PS. If apt does not work,maybe it depends on libc6, I would recommend making a backup of important files once the partition is mounted or do a reinstall without removing or repair the os.

14
  • I tried your solution. My /home/ folder is encrypted and is a separated partition. When I click that partition in Live OS file manager, It asks me for password and after entering password, it gives following error message: Error unlocking /dev/sda2: The function 'bd_crypto_luks_open_blob' called, but not implemented! Nov 28, 2019 at 13:44
  • Also, these three commands does not show any result: sudo pvscan sudo lvscan sudo vgchange -a y Nov 28, 2019 at 13:54
  • Run this in the live environment before trying to give the password,skip no step: sudo apt-get install libblockdev-crypto2 and systemctl restart udisks2.service.You may need to restart other services,post any error messages after this.After entering the password and opening the volume run the commands sudo pvscan etc. Nov 29, 2019 at 3:31
  • Thank you very much, I did exactly what you told in your comment, the partition was opened after 2 mins waiting and its files are readable. But sudo pvscan returns: ` No matching physical volumes found` and sudo lvscan and sudo vgchange -a y return nothing! Any solution? Nov 30, 2019 at 16:11
  • After opening my encrypted partition (/dev/sda2/) by Live OS file manager, I found my /root/ folder in it and tried to mount whole partition on /mnt folder by sudo mount /dev/sda2 /mnt command, but it returns: mount: /mnt: unknown filesystem type 'crypto_LUKS'. and If I try to mount /root folder by sudo mount /media/lubuntu/UUID/root /mnt it returns: mount: /mnt: /media/lubuntu/UUID/root is not a block device (UUID is uu-id of my encrypted partition (/dev/sda2 and /media/lubuntu/UUID/ is the location it is mounted by Live OS file manager). Nov 30, 2019 at 16:39
0

From Issues you faced, it looks like more packages are missing than libc6 and they were removed accidentally. I would suggest to mount / partition and go through apt and dpkg logs to check removed packages.

cat /var/log/dpkg.log | grep remove
cat /var/log/apt/history.log | grep remove

Get list of packages those were removed and try to re-install them.

2
  • May be you are right, but for installing any packages if I use "-o RootDir=/mnt" option it returns E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem. error and i do not know how to run sudo dpkg --configure -a on /mnt as root! Jan 17, 2020 at 13:40
  • i solved chroot problem by runing sudo cp -a /bin/bash /mnt/bin ; sudo chmod +x /mnt/bin/bash ; sudo cp -an /usr /mnt ; sudo cp -an /lib /mnt ; sudo cp -an /lib64 /mnt ; and after above commands, sudo chroot /mnt worked! Jan 17, 2020 at 16:38
0

For mounting your encrypted partition it looks like you need mount /media/lubuntu/UUID /mnt. If running apt/apt-get inside the chroot doesn't work run it in the live CD terminal without chroot but with the added option -o RootDir=/mnt. That will put everything on the encrypted partition properly.

3
  • After running following commands: udisksctl unlock -b /dev/sda2 ; sudo mount /dev/dm-0 /mnt ; sudo mount /dev/sda1 /mnt/boot/ ; sudo mount --bind /sys /mnt/sys/ ; sudo mount --bind /dev /mnt/dev/ ; sudo mount --bind /proc /mnt/proc/ ; I did following command as you sugested: sudo apt autoremove -o RootDir=/mnt ; but it returns: E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem. and running sudo dpkg --configure -a does not returns anythings and does not solve above error message, any suggestion? Jan 17, 2020 at 13:25
  • It seems that I have to run sudo dpkg --configure -a on my /mnt as root directory, but dkpg command does not accept -o RootDir=/mnt option. Is there any suggestion for how to run sudo dpkg --configure -a on /mnt as root? Jan 17, 2020 at 13:42
  • i solved chroot problem by runing sudo cp -a /bin/bash /mnt/bin ; sudo chmod +x /mnt/bin/bash ; sudo cp -an /usr /mnt ; sudo cp -an /lib /mnt ; sudo cp -an /lib64 /mnt ; and after above commands, sudo chroot /mnt worked! Jan 17, 2020 at 16:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .