Devastating slight of hand- deleted directory by mistake

No, it’s cli.

Is this an SSD or HDD you’re working with?

Do you have a spare external drive that can hold the entire capacity of your “sda7” home partition? (So that you can make true image file, that can be used for later data recovery.)


I can’t comment on ext4magic, either. However, it’s important to make an “image” of your disk or partition if feasible. That way you “preserve” that drive’s state, in which you can attempt data recovery at your own convenience.

Well, disk isn’t failing, so why bother? :stuck_out_tongue:

Well I might try that. I’m working with the ext4magic video right now. It looks like the directory above the one deleted can’t be listed for some reason, but I can view it with the Manjaro file viewer GUI fine. Anyway I guess I’ll try testdisk after that

what @winnie said:
make an image of the affected filesystem/partition to some other drive - to preserve the current state and have something to go back to should your recovery operation on the real data fail
dd is the tool to do that in that case

and now to perhaps get something straight in your understanding:

  • you boot the live system
  • nothing from your damaged system is mounted at that point
  • you refresh the mirror list (need an internet connection for that)
  • then you can update the live system - everything you do, including refreshing the mirror list, will only stay in RAM
    meaning: when you shut down your system, you will have to re-do everything again

the live system (the iso from which you boot) is not actually altered - what you do is just temporary
allowing you to

  • update the system, so you can then, finally, successfully install your recovery tool (extundelete)
    which you can then use (I have no experience whatsoever with this tool)

Shut the live system down - and you have to start all over again.

To work on your /home directory , you probably need to mount it
(again: I don’t know how that extundelete tool works)
but
when you need to mount it - you mount it read only (!)
no filesystem check, do not mount it read-write!

… but perhaps you have to mount it read write for the tool to work - I don’t know how this tool works

Have an image of the current state before you do something to recover your data.

If you did that, you likely didn’t check or care that you indeed mounted it in read-write mode.
Don’t - if you don’t have to.

Neither testdisk nor extundelete can be installed. Both come up with errors.
The only utility that can be installed is ext4magic, and that doesn’t work. Apparently there is a bug with that program (already reported, but no solution given).
You can list files right up to the directory above the deleted one, then it gives an inode not found message. Exactly like happened to this guy:

https://askubuntu.com/questions/1321156/ext4magic-does-not-recognize-directory

I’d like to try the other two utilities, but neither one of them will load.
When I try extundelete I get:

error: manjaro-keyring: signature from “Mark Wagie mark@manjaro.org” is unknown trust
:: file /var/cache/pacman/pkg/manjaro-keyring-20220514-2-any.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? (Y/n)

I pick YES, then
Failed to commit transaction (invalid or corrupted package).
error: target not found: extundelete

Something similar happens with testdisk.

Geez. Looks like this is going to be a long day : /

[manjaro@manjaro-cinnamon ~]$ sudo pacman -Sy testdisk
:: Synchronizing package databases...
error: failed retrieving file 'core.db' from mirror.rise.ph : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds
 core is up to date
