Deekoo is a peripatetic and iconoclastic game programmer with a thing for tentacles and a deep and abiding mistrust of the creeping surveillance state.

August 8, 2014:

How to clone and align a Windows XP partition from a Linux command line

The problem: You have an XP filesystem that's almost full by now, between the need to keep around a pile of craptastic Windows-only dev tools that you hate but might need to use someyear and the need to keep a copy of every game ever, plus scratch copies of the data for games you're actually working on. So you get a terabyte on sale. You've now got a blank Big Hard Drive and an old Windows drive.

The Maundering begins here. If you just want to clone windows WITHOUT the rant, skip to the 'END MAUNDERING' section.

It's possible to just partition the new drive, dd the old partitions over, and hit them with ntfsresize to expand the filesystems to fill the new partitions. The problem is that, for performance reasons, XP aligns filesystems to start on a cylinder boundary. This gives a major performance boost when you install XP on a drive that exposes its real CHS geometry to the OS, like exactly no drive still on the market when XP was released. If you've taken apart any recent drive, you'll have noticed that none of them actually have the 32 platters that a 63-head CHS geometry implies.

Modern hard drives tend to have a 4K physical sector size. (SSDs have a much larger physical sector size for reasons - but they tend to be aligned to powers of 2, not powers of 512*63.) And an assortment of random people on the Internet say that an unaligned partition will have shitty performance on a newstyle drive, which seems credible to me.

So after getting XP to boot on the new drive, I promptly turned around and tried to move the partitions to be properly aligned. Everyone says that XP boot partitions really don't like being moved, because they store a bunch of geometry information in the filesystem somewhere. Everyone is very, very right about this. A few hours and a few permutations of parted, fdisk, ntfsresize, and ntfsreloc later, I'm actually beaten down enough to try a GUI tool.

gparted is recommended by a lot of people, but the fact that the documentation has been rendered unreadable by dodgy SEO makes me less than comfortable using it. So I take a look at the Acronis Alignment Tool that everyone's recommending, because apparently Western Digital gave it away free to everyone - even non-WD customers - when they introduced 4K sector drives.

Western Digital's site is a pain to navigate. Ooh, they have 6GB drives- but I shouldn't be distracted by Big Hard Drives, I already HAVE all the Big Hard Drives I need. The form to download Acronis is broken - it asks a bunch of questions about the system I intend to use it on, then sends me to a page of search results instead of a download page. Blundering around their site further, I finally find an actual download link. <clickety>. ... It's an exe file. According to various peoples' instructions, I need to install it on a Winbox to burn the ISO to actually move the partitions. What? This sounds dodgy, but I *suppose* actively distributing malware would do enough damage to WD's rep that they wouldn't... So I recreate the unaligned clone of C I'd been using, boot the new drive into Windows, click 'ok' to all the unsigned drivers it wants to install to access the drives that it's... er, already accessing, turn the network back on, download Acronis from my Real Computer. Scan it for viruses. Nothing that $VIRUSSCANNER recognizes, though that doesn't mean much. Run it. Read the EULA.

Bluh bluh bluh legalese bluh bluh customer agrees to provide Feedback to Acronis about the operation of their tool bluh customer agrees that Acronis may collect and transmit information in secret and without further notification (Whaaat? Right, packet logger ON, I want to see what secret information this thing is transmitting) bluh bluh commercially reasonable efforts to notify customer of changes in terms of service, but... (Well, I can uninstall it when I'm done) bluh bluh several pages about backup services ... Will not disclose information unless required by law or regulation or government request (So basically Acronis can only turn over the information they collect to the NSA if the NSA asks them to.) also we can disclose any child porn (Huh? Well, I don't have any child porn.) content must comply with US law, Swiss law, and any other applicable law (... So no criticism of Putin or Erdogan or whoever your local authoritarians happen to be, check. Good thing I'm not under the jurisdiction of a country where it's illegal to criticize the leaders - oh wait, Swiss lese majeste laws also protect foreign leaders.)

So, by now I'm rather confused and uncomfortable about their EULA - it's pretty clearly the EULA for a private-sector panopticon thinly disguised as a cloud backup service, not a disk alignment tool. Did I download the wrong file or something? (Legal disclaimer: I'm summarizing the contract from memory. There may be errors in my summary. Don't rely on it.). But I kind of want to see what this damn thing tries to upload, and I can uninstall it when it's done, so... finishes skimming contract, clicks agree, waits... Slow install is slow. Slow install is still slow. Slow install wants to install a driver which has not passed WHQL testing for 'System Device'. What, no, no you cannot install fucking drivers, you're just there to save a fucking ISO, cancel.

Installation fails. Apparently it really doesn't like not being allowed to muck with the kernel. It saves an install log. Which locks up Notepad. What the hell is this thing, anyhow? A post-install Spybot scan finds an toolbar - should check with the person who actually uses this machine to see if it's intentional or something Acronis dropped.

