I lost my password to both root and sudo and need to remove ubuntu and erase my HDD. Needless to say this was a stupid newby screwup. I have backed up everything I want to save. How do I rescue my HDD?
1 Answers
If all that is wrong is you've forgotten your passwords, you shouldn't have to remove Ubuntu and erase your HDD. What I would do is simply boot up Linux in live mode from my Ubuntu USB thumb drive, chroot into the hard drive installation, and change your passwords. Easy peasy...
Boot from your Ubuntu USB Thumb drive in Linux Live mode. Don't re-install Ubuntu.
Once booted into live Linux, open a Terminal and start working through these commands:
mkdir linux
sudo mount /dev/sdXX linux
(replace "/dev/sdXX" with whatever device/partition number is correct for the "/" root Linux partition on your hard drive. You might need to run "gparted" to have a look at your partition tables to figure out what is what)
sudo chroot linux /bin/bash
mount -t devtmpfs udev /dev
mount -t proc proc /proc
mount -t sysfs sysfs /sys
passwd USERNAME
(replace USERNAME with whatever your user name was. Or use "root" to change the root password on your HDD).
The chroot command lets you operate on your HDD's Linux system as if you were booted from it, even though you're really booted from the USB thumb drive. It also acts kind of like "su -" in that you will be in your HDD's Linux as root (without requiring your HDD's root password).
Once all that is done, you have to unmount all the stuff we previously mounted from within the chroot environment before exiting. Otherwise, Ubuntu will have a hard time unmounting the Linux partition cleanly when you shutdown.
umount /sys
umount /proc
umount /dev
exit
sudo umount linux
sync
And there you have it. Shutdown and reboot into Linux on your HDD and you should be good to go!
- 276