error: failed retrieving file 'extra.db' from mirror.rise.ph : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds
 extra                                                             1839.7 KiB   915 KiB/s 00:02 [########################################################] 100%
 community is up to date
 multilib is up to date
:: Some packages should be upgraded first...
resolving dependencies...
looking for conflicting packages...

Packages (4) base-3-2  archlinux-keyring-20220927-1  manjaro-keyring-20220514-2  manjaro-system-20220727-1

Total Download Size:   0.54 MiB
Total Installed Size:  2.28 MiB
Net Upgrade Size:      0.82 MiB

:: Proceed with installation? [Y/n] Y
:: Retrieving packages...
 manjaro-keyring-20220514-2-any                                     548.8 KiB   363 KiB/s 00:02 [########################################################] 100%
(4/4) checking keys in keyring                                                                  [########################################################] 100%
(4/4) checking package integrity                                                                [########################################################] 100%
error: manjaro-keyring: signature from "Mark Wagie <mark@manjaro.org>" is unknown trust
:: File /var/cache/pacman/pkg/manjaro-keyring-20220514-2-any.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] Y
error: failed to commit transaction (invalid or corrupted package)
Errors occurred, no packages were upgraded.

in your case, for fixing the signature. open this file:
sudo nano /etc/pacman.conf and edit this line:
SigLevel = Required DatabaseOptional - its on the 45 line - press ctrl+/ and enter: 45;
to look like this:
SigLevel = Optional TrustAll
save the file: ctrl+x and try installing testdisk again:
sudo pacman -S testdisk

It ran forever then wrapped up with testdisk still bombing out with the same error when executed:

...
...
...
...
  -> Running build hook: [block]
  -> Running build hook: [filesystems]
  -> Running build hook: [keyboard]
  -> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-5.9-x86_64.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux59.preset: 'fallback'
  -> -k /boot/vmlinuz-5.9-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-5.9-x86_64-fallback.img -S autodetect
==> Starting build: 5.9.11-3-MANJARO
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [modconf]
  -> Running build hook: [block]
  -> Running build hook: [filesystems]
  -> Running build hook: [keyboard]
  -> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-5.9-x86_64-fallback.img
==> Image generation successful
==> Checking if graphic drivers need an update ...
:: Running post-transaction hooks...
(1/2) Reloading system manager configuration...
(2/2) Arming ConditionNeedsUpdate...

warning: testdisk-7.1-4 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...

Packages (1) testdisk-7.1-4

Total Installed Size:  1.66 MiB
Net Upgrade Size:      0.00 MiB

:: Proceed with installation? [Y/n] Y
(1/1) checking keys in keyring                                                                  [########################################################] 100%
(1/1) checking package integrity                                                                [########################################################] 100%
(1/1) loading package files                                                                     [########################################################] 100%
(1/1) checking for file conflicts                                                               [########################################################] 100%
(1/1) checking available disk space                                                             [########################################################] 100%
:: Processing package changes...
(1/1) reinstalling testdisk                                                                     [########################################################] 100%
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...


[manjaro@manjaro-cinnamon ~]$ testdisk
testdisk: error while loading shared libraries: libntfs-3g.so.89: cannot open shared object file: No such file or directory
[manjaro@manjaro-cinnamon ~]$

uch. Seems the same with the other utility.
Why would the only one that can be loaded, not work? Seems par for the course with me.

try installing the git version:
pamac build testdisk-git

How old is that iso image? 1 year? Manjaro is a rolling release. Using such an old iso image result only in problems…

My head hurts reading this…

  1. @jeffjot format your commands’ output properly as preformatted text. You’ve been here long enough. Or read how-to.

  2. @brahma why install -git when testdisk works fine. Don’t give stupid advice to do -Syy and then install a single program.

  3. @jeffjot, Update damn system. I told you already.

This forum is for laughter and facepalming lately…

2 Likes

i did it on purpose so that he doesnt waste time updating the iso, since he needs only one program installed…
also his iso is with 5.9 kernel, so i dont know if he would be even able to update it…

You can’t update database and install a single new package when everything else is old. How many times does this need to be said? Either install it with -S, and if that doesn’t work (because that version doesn’t exist anymore), then you have to update everything.

1 Like

wow.

It ran forever then ended up with this.
Man, if only I could just load the program so I could START the struggle lol.
Well,
:face_with_spiral_eyes:

file_xz.c:65:108: warning: unused parameter ‘safe_header_only’ [-Wunused-parameter]
   65 | static int header_check_xz(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                                                                         ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
file_xz.c:65:149: warning: unused parameter ‘file_recovery’ [-Wunused-parameter]
   65 | static int header_check_xz(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                                                                                                              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
file_xpt.c: In function ‘header_check_xpt’:
file_xpt.c:65:77: warning: unused parameter ‘buffer_size’ [-Wunused-parameter]
   65 | static int header_check_xpt(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                                          ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
file_xpt.c:65:109: warning: unused parameter ‘safe_header_only’ [-Wunused-parameter]
   65 | static int header_check_xpt(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                                                                          ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
file_xpt.c:65:150: warning: unused parameter ‘file_recovery’ [-Wunused-parameter]
   65 | static int header_check_xpt(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                                                                                                               ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
file_xv.c: In function ‘header_check_xv’:
file_xv.c:55:76: warning: unused parameter ‘buffer_size’ [-Wunused-parameter]
   55 | static int header_check_xv(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                                         ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
file_xv.c:55:108: warning: unused parameter ‘safe_header_only’ [-Wunused-parameter]
   55 | static int header_check_xv(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                                                                         ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
file_xv.c:55:149: warning: unused parameter ‘file_recovery’ [-Wunused-parameter]
   55 | static int header_check_xv(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                                                                                                              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
  CC       file_z2d.o
  CC       file_zcode.o
  CC       file_zip.o
  CC       file_zpr.o
  CC       utfsize.o
  CC       phmain.o
  CC       fat_unformat.o
  CC       pbanner.o
file_z2d.c: In function ‘header_check_z2d’:
file_z2d.c:53:77: warning: unused parameter ‘buffer_size’ [-Wunused-parameter]
   53 | static int header_check_z2d(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                                          ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
file_z2d.c:53:109: warning: unused parameter ‘safe_header_only’ [-Wunused-parameter]
   53 | static int header_check_z2d(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                                                                          ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
file_z2d.c:53:150: warning: unused parameter ‘file_recovery’ [-Wunused-parameter]
   53 |  header_check_z2d(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                                                                                                     ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~

file_zcode.c: In function ‘header_check_zcode’:
file_zpr.c: In function ‘header_check_zpr’:
file_zpr.c:53:77: warning: unused parameter ‘buffer_size’ [-Wunused-parameter]
   53 | static int header_check_zpr(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                                          ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
file_zpr.c:53:109: warning: unused parameter ‘safe_header_only’ [-Wunused-parameter]
   53 | static int header_check_zpr(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                                                                          ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
file_zpr.c:53:150: warning: unused parameter ‘file_recovery’ [-Wunused-parameter]
   53 | static int header_check_zpr(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                                                                                                               ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
file_zip.c: In function ‘header_check_winzip’:
file_zip.c:1350:53: warning: unused parameter ‘buffer’ [-Wunused-parameter]
 1350 | static int header_check_winzip(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                ~~~~~~~~~~~~~~~~~~~~~^~~~~~
file_zip.c:1350:80: warning: unused parameter ‘buffer_size’ [-Wunused-parameter]
 1350 | static int header_check_winzip(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                                             ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
file_zip.c:1350:112: warning: unused parameter ‘safe_header_only’ [-Wunused-parameter]
 1350 | static int header_check_winzip(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                                                                             ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
file_zip.c:1350:153: warning: unused parameter ‘file_recovery’ [-Wunused-parameter]
 1350 | static int header_check_winzip(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                                                                                                                  ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
  CC       pfree_whole.o
  CC       pblocksize.o
  CC       phbf.o
file_zcode.c:52:52: warning: unused parameter ‘buffer’ [-Wunused-parameter]
   52 | static int header_check_zcode(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                               ~~~~~~~~~~~~~~~~~~~~~^~~~~~
file_zcode.c:52:79: warning: unused parameter ‘buffer_size’ [-Wunused-parameter]
   52 | static int header_check_zcode(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                                            ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
  CC       pdiskseln.o
file_zcode.c:52:111: warning: unused parameter ‘safe_header_only’ [-Wunused-parameter]
   52 | static int header_check_zcode(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                                                                            ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
file_zcode.c:52:152: warning: unused parameter ‘file_recovery’ [-Wunused-parameter]
   52 | static int header_check_zcode(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
      |                                                                                                                                 ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
  CC       phbs.o
  CC       phnc.o
  CC       phcli.o
  CC       phrecn.o
  CC       ppartseln.o
  CC       psearchn.o
  CC       suspend_no.o
  CC       fidentify.o
  CXX      qphotorec-qmainrec.o
suspend_no.c: In function ‘suspend_memory’:
suspend_no.c:17:34: warning: unused parameter ‘cinfo’ [-Wunused-parameter]
   17 | void suspend_memory(j_common_ptr cinfo) {
      |                     ~~~~~~~~~~~~~^~~~~
suspend_no.c: In function ‘resume_memory’:
suspend_no.c:20:32: warning: unused parameter ‘cinfo’ [-Wunused-parameter]
   20 | int resume_memory(j_common_ptr cinfo)
      |                   ~~~~~~~~~~~~~^~~~~
  CXX      qphotorec-qphotorec.o
  CXX      qphotorec-qphbs.o
  CXX      qphotorec-qpsearch.o
fidentify.c: In function ‘file_identify’:
fidentify.c:308:35: warning: comparison of integer expressions of different signedness: ‘uint64_t’ {aka ‘long unsigned int’} and ‘off_t’ {aka ‘long int’} [-Wsign-compare]
  308 |    if(file_recovery_new.file_size > file_size)
      |                                   ^
  GEN      moc_qphotorec.cpp
  GEN      rcc_qphotorec.cpp
/usr/bin/mkdir -p lang
/usr/bin/mkdir -p lang
  GEN      lang/qphotorec.ca.qm
lrelease-qt5: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by lrelease-qt5)
lrelease-qt5: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by lrelease-qt5)
make[2]: *** [Makefile:3658: lang/qphotorec.ca.qm] Error 1
make[2]: *** Waiting for unfinished jobs....
  GEN      lang/qphotorec.cs.qm
lrelease-qt5: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by lrelease-qt5)
lrelease-qt5: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by lrelease-qt5)
make[2]: *** [Makefile:3658: lang/qphotorec.cs.qm] Error 1
qphotorec.cpp: In member function ‘void QPhotorec::PartListWidget_updateUI()’:
qphotorec.cpp:287:48: warning: ‘QString& QString::sprintf(const char*, ...)’ is deprecated: Use asprintf(), arg() or QTextStream instead [-Wdeprecated-declarations]
  287 |    partname.sprintf("[%s]", partition->partname);
      |                                                ^
In file included from /usr/include/qt/QtCore/qcoreapplication.h:44,
                 from /usr/include/qt/QtWidgets/qapplication.h:44,
                 from /usr/include/qt/QtWidgets/QApplication:1,
                 from qphotorec.cpp:59:
/usr/include/qt/QtCore/qstring.h:393:14: note: declared here
  393 |     QString &sprintf(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
      |              ^~~~~~~
qphotorec.cpp:292:45: warning: ‘QString& QString::sprintf(const char*, ...)’ is deprecated: Use asprintf(), arg() or QTextStream instead [-Wdeprecated-declarations]
  292 |    fsname.sprintf(" [%s]", partition->fsname);
      |                                             ^
In file included from /usr/include/qt/QtCore/qcoreapplication.h:44,
                 from /usr/include/qt/QtWidgets/qapplication.h:44,
                 from /usr/include/qt/QtWidgets/QApplication:1,
                 from qphotorec.cpp:59:
/usr/include/qt/QtCore/qstring.h:393:14: note: declared here
  393 |     QString &sprintf(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
      |              ^~~~~~~
make[2]: Leaving directory '/var/tmp/pamac-build-manjaro/testdisk-git/src/testdisk/src'
make[1]: *** [Makefile:446: all-recursive] Error 1
make[1]: Leaving directory '/var/tmp/pamac-build-manjaro/testdisk-git/src/testdisk'
make: *** [Makefile:385: all] Error 2
==> ERROR: A failure occurred in build().
    Aborting...
[manjaro@manjaro-cinnamon ~]$

@jeffjot, Update damn system. I told you already.>>>

Are you talking about creating a new bootable ISO? I’m just using this to undelete one directory. Though I certainly regret deleting it!

install this:
sudo pacman -S ntfs-3g
that should fix the missing library, and run testdisk again

[manjaro@manjaro-cinnamon ~]$ sudo pacman -S ntfs-3g
resolving dependencies...
looking for conflicting packages...

Packages (1) ntfs-3g-2022.5.17-1

Total Download Size:    0.54 MiB
Total Installed Size:   1.59 MiB
Net Upgrade Size:      -0.14 MiB

:: Proceed with installation? [Y/n] Y
:: Retrieving packages...
error: failed retrieving file 'ntfs-3g-2022.5.17-1-x86_64.pkg.tar.zst' from mirror.rise.ph : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds
 ntfs-3g-2022.5.17-1-x86_64                                         550.6 KiB   614 KiB/s 00:01 [########################################################] 100%
(1/1) checking keys in keyring                                                                  [########################################################] 100%
(1/1) checking package integrity                                                                [########################################################] 100%
(1/1) loading package files                                                                     [########################################################] 100%
(1/1) checking for file conflicts                                                               [########################################################] 100%
(1/1) checking available disk space                                                             [########################################################] 100%
:: Processing package changes...
(1/1) upgrading ntfs-3g                                                                         [########################################################] 100%
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...
[manjaro@manjaro-cinnamon ~]$ testdisk
testdisk: /usr/lib/libc.so.6: version `GLIBC_2.33' not found (required by testdisk)
testdisk: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by testdisk)
testdisk: /usr/lib/libncursesw.so.6: no version information available (required by testdisk)
testdisk: /usr/lib/libncursesw.so.6: no version information available (required by testdisk)
testdisk: /usr/lib/libc.so.6: version `GLIBC_2.33' not found (required by /usr/lib/libntfs-3g.so.89)
[manjaro@manjaro-cinnamon ~]$

Well, I can try creating a new bootable ISO, if somebody wants to point to the right one to use.