Network cloning disks like a pro

October 20th, 2013 No comments

So you want to clone a hard drive over a network, it’s ok, we’ve all been there. We want quick and easy and preferably some level of integrity insurance.

Boot systemrescuecd on box boxes and make sure both have an IP address and can ping each other. My example IPs are listed below -it’s worth pointing out that you should only do this over a trusted network, there’s no transport level security so potentially someone could be intercepting your stream.


linux treats everything as files, so we can throw an iso image as easily as we can throw a hard drive, eg

nc -lp 1337 | dd of=/tmp/bigIsoFromSource.iso

dd if=./MyBigIso.iso | nc 1337

Nice (nice). Now, you should be running md5sum on the files at both ends to make sure it wasn’t corrupted in transport, but if it’s a big file (or a disk partition) that could take a while. Wouldn’t it be good if we could split the streams (or split the pipe) so we could send the same read data from dd to both netcat and md5sum on the source, and the same on the destination? tee is our friend.

nc -lp 1337 | tee >(md5sum) | dd of=/tmp/bigIsoFromSource.iso

dd if=./MyBigIso.iso | tee >(md5sum) | nc 1337

Cool beans, so now it gets checked on both sides of the network connection. It doesn’t let us see what’s going on though. you can send a `kill -USR1 <ddpid>` to dd’s process ID and it’ll print to stderror how far it’s gotten, but unless you stick it inside of wait it’s not automagically updating. For this we can use pipe viewer, which lets us see the state of data going through a pipe. If you’re feeling clever and know how big the file/partition/disk is, then you can pass the size to pv for even prettier output.

nc -lp 1337 | tee >(md5sum) | pv -s4.5G | dd of=/tmp/bigIsoFromSource.iso

dd if=./MyBigIso.iso | tee >(md5sum) | pv -s4.5G |  nc 1337

and then just to be silly we’re going to compress it and calculate the hashes on both sides for both the raw input/output as well as for the compressed file that gets shoved over the network (hey, cores are cheap, right?)

nc -lp 1337 | tee >(echo -e “compressed: $(md5sum)’\n) | pv -s4.5G | bunzip2 | tee >(echo -e “raw: $(md5sum)’\n) | dd of=/tmp/bigIsoFromSource.iso

dd if=./MyBigIso.iso | tee >(echo -e “raw: $(md5sum)’\n) | pv -s4.5G | bzip2 | tee >(echo -e “compressed: $(md5sum)’\n) |  nc 1337

*note nc under centos wants just the l and no p passing on the destination side, otherwise it errors out. so `nc -lp 13337` fails, but `nc -l 1337`works.

Categories: Linux Tags: , ,

CentOS/RHEL 5 wont boot when converted to vmware with SCSI/SATA Disk

October 20th, 2013 No comments

So you’ve taken your physical install of centos/rhel 5 and cloned the disk into a virtual machine, and now it won’t boot, or even mor eannoyingly it half boots and then tells you it can’t find it’s partitions even though it’s just happily read it’s way through boot.

The usual touted fix for this is to make sure your disk is set to IDE, and this does work, but it’s an annoying fix, so to work as a scsi disk:

edit /etc/modprobe.conf and remove any alias lines referring to scsi_hostadapter and replace with

alias scsi_hostadapter mptbase

alias scsi_hostadapter1 mptspi

alias scsi_hostadapter 2 ata_pixx

then we need to rebuild the initrd so these modules are available at boot

mkinitrd -fv /boot/initrd-$(uname -r).img $(uname -r)

and done; sync && reboot :)


Stepping up the game

August 13th, 2013 No comments

Wiresharking lo with a gui on a remote headless server:
(because when your ssl wrapped (stunnel) smtp auth fails, logs aren’t as good as bytes.)

ssh root@hrs
yum install xorg-x11-xauth dejavu-lgc-sans-fonts wireshark-gnome
ssh -X root@hrs

win -assuming you use linux on your desktop 😉

after the break, for windows:

Read more…

Categories: Howto, Linux Tags: , , , , new email stuffs

July 17th, 2013 No comments

Just tried setting up sky on a friends android and run into the new Yahoo! mess trying to find IMAP details. -They seem somewhat reticent to publish them, and people are having problems with the published SMTP. So…

It’s pretty easy to find the server addresses, resolves (and redirects) nicely but SMTP doesn’t. I’ll save the gory details; is where we’re poking. I’m also using for when the original cname fails.

