Monthly Archives: June 2012

Hard Drive Upgrade on Windows 7 and Fedora 17 Laptops

I recently upgraded the system drive in my Windows7 HP dv9000 laptop from its original 160G drive to a 500G drive using Clonezilla on a USB flash drive. I then used the 160G drive to upgrade my Fedora 17 T61 ThinkPad from its original 80G drive using using Clonezilla and System Rescue CD (also installed on a USB flash drive).

Step 1 – Windows 7 HP dv9000 Drive Upgrade

The first step was to clone my old system drive to the new one. I’d never used Clonezilla before, but installing it to a bootable USB drive was the hardest part of the exercise (download Clonezilla zip distribution, expand to a USB drive, execute Makeboot.bat – it’s all described under “USB setup with MS Windows – Method B: Manual” on the Clonezilla Live on USB flash drive or USB hard drive page). The dv9000 has two drive bays, so I moved the system drive to the secondary drive bay, put the new 500G drive in the primary drive bay, booted the laptop from the new Clonezilla USB drive, and accepted all the defaults for a disk to disk clone (including using novice mode). There was a confusing bit was when the screen text implied I needed to select an option with the space bar, but simply hitting Enter was what worked.

After cloning the drive, I removed the Clonezilla USB drive and the old system drive from the secondary drive bay, and rebooted. Woo hoo! Everything looks good, except I’ve got the same partitions on the new system drive that were on the old system drive (a ~159G “main” partition with Windows, my programs and my data, and a ~1G system restore partition where HP had put the WinXP install disks), and ~360G of unused space. The main partition needed to be grown to include the unused space.

Windows 7 Home Premium includes the capability to extend a disk partition, so I opened the Windows Disk Management tool (Control Panel / System and Security / Create and format hard disk partitions), but unfortunately found that partitions can only be extended into empty space on their right in the allocation display, and that’s where the system restore partition was. Hmmm….

The simplest solution was to delete the system restore partition, so everthing to the right of the 159G main partition was unused space. I rationalizing doing this as the system restore partition has the original 32-bit Windows Vista install, and since I was now using 64-bit Windows 7 from a DVD, and with no extra drivers needed, I didn’t think I would ever need the Vista install again. OK, right-click to delete the system restore partition, and another right-click to extend the (now only) partition. Easy peasy! I’ve now got lots more drive space for programs, pictures and video.

Step 2 – Fedora 17 ThinkPad T61 Drive Upgrade

Upgrading the drive in the Fedora T61 ThinkPad turned out to be a bit more complicated, partially because Fedora uses LVM  (Logical Volume Manager) and partially because the only USB flash drive the T61 would boot from (out of a half-dozen 1G to 8G drives) was the 1G drive I had installed Clonezilla on. Go figure, there must be magic involved in booting from USB drives (“Any technology sufficiently advanced is indisguishable from magic.”)

The T61 doesn’t have a 2nd internal drive bay like the dv9000, so instead of using Clonezilla to do a disk to disk clone, I cloned the T61’s 80G internal drive to an image file on an external USB drive (which was formatted with NTFS by the way), then replaced the old system drive with the “new” 160G drive from the dv9000, and cloned the image file to the new system drive (if I was more concerned about security, I should have wiped the drive first to eradicate its Windows data, but I didn’t).

Next I needed to extend the file system to make use of the 80G of unused space on the drive after cloning. Googling, I learned that Fedora 17 (and at least Fedora 16) by default creates partitions based on LVM (Logical Volume Manager), rather than a more simple system, which meant that extending a partition wasn’t going to be as easy as simply growing it into the unused space.

I had already assumed I was going to use GParted to grow an existing partition before I found out about LVM, and had gone ahead and installed System Rescue CD on a USB flash drive (because it includes GParted, and because I’d heard about it and had been waiting for a reason to try it out). Even though I now couldn’t use GParted, I still needed to boot the T61 with a live environment to work with the disk unmounted, so System Rescue CD still got a workout

I could probably have used the Fedora 17 live system I installed Fedora 17 with in the first place, except that the flash drive I had used had already been overwritten with Clonezilla, and then the System Rescue CD.

After a bit more research, making use of the unused space on the drive turned out to be a multiple step process:

  • Note the starting and ending cluster numbers of the LVM partition on the drive, and also the very last cluster number on the drive.
  • Use fdisk to delete the LVM partition (which removes the partition reference from the drive index structure, but doesn’t affect the data), and then create a new LVM partition starting at the same cluster as the original one, but ending with the last cluster on the drive (get what’s happening?)
  • Use pvresize to expand the physical volume used by the LVM, so that it occupies the entire partition (as extended by fdisk).
  • Use lvextend to extend the /home logical volume by the free space now available in the expanded physical volume (I could also have extended /root and /swap by giving up some /home space, but they seemed adequate already – /root was 45G and /swap was 6G).

