|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
欢迎大家来到仓酷云论坛!人人好,昨天有一同事在linux体系中用治理员用户(root)删除另外一用户的根目次(rm-rf/home/tong),一切的文件没法找回了,我找了百度和谷哥终究把这个成绩处理了,如今我把处置的进程写出来,愿望对人人今后有赞助.
1.装置软件(ext3grep依附于体系的e2fsprogs三个软件包)
[root@redhat1home]#mkdir/mnt/cdrom--创立光盘挂载目次
[root@redhat1home]#mount/dev/cdrom/mnt/cdrom--挂载光盘
mount:blockdevice/dev/sr0iswrite-protected,mountingread-only
[root@redhat1home]#vim/etc/yum.repos.d/base.repo--设置装备摆设体系的当地源
[base]
name=base
baseurl=file:///mnt/cdrom
enabled=1
gpgcheck=1
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-REDHAT-6
[root@redhat1home]#yuminstalle2fs*--装置ext3grep软件的依附包
[root@redhat1home]#rpm-aq|grepe2fs--检讨软件包能否装置
e2fsprogs-devel-1.41.12-14.el6.i686
e2fsprogs-libs-1.41.12-14.el6.i686
e2fsprogs-1.41.12-14.el6.i686
[root@redhat1home]#wgethttp://code.谷歌.com/p/ext3grep/downloads/detail?name=ext3grep-0.10.2.tar.gz--下载ext3grep软件包
[root@redhat1home]#tarxvfext3grep-0.10.2.tar.gz--解压软件包
[root@redhat1home]#cdext3grep-0.10.2--进入软件包
[root@redhat1ext3grep-0.10.2]#./configure--prefix=/usr/local/ext3grep&&make&&makeinstall--装置软件
[root@redhat1ext3grep-0.10.2]#ll/usr/local/|grepext3--检查软件装置胜利
drwxr-xr-x.3rootroot4096Dec217:24ext3grep
[root@redhat1ext3grep-0.10.2]#
2.新建个块装备,用块装备做测试.假如你用/home目次,home目次必需是一个零丁的分区,在前面要停止挂载和卸载.
[root@redhat1home]#ddif=/dev/zeroof=123bs=1Mcount=100--在home目次下新建一个块装备123
100+0recordsin
100+0recordsout
104857600bytes(105MB)copied,0.634943s,165MB/s
[root@redhat1home]#mkfs.ext3123--格局化块装备
mke2fs1.41.12(17-May-2010)
123isnotablockspecialdevice.
Proceedanyway?(y,n)y--输出y肯定
Filesystemlabel=
OStype:Linux
Blocksize=1024(log=0)
Fragmentsize=1024(log=0)
Stride=0blocks,Stripewidth=0blocks
25688inodes,102400blocks
5120blocks(5.00%)reservedforthesuperuser
Firstdatablock=1
Maximumfilesystemblocks=67371008
13blockgroups
8192blockspergroup,8192fragmentspergroup
1976inodespergroup
Superblockbackupsstoredonblocks:
8193,24577,40961,57345,73729
Writinginodetables:done
Creatingjournal(4096blocks):done
Writingsuperblocksandfilesystemaccountinginformation:done
Thisfilesystemwillbeautomaticallycheckedevery27mountsor
180days,whichevercomesfirst.Usetune2fs-cor-itooverride.
[root@redhat1home]#mkdir/mnt/123--新建块装备挂载的目次
[root@redhat1home]#mount123/mnt/123-oloop--将块装备123挂载到/mnt/123中
[root@redhat1home]#df-TH--检查目次能否挂载
FilesystemTypeSizeUsedAvailUse%Mountedon
/dev/mapper/VolGroup-lv_root
ext420G3.8G16G20%/
tmpfstmpfs262M0262M0%/dev/shm
/dev/sda1ext4508M32M451M7%/boot
df:`/mnt/cdrom:Nosuchfileordirectory
/dev/sr0iso96603.2G3.2G0100%/mnt
/home/123ext3102M5.8M91M7%/mnt/123--装备已挂载
3.拷贝文件,删除文件.
[root@redhat1home]#cp-a/etc/passwd/etc/shadow/etc/group/mnt/123/--将文件挪动到装备中
[root@redhat1home]#ll/mnt/123/--检查能否有文件
total19
-rw-r--r--.1rootroot712Dec214:39group
drwx------.2rootroot12288Dec411:14lost+found
-rw-r--r--.1rootroot1509Dec214:39passwd
----------.1rootroot976Dec214:39shadow
[root@redhat1home]#sync--文件同步一下
[root@redhat1home]#rm-rf/mnt/123/passwd/mnt/123/shadow--删除文件
[root@redhat1home]#sync--文件同步一下
[root@redhat1home]#umount/mnt/123--卸载装备
4.恢复文件
[root@redhat1home]#cd/usr/local/ext3grep/bin/--进入ext3grep软件的目次
[root@redhat1bin]#./ext3grep--ls--inode2/home/123
Runningext3grepversion0.10.2
WARNING:IdontknowwhatEXT3_FEATURE_COMPAT_EXT_ATTRis.
Numberofgroups:13
Loadinggroupmetadata...done
Minimum/maximumjournalblock:49402/53515
Loadingjournaldescriptors...sorting...done
Theoldestinodeblockthatisstillinthejournal,appearstobefrom1386127317=WedDec411:21:572013
Numberofdescriptorsinjournal:22;min/maxsequencenumbers:2/5
InodeisAllocated
Findingallblocksthatmightbedirectories.
D:blockcontainingdirectorystart,d:blockcontainingmoredirectoryentries.
Eachplusrepresentsadirectorystartthatreferencesthesameinodeasadirectorystartthatwefoundpreviously.
Searchinggroup0:DD
Searchinggroup1:
Searchinggroup2:
Searchinggroup3:
Searchinggroup4:
Searchinggroup5:
Searchinggroup6:++
Searchinggroup7:
Searchinggroup8:
Searchinggroup9:
Searchinggroup10:
Searchinggroup11:
Searchinggroup12:
Writinganalysissofarto123.ext3grep.stage1.Deletethatfileifyouwanttodothisstageagain.
Resultofstageone:
2inodesarereferencedbyoneormoredirectoryblocks,2ofthoseinodesarestillallocated.
1inodesarereferencedbymorethanonedirectoryblock,1ofthoseinodesisstillallocated.
0blockscontainanextendeddirectory.
Resultofstagetwo:
2ofthoseinodescouldberesolvedbecausetheyarestillallocated.
Alldirectoryinodesareaccountedfor!
Writinganalysissofarto123.ext3grep.stage2.Deletethatfileifyouwanttodothisstageagain.
Thefirstblockofthedirectoryis508.
Inode2isdirectory"".
Directoryblock508:
.--Filetypeindir_entry(r=regularfile,d=directory,l=symlink)
|.--D:Deleted;R:Reallocated
IndxNext|Inode|DeletiontimeModeFilename
==========+==========+----------------data-from-inode------+-----------+=========
01d2drwxr-xr-x.
12d2drwxr-xr-x..
25d11drwx------lost+found
34r12D1386127493WedDec411:24:532013rrw-r--r--passwd--D表现是删除的文件
45r13D1386127493WedDec411:24:532013r---------shadow
5endr14rrw-r--r--group
[root@redhat1bin]#./ext3grep--restore-filepasswd/home/123--restore-file用文件名来恢复文件
Runningext3grepversion0.10.2
WARNING:IdontknowwhatEXT3_FEATURE_COMPAT_EXT_ATTRis.
Numberofgroups:13
Minimum/maximumjournalblock:49402/53515
Loadingjournaldescriptors...sorting...done
Theoldestinodeblockthatisstillinthejournal,appearstobefrom1386127317=WedDec411:21:572013
Numberofdescriptorsinjournal:22;min/maxsequencenumbers:2/5
WritingoutputtodirectoryRESTORED_FILES/
Loading123.ext3grep.stage2...done
Restoringpasswd--恢复passwd文件胜利
[root@redhat1bin]#./ext3grep--restore-inode13/home/123--用节点号(--restore-inode)来恢复文件
Runningext3grepversion0.10.2
WARNING:IdontknowwhatEXT3_FEATURE_COMPAT_EXT_ATTRis.
Numberofgroups:13
Minimum/maximumjournalblock:49402/53515
Loadingjournaldescriptors...sorting...done
Theoldestinodeblockthatisstillinthejournal,appearstobefrom1386127317=WedDec411:21:572013
Numberofdescriptorsinjournal:22;min/maxsequencenumbers:2/5
Restoringinode.13--恢复胜利
[root@redhat1bin]#llRESTORED_FILES/--在本身以后目次下有个RESTORED_FILES目次寄存恢复文件
total8
----------.1rootroot976Dec214:39inode.13
-rw-r--r--.1rootroot1509Dec214:39passwd
[root@redhat1bin]#
注:Linux体系中对Ext4文件体系删除后恢复:http://597011036.blog.51cto.com/6214144/1335953
重点:1.ext3grep敕令参考:
ext3grep/home/123--dump-names--检查存在的和删除的文件
ext3grep/home/123--ls--inode2--具体检查存在的删除的文件(d删除r存在)
ext3grep/home/123--restore-file文件名--恢复文件
ext3grep/home/123--restore-all--恢复一切文件
ext3grep/home/123--restore-inode节点号--恢复指定节点号的文件
ext3grep/home/123--ls--inode15809--可以进入节点为15809的文件夹中,看能否有还有的是的文件
ext3grep/home/1234--restore-file目次/文件--复原目次上面的文件(进入目次ext3grep/home/1234--ls--inode目次节点)
2.毛病处置:
1)假如履行敕令报错
[root@redhat1bin]#./ext3grep--ls--inode2/home/123
处理办法:rm-rf123.ext3grep.stage1123.ext3grep.stage2RESTORED_FILES就能够了
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们! |
|