CnUnix

[알림판목록 I] [알림판목록 II] [글목록][이 전][다 음]
[ CnUnix ] in KIDS
글 쓴 이(By): akira (Park_S_J_)
날 짜 (Date): 2002년 12월  4일 수요일 오후 03시 14분 55초
제 목(Title): 지운 파일 복구하기


rm으로 지운 파일 복구하는 방법을 찾아보니 잘 없군요.
'안됩니다. 백업 없으면 새로 짜세요.' 라는 답변만 보이네요.

Linux에만 해당되며 최근에 생성된 화일은 잘 안되는듯 하고 물론 지운 후 빨리 시행해야 합니다.
debugfs는 file system mount여부와 상관없이 device를 직접 엑세스 하기 때문에(아마)
빨리 file system을 unmount하고 진행하는 것이 좋을 듯 합니다.
그리고 root 권한으로 실행해야 합니다.

1. df로 해당 화일이 있던 file system의 device file을 확인한다.
2. debugfs /dev/[device] -R 'ls -d -l relative/path/to/dir' | grep [filename]
3. inode를 확인하고 debugfs /dev/[device] -R 'cat <[inode]>' 등으로 내용을 확인한다.
4. debugfs /dev/[device] -R 'dump <[inode]> newfile'

아래는 예입니다.

bar /home/foo/kids/CnUnix/www 251 % sum index.cc
26512    24
bar /home/foo/kids/CnUnix/www 252 % ls -asl index.cc
  24 -rw-r--r--    1 foo    kids     24565 Nov  8 16:26 index.cc
bar /home/foo/kids/CnUnix/www 253 % \rm index.cc
bar /home/foo/kids/CnUnix/www 254 % ls -asl index.cc
ls: index.cc: No such file or directory
bar /home/foo/kids/CnUnix/www 255 % df -k /home
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/sda1             70557052  26841048  40131908  41% /home
~~~~~~~~~
bar /home/foo/kids/CnUnix/www 256 % id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
bar /home/foo/kids/CnUnix/www 257 % debugfs /dev/sda1 -R 'ls -d -l foo/kids/CnUnix/www'|grep index.cc
debugfs 1.26 (3-Feb-2002)
 6146208  100644    523    500    2973 10-Oct-2002 16:37 admin_index.cc
 6145683  100644    523    500   24565  8-Nov-2002 16:26 index.cc
 ~~~~~~~
 6145682  100644    523    500   23015 31-Oct-2002 05:57 .#index.cc.1.324
bar /home/foo/kids/CnUnix/www 257 % debugfs /dev/sda1 -R 'cat <6145683>'|sum
debugfs 1.26 (3-Feb-2002)
26512    24
bar /home/foo/kids/CnUnix/www 258 % debugfs /dev/sda1 -R 'dump <6145683> /tmp/index.cc'
debugfs 1.26 (3-Feb-2002)
bar /home/foo/kids/CnUnix/www 259 % ls -asl /tmp/index.cc
  24 -rw-r--r--    1 root     root        24565 Nov 20 18:06 /tmp/index.cc
bar /home/foo/kids/CnUnix/www 260 % head /tmp/index.cc
#include <stdio.h>
...

[알림판목록 I] [알림판목록 II] [글 목록][이 전][다 음]
키 즈 는 열 린 사 람 들 의 모 임 입 니 다.