Monday, July 19, 2010

Humbling is...

humbling /ˈhəm-b(ə-)liŋ/
  1. adjective
    1. The realization that my $20 MP3 player can beat me at Chess.

Saturday, July 3, 2010

If, for some reason, you want to install Windows 7... here's how to make an installation USB drive, from Linux

Hey, do you remember CD-ROMs or DVDs?  They were these round things that you put in your computer... made a lot of noise.  Stored files, but not very many.  Not very fast.  A pain to deal with.  Nobody uses them anymore, now that we just download music and movies off the Internet and exchange files online or via flash drives.  Nobody, that is, except for my mom, who was upset when her DVD drive broke a few months ago...

Anyway, I digress: my mom is evidently not the only one who still uses DVDs.  Microsoft still distributes DVDs for installing and upgrading Windows 7.

My Acer 1410 notebook is awesome, but one of the least-awesome things about it is that it came with Windows Vista.  Not just Vista, but Vista loaded up with a whole lot of crapware courtesy of Acer, including about 500 flash games that have to be uninstalled individually.  Basically the first thing I did with the computer was to install Ubuntu instead of Vista.

But then Acer sent me free DVDs to upgrade to Windows 7... which I heard sucked less than Vista.  So I decided to give it a shot.  But here's the thing: the Acer 1410 doesn't have a DVD drive, since no one except my mom and Microsoft uses them anymore.  So how to install Windows 7?

Windows 7 can be installed from USB drives

Although Windows 7 is still distributed on DVD, it's smarter than Windows XP or Vista (but still only as smart as, say, Linux circa 2000).  Windows 7 can install itself from a USB drive, or pretty much anything... I actually used a 4 GB SD card since I have a bunch of those lying around.

There are a bunch of guides on the Internet that explain how to copy your Windows 7 DVD onto a USB drive and make it bootable.  There's even an official tool from Microsoft to do it.  Unfortunately, these tools and procedures require that
  1. You have a computer with Windows running on it and a DVD drive
  2. You actually have to use Windows to prepare the USB drive... and, frankly, the idea of actually using Windows to prepare bootable media sounds excruciating to me
Are you getting the feeling that I don't really know why I wanted to install Windows 7 in the first place?  Basically, I just wanted to find out if it sucks less than I imagined it would...

Anyway, if you are okay with the above requirements, you can use Windows to transfer your Windows 7 installation DVDs to USB, and be on your merry way.  But, for me...

Making a Windows 7 USB stick from within Linux

You need a flash drive or memory card with at least 4 GB capacity to hold the entire contents of the Windows 7 installation DVD.  Be aware that everything on the USB drive will be erased!!!  Oh, and you need a DVD drive on your Linux computer too.

Plug in the USB drive on your Linux computer, and figure out the device node assigned to it (perhaps /dev/sdb or /dev/sdc).  If you don't know how to do this... ask.  If the flash drive is automatically mounted, then unmount it after you've checked to make sure that you've copied any important data off of it.

Now we need to blank the USB drive and format it with NTFS.  This detail is extremely importantIf you format the USB drive with FAT32, then the Windows 7 installation will start to work, but fail cryptically with messages about unavailable CD-ROM drivers... the Internets are littered with confused forum postings by others who have stumbled on this weird bug.

So, let's use GNU Parted (which should be installed on most modern Linux systems).  First, blank the partition table (replace /dev/sdX with the appropriate device node for your USB drive):

$ sudo parted /dev/sdX
(parted) mklabel msdos
Warning: The existing disk label on /dev/sdb will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? yes


Next, create a new partition filling the USB drive, make it bootable, and then check that it worked by displaying the partition table:

(parted) mkpart primary ntfs 1c 100%
(parted) set 1 boot on
(parted) print
Model: Multiple Card Reader (scsi)
Disk /dev/sdX: 4094MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  4094MB  4093MB  primary  ntfs
 
(parted) quit


Sweet.  Now you have to format the newly-created NTFS partition:

$ sudo mkntfs --fast /dev/sdX1 
Cluster size has been automatically set to 4096 bytes.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.

Here's a slightly tricky part: you have to give the USB drive an appropriate Windows 7 boot sector.  There's a great program called ms-sys for this sort of thing, and I have made pre-built ms-sys packages for Ubuntu.  So install it.  Use ms-sys to make an appropriate boot sector for the USB drive:

$ sudo ms-sys --mbr7 /dev/sdX
Windows 7 master boot record successfully written to /dev/sdX


Finally you have to copy the installation files onto the USB drive.  Mount the newly-created NTFS partition, however you usually mount removable media.  Also, take the Windows 7 installation DVD and mount it.  You may wish to pause for a moment to think about how quaint the DVD is, and to remind yourself which way is "up" on the DVD drive.


Copy allllll the files and directories from the DVD to the USB drive.  You can use a graphical file manager like Nautilus, or do it from the command line with rsync, using something like this:


$ rsync -av /mnt/dvd /mnt/usbdrive 
Slow...
Progress...
While...
We...
Copy...
A...
Bajillion...
Files
done!


And finally, you're done!  Unmount the USB drive and boot off of it on the computer you're trying to install Windows 7 onto.  Windows 7 actually installs fairly quickly, but I must warn you that it will overwrite other operating systems' bootloaders without asking.  So if you plan to dual-boot Windows and Linux/*BSD/etc., be sure that you have something like SystemRescueCD or a bootable Linux flash drive so that you can recover the bootloader.

Epilogue: Windows is still lame

So after all this rigamarole, I have Windows 7 installed on my Acer 1410 notebook alongside Ubuntu.  Whoopty-do.  Windows 7 seems to run a little faster than Vista, and without the crazy screen flickering problems when you suspend and restart.


If you like Ubuntu and are sick of XP and Vista, you still won't like Windows 7.  It's the same old same-old as far as I can tell.


Back to Ubuntu for me. :-)