GNU/Linux >> Belajar Linux >  >> Linux

Mengapa Lsdel Di Debugfs Tidak Berfungsi?

Saya memiliki partisi /dev/sdb1 dengan sistem file ext3 dipasang di /mnt/folder .

Saya menyentuh file di /mnt/folder dan hapus file itu.
Kemudian saya menggunakan debugfs /dev/sdb1 lalu masukkan lsdel ,
tetapi dikatakan “0 inode yang dihapus ditemukan.”

Apa masalahnya? Bagaimana saya memulihkan file saya dengan debugfs ?

Jawaban yang Diterima:

Tidak cocok untuk ext3/ext4.

Dari pria :

list_deleted_inodes [limit]
    List  deleted inodes, optionally limited to those deleted within limit
    seconds ago.  Also available as lsdel.

    This command was useful for recovering from accidental file  deletions
    for  ext2 file systems.  Unfortunately, it is not useful for this pur‐
    pose if the files were deleted using ext3 or ext4, since  the  inode's
    data blocks are no longer available after the inode is released.

Contoh:

$ echo Hello > foo.txt
$ ls -ial
35692596 .
35692545 ..
35692597 foo.txt

$ sudo debugfs -R 'inode_dump <35692597>' /dev/sdc5

0000  b481 e803 0600 0000 82d0 d056 82d0 d056  ...........V...V
0020  82d0 d056 0000 0000 e803 0100 0800 0000  ...V............
0040  0000 0000 0100 0000 d36c 2f0b 0000 0000  .........l/.....
0060  0000 0000 0000 0000 0000 0000 0000 0000  ................
*
...

Karena ini adalah file kecil, kami hanya memiliki satu blok i_block (offset 0x28).

Di atas dapat ditata sebagai:

b481      |      81b4 = i_mode        : 0100664 (octal)
e803      |      03e8 = i_uid         :    1000
0600 0000 | 0000 0006 = i_size_lo     :       6
dbd7 d056 | 56d0 d7db = i_atime       : Fri Feb 26 23:55:23 CET 2016
dbd7 d056 | 56d0 d7db = i_ctime       : Fri Feb 26 23:55:23 CET 2016
dbd7 d056 | 56d0 d7db = i_mtime       : Fri Feb 26 23:55:23 CET 2016
0000 0000 | 0000 0000 = i_dtime       :       0
e803      |      03e8 = i_gid         :    1000
0100      |      0001 = i_links_count :       1
0800 0000 | 0000 0008 = i_blocks_lo   :       8, 8 * 512 = 4096 b
0000 0000 | 0000 0000 = i_flags       :       0
0100 0000 | 0000 0001 = i_osd1        :       1

Direct Block Address:

d36c 2f0b | 0b2f 6cd3 = i_block[0]    : 187657427
0000 0000 | 0000 0000 = ... no more

Kita dapat menghitung offset ke data dalam partisi berdasarkan ukuran blok (di sini 4096):

0x0b2f6cd3 * 4096 = 768644820992

Kemudian dibuang dengan cara langsung membaca:

$ sudo dd if=/dev/sdc5 bs=1 skip=768644820992 count=6 | hd
00000000  48 65 6c 6c 6f 0a                                 |Hello.|

Sekarang, jika kita rm foo.txt , satu bisa ambil data dengan dd yang sama perintah seperti di atas. Tapi itu bisa setiap saat ditimpa.

Tetapi jika kita tidak mengetahui offset ini, kita akan mendapatkan short.

$ ls -ai1
35692596 .
35692545 ..

$ sudo debugfs -R 'ls -d <35692596>' /dev/sdc5
 35692596  (12) .    35692545  (4084) ..   <35692597> (4072) foo.txt

$ sudo debugfs -R 'inode_dump <35692597>' /dev/sdc5

Data inode sekarang:

b481      | 
e803      |
0000 0000 | 0000 0000 = i_size_o      : 0                            *changed
dbd7 d056 | 56d0 d7db = i_atime       : Fri Feb 26 23:55:23 CET 2016
e5d7 d056 | 56d0 d7e5 = i_ctime       : Fri Feb 26 23:55:33 CET 2016 *changed
e5d7 d056 | 56d0 d7e5 = i_mtime       : Fri Feb 26 23:55:33 CET 2016 *changed
e5d7 d056 | 56d0 d7e5 = i_dtime       : Fri Feb 26 23:55:33 CET 2016 *changed
e803      |
0000      |      0000 = i_links_count : 0                            *changed
0000 0000 | 0000 0000 = i_blocks_lo   : 0                            *changed
0000 0000 |
0100 0000 |

0000 0000 | 0000 0000 = i_block[0]    : Zeroed out.                  *changed
0000 0000 |
0000 0000 |

Seperti yang Anda lihat, data blokir dihilangkan.

Terkait:SSH – Bagaimana cara membuat proses yang saya mulai selama sesi SSH berjalan setelah sesi berakhir??
Linux
  1. Mengapa Tidak 'menemukan' Tampilkan File Ini??

  2. Pam_unix2 / Mengapa Tidak Ada Di Beberapa Distribusi?

  3. Linux – Mengapa Setuid Tidak Bekerja??

  1. Mengapa Ekspansi Variabel Tanpa $ Bekerja Dalam Ekspresi?

  2. Mengapa `zip` Dalam A For Loop Bekerja Saat File Ada, Tapi Tidak Saat Tidak?

  3. Debian – Bluetooth Tidak Berfungsi Di Debian 10?

  1. Mengapa `\d` tidak berfungsi dalam ekspresi reguler di sed?

  2. Mengapa file EXE Windows tidak berfungsi di Linux?

  3. mengapa jembatan linux tidak berfungsi