I can't believe what I did today. I decided to install Gentoo on my box at work (replacing Debian, at least for now) and, becuase I still have to use a crappy computer with no CDRW drive (and I work in the software engineering subject group of a University - if I was a secretary, I'd have a p4 and a TFT monitor) I had to do it the not very nice way. What I did was - copy all of the things I wanted to keep - home directories, config files, my cvs tree, www and cgi-bin folders, and what else? Oh, yes: 3+ years of research) into a directory, delete everything else and the next step was to continue with the gentoo install.
I also thought, while I'm at it, I might as well switch to ext3, from ext2. And so I typed:
mke2fs -j /dev/hda2
My bowels shuddered as soon as I pressed enter, but for such a devestating operation, it took a lot less time to clean my partition than it took me to reach for C-c - not that it would have helped, probably.
Yes, I am now the not-so-proud owner of a nice clean ext3 partition.
Luckily, most of my research is also kept at home - thanks to CVS and working from home as much as possible, things tend to be synced.
There is still a bunch of things that I would like to recover, however, and I'm not sure how best to go about it.
What I do know is that I need an image of the partition to work on safely and at my leisure while I install gentoo on my work machine - I can't just not work until I have everything I want.
Now, the problem is, how do I get an image? I don't have a spare partition with 6.4 gigabytes of free space. Actually, I do, but that's the problem - it shouldn't be free, and obviously I can't use it.
The gentoo install CD handily has an ssh daemon, so I set that running and went home. I then tried to scp /dev/hda2 to my machine. No luck - scp complains about /dev/hda2 not being regular. Maybe that was the problem? My irregular filesystem needed more fibre, perhaps?
Thanks to some peeps on IRC, I found a solution. I'm in the process of transferring the files now, and this is how I did it:
- Compile netcat statically at home and sftp it to by work box
- Execute dd if=/dev/hda2 |./nc -l -p 123 & on my work machine (over ssh)
This has the effect of waiting for a connection on port 123, and when it gets one, spewing my partition at it.
- On my home machine, I then use nc my.work.machine.com 123 > disk.img
Which connects to the waiting port and dumps whatever it finds into disk.img.
This is taking place as we speak. I estimated and then calculated that this will probably take approximately 17 hours roughly, give or take, plus or minus 3 days.
Of course, I have no Idea how best to get the stuff out of the image aferwards, but if I have to grep through and take out text files by hand, I'll still have more than I have now. And I must admit, I'm having fun.
If anyone has any ideas on the best way to restore my files - preferably all, but some is also good - please let me know. Mail me at firstname.lastname@example.org with info and I promise, if we ever meet, I'll buy you lunch. Not necessarily a big lunch. Terms and conditions apply.