3

I have a system (VM, actually) with Linux Mint 15 on it. The disk is encrypted, but I remember that password -- just not the password for my account. I've tried changing the command in GRUB from ro to rw init=/bin/bash, per guides online, but that doesn't seem to play nicely with the disk encryption. Is there a way to decrypt the disk, then drop straight to a root prompt (in order to use passwd)?

migrated from superuser.com Sep 5 '13 at 5:09

This question came from our site for computer enthusiasts and power users.

  • Are you able to boot off a live CD and mount the drive and go through the encryption authentication that way? – 50-3 Sep 5 '13 at 3:44
  • @50-3 I have a live CD ISO I can run. Can I change the password from there after mounting the drive? If so, how do I do both (mounting and changing password) -- I'm not very familiar. – NickAldwin Sep 5 '13 at 3:49
5

This is actually way easier than you might think. Here's how you do it:

  1. Boot into a Live CD.

  2. Decrypt and mount your partition on your hard disk. If you have a couple of partitions that all get mounted at boot, you will need to mount all of those, and in the correct order. Note that while you can get away with it this time, usually this includes bind-mounting /proc and /dev into the hard drive mountpoint.

    I won't go into how to do this, since I forget, but you should be able to find how to online (just search for "mount an encrypted partition linux" or something), or ask a new question here.

  3. If you haven't already opened a terminal, open one, and type chroot /path/to/your/encrypted/drive bash, where /path/to/your/encrypted/drive is where you mounted the hard drive partition.

    chroot stands for "change root". Root here is referring to the root of your directory tree, not the root account. Basically any program that you run from now on will see the hard drive, not the CD, as the root of the filesystem. bash at the end tells chroot what program to run from the new root - so you're running bash from your hard drive, not from the CD. bash will think it's executing from something like /usr/bin/bash, but in reality it'll be executing from /path/to/your/encrypted/drive/usr/bin/bash.

    If my garbled explanation was unreadable, here's the Wikipedia article and the manpage.

  4. Run passwd.

  5. Type exit to get out of the chroot and reboot out of the CD and into your hard drive.

  6. Profit.

  • Cool. I'll try this out when I can. – NickAldwin Sep 5 '13 at 6:37
  • 1
    Look for cryptsetup luksOpen with the correct options for your drive. You probably also have lvm, so vgchange -ay after the luks volume is mounted since dm-crypt with lvm is the default fde setup for Debian based systems. – Zoredache Sep 5 '13 at 7:34
  • Actually, for point 2, it should be enough to mount just the root file system, since passwd, all the libraries it needs, and /etc/passwd, are all normally squarely within the root file system. – a CVn Sep 5 '13 at 8:06
  • Unless you had /etc separated. Or /usr (if you're on Arch Linux), although this configuration is buggy as it is. – strugee Sep 5 '13 at 20:02
  • Sorry for the delay but I must wait for some non-corrupted RAM before I try this. I'll accept it once I can try it. – NickAldwin Sep 10 '13 at 3:14

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.