{"id":549,"date":"2009-11-11T13:43:20","date_gmt":"2009-11-11T12:43:20","guid":{"rendered":"http:\/\/sickel.net\/blogg\/?p=549"},"modified":"2010-01-30T12:25:09","modified_gmt":"2010-01-30T11:25:09","slug":"undeleting-in-linux","status":"publish","type":"post","link":"https:\/\/sickel.net\/blogg\/?p=549","title":{"rendered":"Undeleting in Linux"},"content":{"rendered":"<p><a href=\"http:\/\/sickel.net\/blogg\/?p=21\">P\u00e5 Norsk<\/a><\/p>\n<p>I accidentially deleted a lot of files from a memory card (xd-card, but the type shouldn&#8217;t matter). As I am only running Linux at home, the commersial solutions for windows that turned up on google were not usable, but the soulution turned out already to be there, just under my desktop,  <a href=\"http:\/\/lists.debian.org\/debian-user\/2003\/08\/msg02669.html\">fsck.vfat<\/a>:<\/p>\n<pre>carex:\/home\/morten# fsck.vfat -r -y -u \/dcim\/100_fuji\/dscf2389.jpg \/dev\/sda1\r\ndosfsck 2.11, 12 Mar 2005, FAT32, LFN\r\nUndeleting DSCF2389.JPG\r\nPerforming changes.\r\n\/dev\/sda1: 69 files, 3343\/15994 clusters\r\n<\/pre>\n<p>Luckily, I knew a file name. I started off with the last file, and worked backwards until fsck.vfat didn&#8217;t yield any more files. As I lost my cound, I managed to try to unerase some files twice, which truncated the file to 0 bytes, but the file showed up at the root of the file system:<\/p>\n<pre>[morten@carex ~]$ ls -l \/mnt\/cam\/fsck000*\r\n-rwxr-xr-x  1 morten morten 868352 1979-12-31 23:00 \/mnt\/cam\/fsck0000.rec\r\n-rwxr-xr-x  1 morten morten 868352 1979-12-31 23:00 \/mnt\/cam\/fsck0001.rec\r\n-rwxr-xr-x  1 morten morten 851968 1979-12-31 23:00 \/mnt\/cam\/fsck0002.rec\r\n<\/pre>\n<p>Three mvs later everyting was OK.<\/p>\n<p>This job looked quite scriptable, but for some reason, that did not work:<\/p>\n<pre>carex:\/home\/morten# for i in 9 8 7 6 5 4 3 2 1 0; do \r\n>fsck.vfat -y -r -u \/mnt\/cam\/dcim\/100_fuji\/dscf242$i.jpg \/dev\/sda1\r\n>done\r\ndosfsck 2.11, 12 Mar 2005, FAT32, LFN\r\nWarning: did not undelete file DSCF2429.JPG\r\n\/dev\/sda1: 27 files, 1303\/15994 clusters\r\ndosfsck 2.11, 12 Mar 2005, FAT32, LFN\r\nWarning: did not undelete file DSCF2428.JPG\r\n\/dev\/sda1: 27 files, 1303\/15994 clusters\r\n<\/pre>\n<p>Of cource, all this has to be done as root<\/p>\n<p>Hope this can help somebody else aswell. At least, it saved my marriage as the pictures were taken by my wife in her job&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>P\u00e5 Norsk I accidentially deleted a lot of files from a memory card (xd-card, but the type shouldn&#8217;t matter). As I am only running Linux at home, the commersial solutions for windows that turned up on google were not usable, &hellip; <a href=\"https:\/\/sickel.net\/blogg\/?p=549\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-549","post","type-post","status-publish","format-standard","hentry","category-data"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pnVtD-8R","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts\/549","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=549"}],"version-history":[{"count":5,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts\/549\/revisions"}],"predecessor-version":[{"id":680,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts\/549\/revisions\/680"}],"wp:attachment":[{"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=549"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=549"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=549"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}