{"id":1454,"date":"2023-03-01T23:34:00","date_gmt":"2023-03-02T05:34:00","guid":{"rendered":"http:\/\/blog.supportpro.com\/?p=1454"},"modified":"2026-03-27T02:46:44","modified_gmt":"2026-03-27T08:46:44","slug":"data-recovery-using-scalpel-and-foremost","status":"publish","type":"post","link":"https:\/\/www.supportpro.com\/blog\/data-recovery-using-scalpel-and-foremost\/","title":{"rendered":"Data recovery using Scalpel and Foremost"},"content":{"rendered":"\n<p><strong>Data recovery<\/strong> is the process of salvaging and handling the data through the data from damaged, failed, corrupted, or inaccessible secondary storage media when it cannot be accessed normally.&nbsp; The data is recoverable because the information is not immediately removed from the disk.<\/p>\n\n\n\n<p>Nowadays many tools are available for recovering lost data. Two of the most popular tool available are<strong> Scalpel<\/strong> and<strong> Foremost<\/strong>.<\/p>\n\n\n\n<p>In this article, let&#8217;s see how to recover lost data using these tools.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-white-background-color has-background\"><span style=\"text-decoration: underline;\"><strong>1. Scalpel<\/strong><\/span><\/h2>\n\n\n\n<p>Scalpel is an open source file system recovery for Linux and Mac operating systems.&nbsp; Its an open source program for recovering deleted data originally based on foremost, although significantly more efficient.&nbsp; The tool visits the block database storage and identifies the deleted files from it and recover them instantly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span style=\"text-decoration: underline;\"><strong>Installation<\/strong><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>&gt;&gt; From source code :<\/strong><\/h4>\n\n\n\n<p>In order to compile from source code, we need TRE in the server. We can download TRE from http:\/\/laurikari.net\/tre\/download\/<br>The source code for Scalpel&nbsp; is available on : https:\/\/github.com\/machn1k\/Scalpel-2.0<\/p>\n\n\n\n<p><strong>First install&nbsp; TRE<\/strong><\/p>\n\n\n\n<p><em>tar -xzvf tre-0.8.0.tar.gz<\/em><br><em>cd tre-0.8.0<\/em><br><em>.\/configure<\/em><br><em>make<\/em><br><em>make install<\/em><\/p>\n\n\n\n<p><strong>Now compile and install Scalpel<\/strong><\/p>\n\n\n\n<p><em>unzip Scalpel-2.0-master.zip<\/em><br><em>cd Scalpel-2.0-master<\/em><br><em>.\/configure<\/em><br><em>make<\/em><br><em>sudo make install<\/em><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>&gt;&gt; From yum repository<\/strong><\/h4>\n\n\n\n<p>Follow the below steps in order to install Scalpel from yum repo :<\/p>\n\n\n\n<p><em># yum install scalpel<\/em><\/p>\n\n\n\n<p>Sample Output :<br><em>==========<\/em><br><em>Loaded plugins: fastestmirror<\/em><br><em>Loading mirror speeds from cached hostfile<\/em><br><em>* base: centos.01link.hk<\/em><br><em>* epel: mirror.nus.edu.sg<\/em><br><em>* epel-source: mirror.nus.edu.sg<\/em><br><em>Setting up Install Process<\/em><br><em>Resolving Dependencies<\/em><br><em>&#8211;&gt; Running transaction check<\/em><br><em>&#8212;&gt; Package scalpel.i686 0:2.0-1.el6 will be installed<\/em><br><em>&#8211;&gt; Finished Dependency Resolution<\/em><\/p>\n\n\n\n<p><em>Dependencies Resolved<\/em><\/p>\n\n\n\n<p><em>=============================================<\/em><br><em>Package&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Arch&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Repository&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Size<\/em><br><em>=============================================<\/em><br><em>scalpel&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i686&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.0-1.el6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; epel&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 50 k<\/em><\/p>\n\n\n\n<p><em>Transaction Summary<\/em><br><em>=============================================<\/em><br><em>Install&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 Package(s)<\/em><\/p>\n\n\n\n<p><em>Total download size: 50 k<\/em><br><em>Installed size: 108 k<\/em><br><em>Is this ok [y\/N]: y<\/em><br><em>Downloading Packages:<\/em><br><em>scalpel-2.0-1.el6.i686.rpm&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp; 50 kB&nbsp;&nbsp;&nbsp;&nbsp; 00:00&nbsp;&nbsp; &nbsp;<\/em><br><em>Running rpm_check_debug<\/em><br><em>Running Transaction Test<\/em><br><em>Transaction Test Succeeded<\/em><br><em>Running Transaction<\/em><br><em>&nbsp;Installing : scalpel-2.0-1.el6.i686&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n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sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<\/em><\/p>\n\n\n\n<p><em>Complete!<\/em><br><em>==========<\/em><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span style=\"text-decoration: underline;\"><strong>Configuration<\/strong><\/span><\/h3>\n\n\n\n<p>By default, all the lines are commented with # in the configuration file.<br>In <em>scalpel.conf<\/em>, there are few lines which contain the file types that we can recover. For example gpg, doc, avi, doc, etc. So, before running Scalpel, you need to un-comment the file format that you need to recover.<\/p>\n\n\n\n<p>We just need to remove the # sign from the beginning of these lines in order to uncomment them.<\/p>\n\n\n\n<p><em># vi \/etc\/scalpel\/scalpel.conf<\/em>&nbsp; (uncomment the file format that needs to be recovered)<\/p>\n\n\n\n<p>After that please run the Scalpel. (As root)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em># scalpel \/dev\/sda1 -o \/home\/digit\/RECOVERY\/<\/em><\/code><\/pre>\n\n\n\n<p>=&gt; <em>\/dev\/sda1<\/em> is the location of the device where the files are already deleted.<br>=&gt;<em> \/home\/digit\/RECOVERY<\/em> is the place to accommodate the files that will be recovered from \/dev\/sdb1. \/dev\/sdb1 could also be the location of the folder where the data that we will recover.<br>=&gt; <em>\u2018-o\u2018<\/em> switch indicates an output directory, where you want to restore your deleted files. Make sure that this directory is empty before running any command otherwise it will give you an error.<\/p>\n\n\n\n<p>The scalpel is now performing its process and depending on the disk space you are trying to scan and recover, it will take time to recover your deleted file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-white-background-color has-background\"><span style=\"text-decoration: underline;\"><strong>2. Foremost<\/strong><\/span><\/h2>\n\n\n\n<p>Foremost is a command-line tool which can recover files from a number of file systems, including fat, ext3 and NTFS. It has many built-in file filters for fast recovery. ( e.g: jpg, zip, rar etc.)<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span style=\"text-decoration: underline;\"><strong>Installation<\/strong><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>&gt;&gt; From source code :<\/strong><\/h4>\n\n\n\n<p>The source code is available on the Foremost Sourceforge page: http:\/\/foremost.sourceforge.net\/<\/p>\n\n\n\n<p>Extract the archive and proceed with installation following the below steps :<\/p>\n\n\n\n<p><em># tar -xvzf foremost-1.5.7.tar.gz<\/em><br><em># cd foremost-1.5.7<\/em><\/p>\n\n\n\n<p>Before installation, open the Makefile and look for the below two lines : (Assuming installation of Foremost 1.5.7 on Mac OS X 10.8)<\/p>\n\n\n\n<p>macinstall: MAN = \/usr\/share\/man\/man1\/<br>macuninstall: MAN = \/usr\/share\/man\/man1<\/p>\n\n\n\n<p>Substitute the \u201cman1\u2033 by \u201cman8\u2033.<\/p>\n\n\n\n<p>Now the tool can be compiled and installed using the Mac directives:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>#make mac<\/em>\n<em>#make macinstall<\/em><\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>&gt;&gt; From repository :<\/strong><\/h4>\n\n\n\n<p><strong>#apt-get install foremost<\/strong><\/p>\n\n\n\n<p>Take a look at &#8216;#man foremost&#8217; to learn how to use foremost.<\/p>\n\n\n\n<p>The included configuration file is located in:<br><em>\/usr\/local\/etc\/foremost.conf<\/em><\/p>\n\n\n\n<p>This file will automatically be loaded if you don\u2019t specify another one by using the -c switch. By default, everything in this file is commented out, though. This means that Foremost will only look for the built-in types.<\/p>\n\n\n\n<p>Lets now see how to recover a file (an example jpg file) using Foremost tool :<\/p>\n\n\n\n<p>First, make an empty writable directory to save recover files in a partition other than that you are going to recover (\/home\/digit\/RECOVERY\/) and run foremost.<\/p>\n\n\n\n<p>Lets have a try with restoring the partition \/dev\/sda5.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>#foremost -t jpg -i \/dev\/sda5 -o \/home\/digit\/RECOVERY\/<\/em><\/code><\/pre>\n\n\n\n<p>Finally set user permission to \/recovery\/data\/ to view image. type<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>#chown YOUR_USER_NAME \/recovery\/data -R<\/em><\/code><\/pre>\n\n\n\n<p>Some important foremost command line arguments.<\/p>\n\n\n\n<p><em>&nbsp; -i&nbsp; :<\/em>&#8211; partition\/image to recover<br><em>&nbsp; -o :<\/em>&#8211; location to store recovered files.<br><em>-t&nbsp; :<\/em>&#8211; built in file filter options.&nbsp; you can give multiple filters by separating using commas. (e.g: for jpg and pdf: -t jpg,pdf )<br><em> -q :-<\/em> quick mode.<\/p>\n\n\n\n<p>In the recovered location you may see an audit.txt file. This audit.txt contains a summary of what foremost has done.<\/p>\n\n\n\n<p>If you require any help with configuration or install contact <a href=\"https:\/\/www.supportpro.com\/requestquote.php\">SupportPRO Server Admins<\/a><\/p>\n\n\n\n<div class=\"wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile is-vertically-aligned-center has-white-background-color has-background\"><div class=\"wp-block-media-text__content\">\n<p class=\"has-large-font-size\">Partner with <strong>SupportPRO<\/strong> for 24\/7 proactive cloud support that keeps your business secure, scalable, and ahead of the curve.<\/p>\n\n\n\n<!--HubSpot Call-to-Action Code --><span class=\"hs-cta-wrapper\" id=\"hs-cta-wrapper-3350a795-db50-482f-9911-301930d1b1be\"><span class=\"hs-cta-node hs-cta-3350a795-db50-482f-9911-301930d1b1be\" id=\"hs-cta-3350a795-db50-482f-9911-301930d1b1be\"><!--[if lte IE 8]><div id=\"hs-cta-ie-element\"><\/div><![endif]--><a href=\"https:\/\/cta-redirect.hubspot.com\/cta\/redirect\/2725694\/3350a795-db50-482f-9911-301930d1b1be\" ><img decoding=\"async\" class=\"hs-cta-img\" id=\"hs-cta-img-3350a795-db50-482f-9911-301930d1b1be\" style=\"border-width:0px;\" src=\"https:\/\/no-cache.hubspot.com\/cta\/default\/2725694\/3350a795-db50-482f-9911-301930d1b1be.png\"  alt=\"Contact Us today!\"\/><\/a><\/span><script charset=\"utf-8\" src=\"https:\/\/js.hscta.net\/cta\/current.js\"><\/script><script type=\"text\/javascript\"> hbspt.cta.load(2725694, '3350a795-db50-482f-9911-301930d1b1be', {\"useNewLoader\":\"true\",\"region\":\"na1\"}); <\/script><\/span><!-- end HubSpot Call-to-Action Code -->\n<\/div><figure class=\"wp-block-media-text__media\"><img fetchpriority=\"high\" decoding=\"async\" width=\"904\" height=\"931\" src=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup.png\" alt=\"guy server checkup\" class=\"wp-image-12943 size-full\" srcset=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup.png 904w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-291x300.png 291w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-768x791.png 768w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-585x602.png 585w\" sizes=\"(max-width: 904px) 100vw, 904px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Data recovery is the process of salvaging and handling the data through the data from damaged, failed, corrupted, or inaccessible secondary storage media when it cannot be accessed normally.&nbsp; The&hellip;<\/p>\n","protected":false},"author":5,"featured_media":13055,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[5],"tags":[],"class_list":["post-1454","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-general-topics"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/1454","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/comments?post=1454"}],"version-history":[{"count":7,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/1454\/revisions"}],"predecessor-version":[{"id":16772,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/1454\/revisions\/16772"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media\/13055"}],"wp:attachment":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media?parent=1454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/categories?post=1454"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/tags?post=1454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}