me@here ~ $ping
PING ( 56(84) bytes of data.
64 bytes from ( icmp_seq=1 ttl=55 time=26.5 ms

As there’s no published IMAP config options, it’s up to us to work them out; nmap is our friend:

me@here ~ $ nmap

Starting Nmap 6.25 ( ) at 2013-07-17 21:28 BST
Nmap scan report for (
Host is up (0.046s latency).
Other addresses for (not scanned):
rDNS record for
Not shown: 997 filtered ports
80/tcp  open  http
143/tcp open  imap
993/tcp open  imaps

Nmap done: 1 IP address (1 host up) scanned in 12.68 seconds

-so, we see options for both secure and insecure IMAP; nice. Lets do SMTP whilst we’re here:

[code]me@here ~ $ nmap

Starting Nmap 6.25 ( ) at 2013-07-17 21:30 BST
Nmap scan report for (
Host is up (0.031s latency).
rDNS record for
Not shown: 991 filtered ports
25/tcp  open   smtp
80/tcp  closed http
110/tcp closed pop3
143/tcp closed imap
443/tcp closed https
465/tcp open   smtps
587/tcp open   submission
993/tcp closed imaps
995/tcp closed pop3s

Nmap done: 1 IP address (1 host up) scanned in 5.98 seconds[code]

Cool, that’s a bit more going on. Massive respect to them for actually respecting the standard and having 587 open. 465 looks promising.

So, here’s what you need to know

username: [email protected]

IMAP: 993
Security : SSL

Port: 465
Security: SSL

pro-tip: lots of mail clients don’t use the when they try and probe. Also, Thunderbird’s account setup menu makes it looks like it auto-prefixes the imap/pop part of the hostname; it doesn’t.

Also, Yahoo! deserves some credit at the moment…

Categories: Howto Tags: , , , , ,

A quick thought about SSDs

April 28th, 2013 2 comments

my slow 160tb system disk. Slow but still SATA II

After the break some quick screenshots of HDD benchmarks. -Look at the speed on the SSD 😉

Also, can you believe Samsung 256GB SSD for under £60? Get me one of those :)

Read more…

Categories: HardWare, Linux Tags: , ,

Max Payne in 2013

April 28th, 2013 No comments

portrait, as cropped from my screenshot of the loading screen.

TLDR: Don’t bother with windows, use linux 😉

I’d already been talking about fond Max Payne memories last week, so when Steam did one of their ridiculous sales; Max Payne 1 and II for only $2.50, I had one of those dangerous spur of the moment impulse buys, forgot about affording bread & milk and dropped the cash.

When I bought it, my brother pointed out that ‘he had my old copy somewhere at home’ -‘and anyway, [I] could just download it easily’, but for some reason I had the impression that if Steam were going to sell it, they’d have at least made sure it was fully patched and ready for play. This would be easier all in, I thought. I’m feeling a bit bloody disappointed right now.

I download & install only to find it wouldn’t work on either of my Windows 7 boxs at all at all. The install would go through absolutely fine (a tiny 700MB) and then it’d refuse to start.

but my card always was!

Max Payne requires a DirectX 8 compatible display adapter. Please consult the troubleshooting readme in the installation folder

it scolds me, and refuses to do any more. And no amount of Compatibility Troubleshooting helps me get past this either. Some googling suggested that newer drivers were the problem (I’m rocking an nVidia GeForce 9600GT (and a 7300 in the old machine)) so spent a couple of hours trying out some old and new graphics drivers all to absolutely no avail. 4 hours later and I still couldn’t get this bloody game to launch.

3AM and hours into this I gave up in disgust, apologised again to my brother and restarted into my usual GNU/Linux home… and then remembered WINE -and Max certainly reports as working nicely, so here come full instructions after the break: Read more…

Categories: Gaming Tags: , , ,

zsh magic

April 6th, 2013 No comments

sometimes you need to copy a file in a remote directory (like backing up a config file).
If its not in your current working directory, then you can end up with silliness like

cp /usr/src/linux/arch/x86/boot/bzImage /usr/src/linux/arch/x86/bzImage.backup

-lots of duplication. I’ve been trying to find a better way for years but never found it.

Khayyam in #Gentoo cracked it within moments of me asking (after setting me onto zsh (a different shell to bash))
with zsh you can do the clever thing of:

echo /usr/src/linux/arch/x86/boot/bzImage !#1.copy

which auto-expands to

/usr/src/linux/arch/x86/boot/bzImage /usr/src/linux/arch/x86/bzImage.backup

massive thanks to Khayyam who also has some immense .zsh customization & scripts on the go. He also suggests that you check out for more excellent tips :)

edit: in bash you can just do cp /path/to/file.png{,.old}

Categories: zsh Tags: ,

CW Touch Recovery on Samsung Galaxy S3

August 20th, 2012 No comments

CW Touch on SGS3

I’ve always used the clockwork mod recoveries, and apparently now they do a touch version for those phones without keyboards.

The easy install is a paid app from the market, but they give away the image for free, if you’re daring enough to flash it yourself. Here’s the easy way how (standard disclaimers apply: this worked for me, it might set you on fire. Sorry but not my fault if it does). Bits between `backticks` are commands to be executed (eg `echo “I am a command!”`).

We’re talking about the international SGS3, the GT-I900. It originally came from T-Mobile UK.

1. Get root.

2. Get the android dev tools so you can connect to your phone using adb. You’ll need to enable USB debugging too 😉

3. Head to the ClockworkMod download page and get the latest touch recovery for your “Samsung Galaxy S3 (GT-I9300)”, at the moment it’s recovery-clockwork-touch- Note the fact it’s a .img file.
Put this somewhere on your phone. I’m sticking it on the _internal_ SD-Card.

4. open a command prompt (`cmd` on windows) and check your PC can see your phone `adb devices`. You should see a device attached.

5. Get a shell on the phone (`adb shell`) and then get root (`su`). The end of your prompt should change from a $ to a # when you’ve got root. (eg, from “shell@android:/ $” to “shell@android:/ #”).

6. Change location to where you’ve got your image downloaded. On my phone/current firmware (stock samsung, latest) it’s /sdcard/, so `cd /sdcard/`. `ls` will list files, so you can make sure your image is there.
If you’re having problems finding the sdCard mount location, the _external_ sdcard seems to be at `/mnt/extSdCard` but you can get a list of mounts with `mount`.

7. Make a backup of your old recovery.
The recovery partition on the SGS3 seems to be as follows (found by WT Ho on the xda-developers forums)

/dev/block/mmcblk0p1 – unknown
/dev/block/mmcblk0p2 – unknown
/dev/block/mmcblk0p3 – /efs
/dev/block/mmcblk0p4 – unknown
/dev/block/mmcblk0p5 – kernel
/dev/block/mmcblk0p6 – recovery
/dev/block/mmcblk0p7 – unknown
/dev/block/mmcblk0p8 – /cache
/dev/block/mmcblk0p9 – /system
/dev/block/mmcblk0p10 – unknown
/dev/block/mmcblk0p11 – unknown
/dev/block/mmcblk0p12 – /data

so we’re interested in `/dev/block/mmcblk0p6`
`dd if=/dev/block/mmcblk0p6 of=./recovery-backup.img` makes a backup of our current image.

8. Blank the recovery partition:
Here be dragons! If things go wrong between now and the end of step 10, you might be buggered.
Probably not needed, but we write zeros to the recovery partition to blank it `dd if=/dev/zero of=/dev/block/mmcblk0p6`.

9. Write the new recovery -Still a dangerous place to be. Obviously you have a full battery and are in aeroplane mode?
“recovery-clockwork-touch-” is the name of the image. If you’ve got it in a zip or tar file then you should have extracted it first. I’ve renamed it to “recoveryTouch.img” for ease.
`dd if=./recovery.img of=/dev/block/mmcblk0p6` flashes the image to the partition.

10. `sync` afterwards, because it’s just a nice thing to do

11. Switch off the phone in the usual way, and then hold down [Volume UP] + [menu] + [Power] to switch it back on.
You should now be booted into your nice new touch recovery.

12. Touch the screen and enjoy. “reboot system now” to exit

Categories: SGS3 GT-I9300 Tags: , , ,

Pro-Active Destruction

May 21st, 2012 No comments

so I finally updated the website and theme and apparently it’s broken the site somewhat.
If it wasn’t nearly 4am and I didn’t have things to do tomorrow I might have actually fixed it instead of posting this :S

Categories: Uncategorized Tags:

32bit Wine 64bit Gentoo

December 24th, 2010 No comments

Gentoo now lets you compile wine with the win32 or win64 useflags.

If you’re on 64bit linux then all your wine “prefix’s” become 64bit as default. My googling of the internet seems to suggest you need an entire 32bit chroot or other sillyness to have some good old 32bit action (I want to play Portal).

WINEARCH=win32 WINEPREFIX="/home/user/.wine-portal" wineboot

is what I’m grepping through my bash history looking for :)

Categories: Gentoo, WINE Tags: , ,