1

After a mistake, I changed my password but can't remember it now.

I've found out that you can reset it by going into recovery mode, but I can't seem to get there! I have Ubuntu 14.04.2 running alongside OS X Yosemite on my MacBook Pro.

I have the rEFInd boot manager installed, but I can delete it. I've tried holding Shift while booting any of the three (?) options to boot Ubuntu, and tried holding C as well.

Whatever I do, I can't seem to get into recovery mode.

Here are the three options I get in rEFInd, as well as OS X:

  • Boot boot\vmlinux-3.16.0-41-generic from 14GiB ext4 volume
  • Boot boot\vmlinux-3.16.0-30-generic from 14GiB ext4 volume
  • Boot Linux from whole disk volume

Can anyone help me please? Bear in mind I can't run any sudo commands as I can't remember my password.

1

You can boot a LiveCD from CD/USB, mount Ubuntu and chroot into it.

After booting the LiveCD open a Terminal and type sudo fdisk -l /dev/sda. This will show you which partitions are in use:

$ sudo fdisk -l /dev/sda

Disk /dev/sda: 17.5 GB, 17515986944 bytes
255 heads, 63 sectors/track, 2129 cylinders, total 34210912 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004634f

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048    31082495    15540224   83  Linux
/dev/sda2        31084542    34209791     1562625    5  Extended
/dev/sda5        31084544    34209791     1562624   82  Linux swap / Solaris

You need to find that line which is has Linux in the last column. In this case /dev/sda1 is your root partition. If you've more than one line with System Linux you'll have to try out

$ sudo mount /dev/sdaX /mnt #where sdaX is your root partition
$ ls /mnt
bin     dev      home      media     proc      sbin     tmp     var
boot    etc      lib       opt       root      sys      usr

The output of ls /mnt should look like this or you've choose the wrong partition. If so unmount it with sudo umount /mnt and try again. If you found the correct root partition proceed with:

$ sudo mount --bind /dev /mnt/dev
$ sudo mount --bind /proc /mnt/proc
$ sudo mount --bind /sys /mnt/sys
$ sudo chroot /mnt
$ passwd YOUR_USER_NAME

After setting a new password type:

$ exit
$ sudo umount /mnt/dev
$ sudo umount /mnt/proc
$ sudo umount /mnt/sys
$ sudo umount /mnt
$ sudo reboot
  • Okay I'm on a LiveUSB now. What do I put on the first line again? Very newbie question, but where is my root partition? I have two root folders in front of me, one on the "Computer" (which I assume is the USB) and one on my 15GB Ubuntu Partition. – Woody Jun 27 '15 at 0:04
  • @Woody I updated the answer – Germar Jun 27 '15 at 1:19
  • That's fantastic, a really helpful guide! You've really saved a lot of important information of mine. – Woody Jun 27 '15 at 15:44
  • @Woody I'm glad I could help. Please consider marking this as your accept answer by clicking on the grey checkmark – Germar Jun 27 '15 at 16:06
1

If you press the Insert, F2, or + key, rEFInd will show a menu that may hold additional options, depending on the OS type.

From the options submenu, you can press the Insert, F2, or + key again to edit your boot loader options.

A simple text-mode line editor opens, enabling you to move a cursor back and forth in the line with your arrow keys, delete text, and type in new text. If you want to boot with your edited options, press the Enter key.

Source

Find the kernel line starts with /boot/vmlinux and add init="/bin/bash" at the end of the line to boot into root mode and change your password.

Source

  • I can't find the line you're asking me to look at. In the rEFInd line editor, all I get in the first two options I listed is: ro root=UUID=lotsofnumbers initrd=boot\initrd.img-3.16.0-41-generic. With the third option, there is nothing there. I get a kernel panic if I change anything. – Woody Jun 26 '15 at 23:39
  • In the rEFInd boot-options editor, the only line is what kyodake refers to as "the kernel line," but it omits /boot/vmlinux. Just add init="/bin/bash" to the options. – Rod Smith Jun 27 '15 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.