Replacing a forgotten root password in Fedora 15

At school, one of the classes I teach is the Linux class. In this class, we use Fedora 15. One of my students had forgotten the root password of his machine, and despite trying everything he could think of, he wasn’t able to guess what he had set the password to. He came to me looking for a way to reset the password.

The easiest way to do this is to boot into single-user mode. In single-user mode, you don’t need to log in; you’re automatically logged in to the root account. From there, you just need to run the “passwd” command, and you can set a new password for root.

It was a little more difficult than I expected. When Fedora 15 is installed, by default it installs the GRUB bootloader. If we have a choice of more than one operating system to boot into, the Fedora installation gives us a few seconds to select which one. During these few seconds, we can stop the boot process, then tell GRUB that we want to enter single-user mode (via a Linux kernel command-line argument), and away we go. However, if we only have a single OS on the computer, as was the case for my student, GRUB boots immediately into Linux, and we don’t have a chance to modify the kernel arguments. I knew there was some way to stop the boot, and after a little googling, I found the answer. I thought it was worth a blog post in case anyone else runs into this situation.

Short answer: hold down the shift key as the computer is booting, then GRUB will allow you to specify single user mode.

Here’s the longer answer.

Turn on the computer, and as the computer is booting, press and hold the shift key. If you time it right (if you press and hold too early, GRUB won’t recognize the keypress), you will see the following screen:

Initial GRUB screen

That’s GRUB. OK, we want to edit the kernel command-line arguments (you can find a complete list of them here), so at this point press the “a” key. You’ll go into a screen that allows you to edit the arguments:

Editing the kernel parameters

To enter single-user mode, you just need to append an “S” to the end of the command line, being sure to leave a space between the previous last argument and the S. See the screenshot below for what it should look like.

After adding the single-user kernel parameter

Once you’ve got that, just press the Enter key, and you’ll boot into single-user mode (also known as rescue mode — because it will rescue you from the forgotten root password!). You’ll be at the console, not the GUI, and your screen will look like this.

In single-user mode

Now, we can run the “passwd” command, and enter in the new password. The password won’t be displayed on the screen, but we’ll be asked to enter it twice, to make sure we didn’t make a typing mistake. After running the command, your screen will look like:

After changing the password

Once that’s done, you’ll be able to use your new password to log in to your root account. Now, just type CTRL-D, and the system will boot as normal, and away you go!

Moving Time Machine backups to a new disk on a Mac

On my Mac, I’ve got a 1 TB external USB drive to hold my Time Machine backups, and I’ve got a 360 GB drive to hold my media files. Unfortunately, I’ve ripped too many of my DVDs, and now my media drive is full. This past weekend, I saw that Best Buy had a 2.5 TB USB drive for $99! (Not like this post will look dated in a year or so! 🙂 ) So, needing more drive space, I decided to pick one up.

OK, now I was faced with a difficult choice: do I use my new drive to hold my media and choose not to back up those files, or do I move my backups to the new drive, move my media files to the 1 TB drive, and take my 360 GB drive off-line? Well, I’d really be uncomfortable not having backups of my songs and videos, so I decided on the latter. I’ve got a Garibaldi board just dying to use that small drive for a new installation of MIPS Debian Linux, so my plan was set.

I wasn’t quite sure how to set up a new drive for Time Machine and maintain all my existing backups (you never know when I’ll need a file from 2008 — now you know why my basement is as full of “archives” as it is!), so I did a quick google search and found the answer on Apple’s support site. Unfortunately, it didn’t quite work for me, but I was able to find other information to help me to resolve my problem, so I thought I’d document it in a blog post in case anyone else runs into this problem.

The Apple knowledge base article, “Mac 101: Time Machine”, had the information I was looking for. About three-quarters of the way down the page is a section entitled “Mac OS X v10.6: How to transfer your backups from your current hard drive to a new hard drive”. That sounds exactly what I wanted, and it almost worked for me, but just not quite.

Here’s what the page had to say:

If you upgrade to a new hard drive with a larger capacity, you may want to transfer your existing Time Machine backups to it before using it for regular backups. To keep your existing backups on your new, larger backup hard drive, follow these steps:

  1. Connect your new hard drive.
  2. In Disk Utility, make sure it has a GUID partition and is formatted as Mac OS Extended (Journaled). If needed, reformat the drive as Mac OS Extended with a GUID partition. If you do not know how, see the steps in this article. Note: Back up any data on the hard drive before you format it.
  3. Select the new drive’s icon on the desktop and choose Get Info from the File menu.
  4. Make sure “Ignore ownership on this volume” is not enabled.
  5. Open Time Machine preferences in System Preferences.
  6. Slide the Time Machine switch to Off.
  7. In Finder, double-click the current backup hard drive to open its Finder window.
  8. Drag the folder “Backups.backupd” to the new hard drive.
  9. Enter an administrator user name and password, then click OK to start the copying process. This may take some time to complete because all your backups will be copied.
  10. In Time Machine System Preferences click “Select Disk…”
  11. Select your new hard drive, then click “Use for Backup.”

Now, on your new hard drive, you will have all of your existing backups from the previous backup hard drive plus have more room for more new backups.

As I worked through the steps, my first problem came at step number 9. Because my original backup disk was formatted as “Mac OS Extended (Case-sensitive, Journaled)”, and because step 2 instructed me to create a non-case-sensitive partition, I got an error. That was easy to fix — just go back to step 2 and create a case-sensitive partition.

My next problem also occurred in Step 9. After dragging “Backups.backupd” from the old drive to the new one, it proceeded to start copying. It took a long, long time — 1 TB takes a long time to transfer! I left it overnight, and when I checked on it the next morning, the Mac Finder reported an error with error code -8003, and copied some but not all of the files. I googled for that error code, but wasn’t able to find anything. I was (temporarily) stumped. Back to Google! I needed to find some way to copy that directory from the old to the new disk.

After some searching, I found this page: Apple Tips: Using Disk Utility 7. Copying a Volume via the Restore tab. This is a really good page, and tells how to copy an entire volume from one disk to another. This is EXACTLY what I needed. I’ll leave the details to that page (screenshots and all!), but basically, it describes how to use OS X’s Disk Utility’s Restore function to copy the contents of one drive to another.

Following those instructions, I was able to copy my old backups over to my new disk, turn off my old backup drive, and start using my new drive, with no problems! If you’re going to do something similar, just replace Steps 7 to 9 on Apple’s page with the instructions on the Apple Tips page. For the curious, it took about 25 hours (!) to copy over that terabyte of data.

Next, of course, I’ll be moving my media files from my 360 GB drive over to my 1 TB drive (the old backup drive). Again, this will be easily accomplished using the Disk Utility. Thanks, James Pond, for your Apple Tip!