Undelete

Jun 26, 2011·
Julio Batista Silva
Julio Batista Silva
· 2 min read
blog Linux

Today I deleted some files from my external hard drive, which is formatted as ext4, and realized I had pointed at the wrong files. Luckily I know a few things about file recovery and managed to get everything back in 5 minutes. Here is the process:

  1. I immediately closed every application with access to that disk and unmounted the partition so the inodes would not be overwritten:

    julio@julio-acer ~> sudo umount /dev/sdb3
    
  2. I installed a program from the Arch Linux repository called extundelete, which uses the information written in the journal of ext3 and ext4 partitions to recover deleted files:

    julio@julio-acer ~> sudo pacman -S extundelete
    
  3. I read the program’s help (extundelete --help) and the instructions available at http://extundelete.sourceforge.net.

  4. I changed to my home directory (which is on the internal drive) and ran the following command, which recovers every deleted file in the given directory:

    julio@julio-acer ~  $  sudo extundelete /dev/sdb3 --restore-directory "Documentos/Música/recorder"
    WARNING: Extended attributes are not restored.
    Loading filesystem metadata … 14145 groups loaded.
    Loading journal descriptors … 25337 descriptors loaded.
    Searching for recoverable inodes in directory Documentos/Música/recorder …
    149 recoverable inodes found.
    Looking through the directory structure for deleted files …
    Restored inode 100928610 to file RECOVERED_FILES/Documentos/Música/recorder/Metodo per Flauto Dolce (1^ parte).pdf
    Restored inode 100928611 to file RECOVERED_FILES/Documentos/Música/recorder/Metodo Per Flauto Dolce (2^Parte).pdf
    Block 404247082 is allocated.
    Failed to restore inode 100928612 to file RECOVERED_FILES/Documentos/Música/recorder/Metodo per Flauto dolce (adatto per scuola media).zip:Some blocks were allocated.
    Failed to restore inode 101040146 to file RECOVERED_FILES/Documentos/Música/recorder/metodo:Inode does not correspond to a regular file.
    145 recoverable inodes still lost.
    

Done! The files I had deleted were the two PDFs, which the program recovered successfully and put into a folder called RECOVERED_FILES.

Julio Batista Silva
Authors
Senior Cloud Developer

I’m a Brazilian computer engineer based in Germany, passionate about tech, science, photography, and languages.

I’ve been programming for about two decades already, exploring everything from mobile apps and web development to machine learning. These days I focus on cloud SRE and data engineering.

I volunteer in the open source and Python communities, helping organize PyCon DE and PyData Berlin, mentoring, and contributing with code and translations.

On my blog, I share Linux tips, setup guides, and personal notes I’ve written for future reference. I hope others find them helpful as well. The content is available in multiple languages.

Browse my gallery for some of my photography.

Away from the keyboard, you’ll find me at concerts, playing clarinet, cycling, scuba diving, or exploring new places, cultures, and cuisines.

Always happy to connect! 🙂

comments powered by Disqus