{"id":476,"date":"2000-01-01T03:00:00","date_gmt":"2000-01-01T03:00:00","guid":{"rendered":"http:\/\/adam.rosi-kessel.org\/weblog\/free_software\/code\/cautionary.html"},"modified":"-0001-11-30T00:00:00","modified_gmt":"1970-01-01T05:00:00","slug":"cautionary","status":"publish","type":"post","link":"https:\/\/adam.rosi-kessel.org\/weblog\/2000\/01\/01\/cautionary","title":{"rendered":"A Cautionary Tale"},"content":{"rendered":"<p><!-- keywords:Free Software --> <\/p>\n<p> Here&#8217;s a cautionary tale for all you folks. <\/p>\n<p> So I was going along, happily minding my own business, debianizing\/defenestrating a few new computers, when I needed to make root\/rescue disks. I went to my laptop, got the dd images and typed: <\/p>\n<p> dd if=root.bin of=\/dev\/hda bs=1024 conv=sync <\/p>\n<p> Boom. That was fast. And the floppy didn&#8217;t even spin. Hm&#8230; <\/p>\n<p> Now wait a minute&#8212;that&#8217;s \/dev\/hda, not \/dev\/fd0! That&#8217;s ME. But I wasn&#8217;t root??? <\/p>\n<p><pre> ~> ls -l \/dev\/hda brw-rw---- 1 root disk 3, 0 Mar 14 2002 \/dev\/hda ~> groups ...disk... <\/pre>\n<\/p>\n<p> Uh oh. I suddenly have the feeling of someone you see in the movies where the torso has been severed but they don&#8217;t feel it yet. I just overwrote the first 1024K of my hard drive with root.bin. <\/p>\n<p> But everything was still working fine, for the moment. I had overwritten my partition table and part of my hibernation partition, but none of my actual linux drive. <\/p>\n<p> So I foundered about for a bit, desperately not wanting to have to back up my whole drive and start over. I called my friend Dylan, woke him up (you never know with mathematicians!), and he gave me some very good ideas. <\/p>\n<p> It turns out my partition table was still in memory, in \/proc\/partitions. <\/p>\n<p> cfdisk \/dev\/hda failed (fatal error), but it turns out I could still run fdisk \/dev\/hda. <\/p>\n<p> So I manually recreated the partition table with fdisk from \/proc\/partitions (set the partition types), wrote it to disk, reinstalled grub, rebooted and crossed my fingers. <\/p>\n<p> Back to normal! <\/p>\n<p> Try recovering from such a disaster under Windows, and I&#8217;ll see you next year. <\/p>\n<p> A few lessons to be learned: <\/p>\n<ul>\n<li> Don&#8217;t put yourself in group disk! This might be obvious to some of you, but I had added myself in order to burn CDs (I should have created a different group, didn&#8217;t think about it at the time). <\/li>\n<li> Save a copy of your partition table! I was lucky based on what I did that the partition table was still in \/proc, but googling suggested that this is sometimes an invaluable recovery tool. Put your partition table somewhere else. There is a tool gpart that tries to guess your partition table based on the data, but having the information just makes it so much easier. <\/li>\n<li> Don&#8217;t dd over your hard drive. <\/li>\n<\/ul>\n<p> I guess that&#8217;s it. I hope my averted disaster is helpful to some of you. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a cautionary tale for all you folks. So I was going along, happily minding my own business, debianizing\/defenestrating a few new computers, when I needed to make root\/rescue disks. I went to my laptop, got the dd images and typed: dd if=root.bin of=\/dev\/hda bs=1024 conv=sync Boom. That was fast. And the floppy didn&#8217;t even [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[17],"tags":[],"_links":{"self":[{"href":"https:\/\/adam.rosi-kessel.org\/weblog\/wp-json\/wp\/v2\/posts\/476"}],"collection":[{"href":"https:\/\/adam.rosi-kessel.org\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adam.rosi-kessel.org\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adam.rosi-kessel.org\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/adam.rosi-kessel.org\/weblog\/wp-json\/wp\/v2\/comments?post=476"}],"version-history":[{"count":0,"href":"https:\/\/adam.rosi-kessel.org\/weblog\/wp-json\/wp\/v2\/posts\/476\/revisions"}],"wp:attachment":[{"href":"https:\/\/adam.rosi-kessel.org\/weblog\/wp-json\/wp\/v2\/media?parent=476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adam.rosi-kessel.org\/weblog\/wp-json\/wp\/v2\/categories?post=476"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adam.rosi-kessel.org\/weblog\/wp-json\/wp\/v2\/tags?post=476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}