|
We all know Linux, delete the file you want to restore hard! And commands and tools under a different file system recovery may not be the same. Below that treated with debugfs, Linux comes with command, on the ext3 file system recover deleted files attempt.
[Root] # mkdir / root / test // -> build test folder
[Root] # cd / root / test // -> to enter the directory
[Root] # touch test.txt // -> build test file name
[Root] # cat / proc / meminfo >> test.txt // -> test file to write
[Root] # cat test.txt
MemTotal: 16432172 kB
MemFree: 7577528 kB
Buffers: 896832 kB
Cached: 5724212 kB
SwapCached: 0 kB
Active: 2737104 kB
Inactive: 4246932 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 16432172 kB
LowFree: 7577528 kB
SwapTotal: 16777208 kB
SwapFree: 16777208 kB
Dirty: 1944 kB
Writeback: 0 kB
AnonPages: 362976 kB
Mapped: 179000 kB
Slab: 1756168 kB
PageTables: 9432 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
CommitLimit: 24993292 kB
Committed_AS: 1469296 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 291068 kB
VmallocChunk: 34359447031 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
Hugepagesize: 2048 kB
[Root] # rm test.txt // -> Delete this test file
[Root] # ls -lart // -> View Delete
total 12
drwxr-x --- 6 root root 4096 Aug 6 09:51 ..
drwxr-xr-x 2 root root 4096 Aug 6 09:52.
[Root] # mount -r -n / dev / mapper / vg00-lvol1 / // -> all the way back to only mount to prevent the use of other process
[Root] # df -h
Filesystem Size Used Avail Use% Mounted on
/ Dev / mapper / rootVG-root
83G 7.4G 72G 10% /
/ Dev / mapper / rootVG-tmp
3.9G 137M 3.6G 4% / tmp
/ Dev / mapper / rootVG-var
31G 5.0G 24G 18% / var
/ Dev / cciss / c0d0p1 145M 26M 111M 19% / boot
/ Dev / mapper / vgglobal-lvol2
27G 291M 25G 2% / home
/ Dev / mapper / vgglobal-lvol1
105G 7.3G 93G 8% / d / oss / global
[Root @ nas2ds1 test] # df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/ Dev / mapper / rootVG-root
ext3 86623180 7696528 74455460 10% /
/ Dev / mapper / rootVG-tmp
ext3 4062912 139456 3713744 4% / tmp
/ Dev / mapper / rootVG-var
ext3 31741856 5222564 24880892 18% / var
/ Dev / cciss / c0d0p1
ext3 147764 26611 113524 19% / boot
/ Dev / mapper / vgglobal-lvol2
ext3 27447508 297580 25755652 2% / home
/ Dev / mapper / vgglobal-lvol1
ext3 109806464 7579200 96649332 8% / d / oss / global
[Root] # debugfs // -> Use this command
debugfs 1.39 (29-May-2006)
debugfs: open / dev / mapper / rootVG-root // -> Open File System
debugfs: ls -d / root / test // -> View deleted files
16269861 (12). 16269793 (4084) .. < 16269863> (4072) test.txt
debugfs: logdump -i < 16269861> // -> node where the block view
Inode 16269861 is at group 497, block 16285700, offset 512
Journal starts at block 6182, transaction 1128695
FS block 16285700 logged at sequence 1128698, journal block 6330
(Inode block for inode 16269861):
Inode: 16269861 Type: bad type Mode: 0000 Flags: 0x0 Generation: 0
User: 0 Group: 0 Size: 0
File ACL: 0 Directory ACL: 0
Links: 0 Blockcount: 0
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x00000000 - Thu Jan 1 07:00:00 1970
atime: 0x00000000 - Thu Jan 1 07:00:00 1970
mtime: 0x00000000 - Thu Jan 1 07:00:00 1970
Blocks:
FS block 16285700 logged at sequence 1128704, journal block 6727
(Inode block for inode 16269861):
Inode: 16269861 Type: bad type Mode: 0000 Flags: 0x0 Generation: 0
User: 0 Group: 0 Size: 0
File ACL: 0 Directory ACL: 0
Links: 0 Blockcount: 0
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x00000000 - Thu Jan 1 07:00:00 1970
atime: 0x00000000 - Thu Jan 1 07:00:00 1970
mtime: 0x00000000 - Thu Jan 1 07:00:00 1970
Blocks:
FS block 16285700 logged at sequence 1128705, journal block 6819
(Inode block for inode 16269861):
Inode: 16269861 Type: bad type Mode: 0000 Flags: 0x0 Generation: 0
User: 0 Group: 0 Size: 0
File ACL: 0 Directory ACL: 0
Links: 0 Blockcount: 0
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x00000000 - Thu Jan 1 07:00:00 1970
atime: 0x00000000 - Thu Jan 1 07:00:00 1970
mtime: 0x00000000 - Thu Jan 1 07:00:00 1970
Blocks:
FS block 16285700 logged at sequence 1128707, journal block 6860
(Inode block for inode 16269861):
Inode: 16269861 Type: directory Mode: 0755 Flags: 0x0 Generation: 285284165
User: 0 Group: 0 Size: 4096
File ACL: 0 Directory ACL: 0
Links: 2 Blockcount: 8
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x53e18a66 - Wed Aug 6 09:52:38 2014
atime: 0x53e18a44 - Wed Aug 6 09:52:04 2014
mtime: 0x53e18a66 - Wed Aug 6 09:52:38 2014
Blocks: (0 + 1): 16312328
Found sequence 1127169 (not 1128751) at block 9518: end of journal
debugfs: quit // -> exit, execute the dd command, count is set to 1, skip to the value of just viewing, which was placed in the / tmp directory.
[Root] # dd if = / dev / mapper / rootVG-root of = / tmp / test.txt.bak bs = 4096 count = 1 skip = 16312328
1 + 0 records in
1 + 0 records out
4096 bytes (4.1 kB) copied, 4.1e-05 seconds, 99.9 MB / s
[Root] # cat /tmp/test.txt // -> check the contents, and consistent with the original!
MemTotal: 16432172 kB
MemFree: 7577528 kB
Buffers: 896832 kB
Cached: 5724212 kB
SwapCached: 0 kB
Active: 2737104 kB
Inactive: 4246932 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 16432172 kB
LowFree: 7577528 kB
SwapTotal: 16777208 kB
SwapFree: 16777208 kB
Dirty: 1944 kB
Writeback: 0 kB
AnonPages: 362976 kB
Mapped: 179000 kB
Slab: 1756168 kB
PageTables: 9432 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
CommitLimit: 24993292 kB
Committed_AS: 1469296 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 291068 kB
VmallocChunk: 34359447031 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
Hugepagesize: 2048 kB |
|
|
|