질문&답변
클라우드/리눅스에 관한 질문과 답변을 주고 받는 곳입니다.
리눅스 분류

rm -rf 로 삭제한 파일 복구 가능?(xfs 파티션)

작성자 정보

  • 초보입니다 작성
  • 작성일

컨텐츠 정보

본문

XFS 파티션에서 rm -rf 로 파일을 삭제했습니다.

이렇게 삭제한 파일을 복구가 가능할까요?

관련자료

댓글 1

dslee님의 댓글

  • dslee
  • 작성일
네이버에서 가져온 자료입니다.

[Linux]rm 으로 삭제한 파일 복구하기

debugfs 라는 명령어 입니다. (man page 참조)

실제 사용예를 들어 설명하겠습니다.

가정1) /home/pds/portsentry.tar.gz 라는 파일이 있음.
가정2) /home 파티션은 hda8 입니다. (df -h 로 확인)
가정3) rm -f /home/pds/portsentry.tar.gz 명령으로 지웠음.
가정4) root 로 작업.

복구 절차.

1. #debugfs /dev/hda8

=> 설명 : hda8 파티션에 대해서 검사를 한다.

2. debugfs:

=> 대기상태를 뜻함. 이곳에서 lsdel 을 입력하고 엔터.
계속...

debugfs: lsdel
99 deleted inodes found.
Inode Owner Mode Size Blocks Time deleted
108123 0 100644 239 1/ 1 Thu Jan 3 01:25:33 2002
18417 0 100644 426625 420/ 420 Thu Jan 3 01:26:34 2002
45007 0 100644 343 1/ 1 Thu Jan 3 01:29:59 2002
28691 0 100400 879 1/ 1 Thu Jan 3 01:38:29 2002
18394 0 40755 0 1/ 1 Thu Jan 3 01:58:54 2002
..
.
14356 0 100644 2325 3/ 3 Fri Jan 25 16:13:24 2002
61239 0 100644 43034 44/ 44 Fri Jan 25 16:13:31 2002
debugfs:

위와 같은 상태로 나오고 다시 대기상태로 됩니다. 실제로는 너무 많이 나오
더군
요.. (내가 그렇게 많이 지웠었나? '.'a)

이제 이 목록중에서 하나를 선택해서 살려야 합니다. 다행히도 살리고자 하
는 파일
은 가장 최근에 지운 파일이므로 가장 아래쪽에 있는 것이겠죠.

debugfs: dump <61239> /home/debugfs/portsentry.tar.gz

=> Inode 값을 <> 안에 적어줍니다. 뒤에는 복구할 파일 이름을 적어주시면
됩니다.
=> 복구할 파일은 다른 디렉토리로 지정해 주시는게 좋습니다. 별 상관은 없
지만...

#cd /home/debugfs
#tar -zxvf portsentry.tar.gz // 정상적으로 압축이 풀리더군요.

=> 아주 훌륭하게 복구가 되었더군요. ^^v

임의로 portsentry.tar.gz 를 지워서 테스트를 한 것입니다.

debugfs: 상태에서 사용할 수 있는 명령어는 help 를 쳐보면 알 수 있습니
다.
끝내는 것은 q, quit 입니다.



아래는 debugfs: 에서 사용가능한 명령어들 입니다.
---------------------------------------------------------------------

Available debugfs requests:

show_debugfs_params, params
Show debugfs parameters
open_filesys, open Open a filesystem
close_filesys, close Close the filesystem
feature, features Set/print superblock features
dirty_filesys, dirty Mark the filesystem as dirty
init_filesys Initalize a filesystem (DESTROYS DATA)
show_super_stats, stats Show superblock statistics
ncheck Do inode->name translation
icheck Do block->inode translation
change_root_directory, chroot
Change root directory
change_working_directory, cd
Change working directory
list_directory, ls List directory
show_inode_info, stat Show inode information
link, ln Create directory link
unlink Delete a directory link
mkdir Create a directory
rmdir Remove a directory
rm Remove a file (unlink and kill_file, if appropriate)
kill_file Deallocate an inode and its blocks
clri Clear an inode's contents
freei Clear an inode's in-use flag
seti Set an inode's in-use flag
testi Test an inode's in-use flag
freeb Clear a block's in-use flag
setb Set a block's in-use flag
testb Test a block's in-use flag
modify_inode, mi Modify an inode by structure
find_free_block, ffb Find free block(s)
find_free_inode, ffi Find free inode(s)
print_working_directory, pwd
Print current working directory
expand_dir, expand Expand directory
mknod Create a special file
list_deleted_inodes, lsdel
List deleted inodes
write Copy a file from your native filesystem
dump_inode, dump Dump an inode out to a file
cat Dump an inode out to stdout
lcd Change the current directory on your native
filesystem
rdump Recursively dump a directory to the native filesystem
help Display info on command or topic.
list_requests, lr, ? List available commands.
quit, q Leave the subsystem



출처 : http://blog.empas.com/korigin
 

추가로 ~ rm은 조심해서 쓰셔야합니다.

작업은 root가 아닌 일반계정으로 하시길 바랍니다. ㅡㅡ^

공지사항


뉴스광장


  • 현재 회원수 :  60,017 명
  • 현재 강좌수 :  35,690 개
  • 현재 접속자 :  228 명