Do further research. Find out that actually, everyone who said WD made the tool available free to everyone is full of shit (or, more charitably, perhaps it was available to everyone at the time the wrote it and NOW is only for WD customers.) Apparently the random search page was WD's user-friensdly way of saying 'You are not logged in. You need to log in to download this. You need the serial number from a Western Digital drive to log in. Also you need the serial number to be from a drive old enough that we think using XP on it is OK, not one of our new NAS drives.'

Upon consideration of the wisdom of jumping through hoops to install unlicensed probable malware, I decide 'screw this, I'm going to try gparted.'

So I install Debian, flail about for a while with grub and parted and fdisj (Because after enough flailing and argh, my typing kind of suffers) and ntfsreloc and ntfsresize, install gparted, start trying to move the partitions around. Resizing them doesn't make it clear whether they'll be aligned or not, and the fact that maxing out the size causes gparted to say I'm doing nothing at all makes me think it probably isn't actually going to align them. Maybe if I shrink the partition and move it to the end and then back to the beginning it will be properly aligned? Dunno, may as well try.

Beginning read-only test, 2:30:14 remaining.

... Screw this. My flailing has left the new drive's partition arrangement a complete and unholy mess, with an sda5 that Linux doesn't recognize, an out-of-order partition table (most of which is unaligned), no free space, and filesystems that have a good chance of STILL not booting even after I finish mucking with 'em. Hastur only knows what Acronis has left on the drive. Screw this. I'm going to delete all the partitions and start over.


So, here's the actual FAST instructions.

Make sure the new drive is the only one connected to the computer.

Boot from the Debian netinst CD. I used the standard (non-graphical) installer to create the partitions - which gave me properly sector-aligned partitions starting at 2048. (The extended partition it created was unaligned, but the logical partitions within it were properly aligned - and it's only the logical partition alignment which matters performance-wise IMO.) Finished the install, making sure to disable the 'Debian Desktop' and 'Print Server' options when selecting default package sets (no point downloading those for my purposes - the Debian install on this box will be used for sysadminly tasks, not as a desktop. If I need desktop stuff on it it'll probably all have updated _anyhow_.

Make sure you mark your C: partition bootable. I don't remember when I did it or whether I used fdisk or the installer's friendly partitioner, but.

Boot Debian on the new drive. apt-get install ntfsprogs. mkfs.ntfs on your shiny new NTFS partitions. (Note: By default, mkfs.ntfs will zero the entire partition. You can use the -Q option to skip that step if it's not needed. I see reports that zeroing is needed if you're planning to install Windows on the drive, as otherwise it may decide it needs reactivation or something. It started to zero the C: drive but was taking too long, so I ^C'd it and tried again with -Q. The data drive wasn't zeroed at all.)

Plug the old drive back in. Make sure the computer will boot off the new drive, not the old one.

Boot Debian. Mount your old Windows partitions. Also mount your shiny new Windows partitions. This example assumes that the new C: drive is mounted on /c and the old one on /old-c/ .

cp -a /old-c/* /c

SERIOUSLY THAT IS IT. Format the bootable NTFS partition under Linux and cp everything onto it, and IT WILL BE BOOTABLE.

Repeat the cp for any other Windows partitions you're copying over. Umount them all. Shut down. Unplug the old drive. Boot Debian. Run update-grub. Optionally, edit /boot/grub/grub.cfg so the default option is your XP install.

The only weirdness I've noticed so far is that it opens the desktop.ini files from the startup items folders in Notepad at boot. Depending on how you arranged the new partitions, there's a possibility you might wind up needing to manually reassign their drive letters.

{ 0x0 Comments | Comment }

May 4, 2013:

The city lights twinkle underfoot
wreathed in tendrils of mist
and still further below
dendritic inclusions of quartz
arc piezoelectric discharges
as, aeons-long slumber disrupted
the mountains shift uneasily

{ 0x1 Comments | Comment }

November 21, 2012:

I see time travellers, and they work in 'journalism'.

Bloomberg is happily running a puff piece under the headline "Wal-Mart Shoppers Seen Overrunning Black Friday Protesters" (never mind that the timestamp on the article is November 19th, and today is the 21st, and the protests they're talking about? Haven't happened yet, thanks.)

... I have to wonder how much of Wal-Mart's marketing budget goes to clandestine memetic manipulation - this isn't the first time I've noticed 'news' coverage of them that reads like advertising content.

Meanwhile, from the other direction, Docstoc sends the following gem:

Docstoc Newsletter - November 20, 2012 - SMB Stat of the Day

61% of Small Business Owners Plan to Vote for Romney
Romney is favored by small business owners over President Obama by a 35% margin.

Who will small business owners vote for in November?

... Hmm. I wonder who WILL win the election? Personally, my money's on Dewey.

{ 0x0 Comments | Comment }