Thursday, March 22, 2012

Nook Rooting and Mounting Drives in Unix

I got a Nook Simple Touch, because you can put Android on it and then use the Nook app, the Kindle app, or whatever pdf reader you want to read all of the ebooks, not just Amazon's or B&N's. To put Android on it, I used this guide. (this is for Nooks with firmware 1.1; here's the one for 1.0 or 1.0.1. Find your firmware version in Settings->Device Info->About Your Nook)

The process works as follows: download a disk image, put it onto a microSD card, put that card in the Nook, boot up the nook, and then do a bunch of things on the software to sign in to the Android Market and download apps. The tricky part for me was putting the image onto the SD card.

The command to put the image on the SDcard (where touchnooter-2-1-31.img is the name of the disk image file) is:
sudo dd if=touchnooter-2-1-31.img of=/dev/
The tricky part is that you have to replace "/dev/" with the name of your SD card. (this site clarifies: "where is your sdcard (for example /dev/sdc or /dev/mmcblk0, not the mount point of the sdcard or an existing partition like sdc1 or mmcblk0p1)." What does this mean?

If a volume (aka a partition of a drive) is "mounted", then it's got an alias in the big unix filesystem tree and you can access files on it. Usually, when you plug in an SD card or USB drive, the system mounts it automatically. You can just run the command "mount" to see what's already mounted; most of it didn't mean anything to me when I ran it, but at least I saw this:

/dev/sda1 on / type ext4 (rw,errors=remount-ro,commit=0)
which is my main hard drive's main partition, so that's interesting. You can also (in Ubuntu) use the "Disk Utility" to see what's mounted.

In Disk Utility, click on your card reader on the left, and you'll see in the top right "Drive" and in the bottom right "Volumes". Look for "Device:", which will tell you the name of the drive in the filesystem. For example, right now I've got a card in there that has one partition and a bunch of free space; the Drive is /dev/sdd and the Volumes are /dev/sdd1 (the existing partition) and /dev/sdd (the free space).

When you're running that sudo dd command above, you want to write to the drive, not a partition of that drive. I kept trying to dd the image to /dev/sdb1 (which was a partition of my SD card) instead of /dev/sdb (which represented the card itself). Once I wrote the file to /dev/sdb, it worked.

Note that playing around with dd is dangerous: if you accidentally write files to the wrong drive (like /dev/sda in my case), you can erase your hard drive. So make sure (via Disk Utility) that you're writing to the SD card.

Outstanding questions in my mind:
- what's the command-line tool that will tell me the same things that Disk Utility tells me?
- what is "/dev/sdb" and how does it get there? I guess it's just an identifier that refers to my SD card when I put it in, but why /dev/sdb? And what is it, is it a file descriptor or what? I think /etc/fstab and /etc/mtab are involved, but I'm not sure how; and who puts those two files there?
- is "unmounting" exactly the same as "ejecting" your SD card/USB drive?
- what does dd do that just moving the disk image file to the SD card doesn't do? According to wikipedia, dd is just a lower-level way to move raw data. So it can... cause some file to be run when you boot or something?

No comments:

Post a Comment