Ubuntu 10.04 rescue information

0
by on January 12, 2013 at 9:35 pm

I recently encountered a problematic server running Ubuntu 10.04 server.  The problem was simple, and so was the solution, but there were many hurdles in the way that, if you’re not familiar with them, will prevent you from accomplishing the task.  This should apply to later Ubuntu distros as well.

Scenario:  The server is a Dell, on the other side of the country.  You have only DRAC access, no ability to manipulate anything physically.  Somehow, the root password was changed, and now no one can log into the server remotely.

Since I primarily work on RHEL based distros, my first instinct is to drop the system into runlevel 1.  This won’t work, however, for two reasons: First, the grub2 menu does not appear by default.  Second, runlevel 1 and runlevel single passed as kernel arguments both bring you to a menu that prompts for ….the root password!

How to move forward:  We need to boot off the installation media, NOT a livecd.  Why not a livecd?  Well, we happened to have installed the system with lvm2, and for some inexplicable reason, Ubuntu’s own livecd doesn’t include the lvm2 package.  I’m personally perturbed about having no grub menu, despite not “needing” one by default, so we’re going to address that as well.

If your system is a Dell, and you have a DRAC which is capable of mounting virtual media, you’re in luck here; simply mount the virtual media, reboot the system and boot from the virtual disk.  Otherwise, you’ll need to send someone onsite to insert a disk and hook up a remote KVM or type in commands for you (eek!)

Boot into Ubuntu Rescue Mode

Boot into Ubuntu Rescue Mode

Select your language, and the proceed with the menu selection shown above.  Next, you’ll be prompted to enter your keyboard information.  The system will scan your hardware briefly, and then attempt to setup networking using DHCP.  Feel free to cancel this step by pressing enter, as we don’t need networking for this task.  On the following page, choose “Do not configure network at this time.”

Next, it will ask you for a hostname.  You can enter whatever you wish, you’re not making changes to your installation.  I just press enter for default value.  Press enter again to select timezone.

A couple seconds later, you’ll be faced with the following screen:

Ubuntu Rescue Mode Device Selection

Ubuntu Rescue Mode Device Selection

As you can see, I choose “Do not use a root file system.”  This will allow you to drop you into a basic shell, which is useful in case there are other problems with your system that prevent the system from booting (not addressed here, but useful if you need to in the future for a fsck (file system check) when you don’t have the root password).

On the following page, choose “Execute a shell in the installer environment” and then select continue.

Next, we should have our command prompt.  Run lvscan to get a list of all logical volumes on the system.  In my case, I have just a default root LV, /dev/ubuntu/root.  Let’s go ahead and mount that to /mnt

.Mount logical volume from rescue mode.

Mount logical volume from rescue mode

Next, we want to change a root directory to the newly mounted file system:  chroot /mnt

Now we can set the root password by simply issuing the passwd command and typing in our new password.

Press ctrl+d or type exit to leave the chroot environment.

Now, we can reboot the system and boot from the disk, and configure the system in whichever runlevel we deem appropriate with the new root password.

As discussed, the way to get the grub menu to appear during boot:

Edit the file /etc/default/grub with your text editor of choice, make the following changes:

Edit Ubuntu Grub Menu

So, comment out the GRUB_HIDDEN_TIMEOUT=0 line, and uncomment GRUB_TERMINAL=console line.  The second is not absolutely necessary, but this changes grub from graphical mode to text mode, which is useful if you’re having video driver problems, in which case grub may decide not to show at all.

Now, issue the command grub-mkconfig -o /boot/grub/grub.cfg to apply the changes.

 

in Distros, How-To, Ubuntu

, , , ,

You can skip to the end and leave a response. Pinging is currently not allowed.

Categories