0

I'm running the Ubuntu 12.04 LTS LAMP server. I got an error stating that my root directory was full after running an apt-get dist-upgrade, so following the instructions I found online, I uninstalled some of the old kernels using apt-get. However, I somehow accidentally uninstalled all of the kernels. My system won't reboot now.

I found a thread from 2011 about resolving this issue How to restore a system after accidentally removing all kernels?

But when I try to follow the instructions, they don't work for me.

When I do this:

sudo parted -l

I get this:

Model: ATA WDC WD20EZRX-00D (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos

Number  Start   End     Size    Type      File system  Flags
 1      1049kB  256MB   255MB   primary   ext2         boot
 2      257MB   2000GB  2000GB  extended
 5      257MB   2000GB  2000GB  logical                lvm


Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0
has been opened read-only.

Error: Can't have a partition outside the disk!

I don't understand why partition 1 is ext2 since this was a fresh install of 12.04 LTS, but I did this command as instructed:

sudo mount /dev/sda1 /mnt

Then I tried this command:

sudo mount --bind /dev /mnt/dev

and it said it couldn't find the mount point.

So, I did this:

mkdir /mnt/dev

and then it did the mount.

Okay, so now I'm ready for chroot per the instructions:

sudo chroot /mnt

And I get this:

chroot: failed to run command '/bin/bash': No such file or directory

I apologize in advance, but I don't know enough about linux to figure out what's going on here. Could someone please help me? It will take me a long time to reinstall everything on my server.

UPDATE: Thanks for your answer. When I enter

sudo pvs 

I get:

PV         VG         Fmt  Attr PSize PFree  
/dev/sda5  HOP-Server lvm2 a-   1.82t 136.00m

Then, I enter

sudo lvdisplay /dev/HOP-Server

and get this:

  --- Logical volume ---
  LV Name                /dev/HOP-Server/root
  VG Name                HOP-Server
  LV UUID                feUsjU-HFHi-WFre-322J-SlWF-0J1K-zpiTQX
  LV Write Access        read/write
  LV Status              NOT available
  LV Size                1.81 TiB
  Current LE             474993
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto

  --- Logical volume ---
  LV Name                /dev/HOP-Server/swap_1
  VG Name                HOP-Server
  LV UUID                tuJSFw-EKU4-oeLI-A934-srj2-DA2L-VqZtYr
  LV Write Access        read/write
  LV Status              NOT available
  LV Size                7.20 GiB
  Current LE             1843
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto

That's slightly different from your example, but I presume that I should enter

sudo mount /dev/HOP-Server/root /mnt  **UPDATED**

But when I do, I get this:

mount: special device /dev/HOP-Server/root does not exist

**UPDATE: ** I used this web page to help me mount the file system partition:

http://linuxwave.blogspot.com/2007/11/mounting-lvm-disk-using-ubuntu-livecd.html

After that, I was able to follow the rest of the original instructions with no errors. However, when I reboot, the only options are to start two versions of the memory test utility. I rebooted the live CD again and followed the instructions again. When I got to the apt-get for the kernel, it said that it's up to date.

UPDATE: Okay, I mounted the partitions again, and I can see that in /root is a file named initrd.img-3.2.0-56-generic. IIRC, that's the latest kernel. I ran update-grub, but it gives me the error, "cannot find a device for /".

UPDATE: After another search, I found this:

http://sourceforge.net/apps/mediawiki/bootinfoscript/index.php?title=Boot_Problems:Cannot_Find_A_Device_For_boot/grub

I followed that procedure, and it didn't get any errors. However, now when I boot, I get this:

error: ELF header smaller than expected
grub rescue> 

1 Answers1

6

Your Ubuntu seems to be using a LVM as its root. The ext2 partition you mounted contains the bare necessities to make your system able to boot and mount the lvm, the rest – including bash – is stored there.

In order to find the LVM volume containing your data, you need the lvm2 package, which is not installed on a live system. Thus, install it.

sudo apt-get install lvm2

Find the volume group containing your root partition by listing all volume groups.

sudo pvs

The output should look like

PV         VG   Fmt  Attr PSize PFree  
/dev/sda2  vg1  lvm2 a--  1,64t 236,91g

The second column contains the volume group's name, in this case vg1. With that, you can get information about the volumes contained in that group by issuing

sudo lvdisplay /dev/vg1

The output will look like

--- Logical volume ---
LV Path                /dev/vg1/lv1
LV Name                lv1
VG Name                vg1
LV UUID                kE8qXE-bI4u-NLzZ-u37A-wZfx-NtaU-57PqRj
LV Write Access        read/write
LV Creation host, time , 
LV Status              available
# open                 1
LV Size                1000,00 GiB
Current LE             256000
Segments               2
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           254:0

You are looking for the LV name, in this case lv1. In case there's just one volume, that should be your root drive. Otherwise, mount them all and see which one contains your system's data.

Mounting the volume is as easy as

sudo mount /dev/vg1/lv1 /mnt

Once you've done that, you should be good to continue with the instructions from the thread you've found.

Update: As mentioned in the comments, since you are using a separate boot partition (/dev/sda1), you will have to mount it to /mnt/boot/. The second answer in the thread you've found contains some more details on that.

Update 2: The latest error usually indicates that something is wrong with your grub installation. If you have access to a remote GUI, you might try using Boot Repair. If that doesn't help or you only have a terminal, I'd advise the creation of a new thread focused on this new problem.

drc
  • 2,880
  • 1
    Nice answer @drc (and nice editing of the question) - since the instructions the poster is following presumably don't mention how to handle a separate boot partition, should we include that they will likely need to add an extra step of making a /mnt/boot directory and mounting /dev/sda1 there? – steeldriver Nov 19 '13 at 08:05
  • Thanks, and good thinking with /boot/. Just checked the instructions and lucky for us, the second answer already contains a section about dealing with a separate boot partition. Added a hint to look at that to my answer. – drc Nov 19 '13 at 08:15
  • Thanks, @drc. I appreciate the prompt answer. Unfortunately, I had a problem. A comment won't let me enter enough information, so I'm hoping it is okay for me to enter my results as an answer. I apologize if this is not how I should enter the information. – user217202 Nov 19 '13 at 15:29
  • Just add the results in your original post. That should suffice. – Indian Nov 19 '13 at 15:36
  • Thanks @drc. I went back and did that, and hopefully formatted it better this time. – user217202 Nov 19 '13 at 15:48
  • @drc I made some progress, but still can't reboot. Details in the question. – user217202 Nov 19 '13 at 21:15