The details are in the LVM Partition Resizing thread on LinuxQuestions.org (and a big thank you to mpdavig for a very clear and concise article!). I simply followed mpdavig’s instructions in a terminal shell from the System Rescue CD.

Dale

Using “new” PHP with “old” MySQL passwords

I recently encountered this error trying to connect Achievo to an existing corporate project-tracking database:

Critical: Unknown error: 2000 (mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD(‘your_existing_password’). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file).

To understand what’s going on, you need to understand a couple not-so-recent developments in PHP and MySQL:

  • MySQL version 4.0 and earlier used a 16-byte password hash, but starting with version 4.1+ uses a more secure password algorithm and 41 byte hash (although still supporting the older less secure password hash if needed).
  • The original external PHP module for accessing MySQL was mysql, but the current preferred module is mysqli (MySQL Improved).
  • The original low-level c-library that mysql (and mysqli) used to actually interface to a MySQL server was libmysql (included with MySQL), but starting with PHP 5.3 they are typically compiled with mysqlnd (a seperate project). mysqlnd has many advantages compared to libmysql, but it doesn’t support the old 16-byte MySQL password hash.

The database server I needed to connect to was running MySQL v5.0, and was configured with “old_passwords” set to On, which sets password operations to use the older 16-byte password hash (possibly because the original client/server application had been developed with MySQL 4.0 or earlier).

The simplest solution would have been to turn old_passwords Off and reset my password as the error message said (assuming the password column in the mysql.usr table would hold a 41-byte hash, otherwise its width would have to be increased first). However, the dba was loath to change the server configuration in case it broke existing mission critical enterprise applications, so I needed a different solution.

Since mysql and mysqli are compiled seperately, they can use different underlying c-libraries. In other words, mysql can be compiled to use libmysql – which supports the old 16-byte password hash. That would allow using mysql to connect to the corporate project-tracking database, without any effect on using mysqli to connect to other databases.

On a FreeBSD server, it was as easy as:

# pkg_delete php5-mysql
# cd /usr/ports/databases/php5-mysql
# make config  (uncheck support for mysqlnd)
# make install clean

and then edited the Achievo config.inc.php file to use mysql for the corporate database instead of mysqli.

Google Maps Experiment

I’ve been trying to spend a day a week of focused quality time at the keyboard working on Achievo, combined with a long weekly bike ride for thinking. Last Friday, I spent the day with my laptop in a quiet corner of the Mount Royal University library (my first alma mater). Although thunderstorms were in the forecast, I was feeling lucky and set out by bicycle (with a heavy-duty garbage bag for my laptop just in case). I made it to MRU without getting wet, enjoying beautiful but ominous thunderheads overhead, and was safe and sound by the time the rain started. Two thunderstorms later the weather cleared and I was able to ride home (steering clear of some major puddles!).

So here’s to the point of this post, my first embedded Google Map. It was pretty easy to create, but for some reason I can’t get the zoom level right in the image here (the top and bottom are always cropped). Oh well, you can always open the map by clicking the link.


View Calgary SW Bicycle Loop 1 (FCPP, MRU, Weaselhead) in a larger map

Ride on!

Fedora 17 on my T61 ThinkPad

On the encouragement of Victor, a low-level embedded ‘nix developer I had the pleasure of working with a few years back, I loaded Fedora 17 onto a T61 ThinkPad dev laptop (a recent glowing review on the Linux Action Show was added encouragement). I had avoided Fedora primarily due to its relatively short support period, but then thought “Hey, I’m not using it for my server,” (FreeBSD 8.3 has security support to June 2014) , “and I like the Fedora/REL relationship.” (REL seems to be the only ‘nix in local use that’s “corporately-approved” and even though I have no intention to leave FreeBSD, a greater familiarity wouldn’t be a bad thing).

Install was a breeze. I downloaded the F17 ISO and dd’d it onto a 1G usb key, configured the T61’s BIOS for USB boot, and backed up my OpenSuse ~/ directory. The T61 booted from the live F17 system on the USB key without issue and let me do some basic experimenting – configuring ‘net access through my WAP and a bit of repo browsing to make sure KeePassX was available. After seeing everything was OK, it was a couple clicks to install F17 onto the hard drive (the install even copied my WEP key from the live environment!).

The only issue so far is that I can’t shutdown directly from the desktop, first having to log out, and then shutdown (i.e., 2 steps). Could I be missing something? Meanwhile, I’m going to just suspend for now on and see how long I can go without a crash. Maybe it’s like a tablet, and Fedora is basically saying in normal operation you never actually shutdown.

Dale

P.S. I have put new howto in the knowledgebase for creating a PhpStorm / XAMPP/LAMPP / XDebug with Fedora 17. See How to install XAMPP and PhpStorm on Fedora 17.