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
PHP Learner
  • 2,948

3 Answers3

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.

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.

KK Patel
  • 19,753
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.