extundelete恢复Ubuntu系统下git clean -fd(rm)误删除的文件

一时大意,本来在.bashrc里封装了个命令gc=’git ch .;git clean -fd’,一进库,执行了下gc,然后把之前写了一周的代码删除个干干净净,找了很多办法还原,发现extundelete有作用。在这里作个笔记,下次误操作的时候用到再查(同样适用于rm 误删除的文件)。

1、将硬盘挂载为只读模式

sudo mount -o remount,ro /dev/sda5

2.安装extundelete

sudo apt-get install extundelete  

3.查看当前被删除文件所在系统分区

df  .

4.在被删除的目录下执行命令,获取Node号

ls -id .  

5.查找被删除的文件
extundelete 所在分区 –inode Node号

sudo extundelete  /dev/sda6  --inode 51119565

6.恢复文件
sudo extundelete 所在分区 –restore-file 文件路径

sudo extundelete /dev/sda6 --restore-file activity_main.xml___jb_old___

7、再将硬盘挂载为读写模式

sudo mount  -o remount,rw  /dev/sda6

附extundelete所有功能:

Usage: extundelete [options] [--] device-file
Options:
  --version, -[vV]       Print version and exit successfully.
  --help,                Print this help and exit successfully.
  --superblock           Print contents of superblock in addition to the rest.
                         If no action is specified then this option is implied.
  --journal              Show content of journal.
  --after dtime          Only process entries deleted on or after 'dtime'.
  --before dtime         Only process entries deleted before 'dtime'.
Actions:
  --inode ino            Show info on inode 'ino'.
  --block blk            Show info on block 'blk'.
  --restore-inode ino[,ino,...]
                         Restore the file(s) with known inode number 'ino'.
                         The restored files are created in ./RESTORED_FILES
                         with their inode number as extension (ie, file.12345).
  --restore-file 'path'  Will restore file 'path'. 'path' is relative to root
                         of the partition and does not start with a '/' (it
                         must be one of the paths returned by --dump-names).
                         The restored file is created in the current
                         directory as 'RECOVERED_FILES/path'.
  --restore-files 'path' Will restore files which are listed in the file 'path'.
                         Each filename should be in the same format as an option
                         to --restore-file, and there should be one per line.
  --output-dir 'path'    Restore files in the output dir 'path'.
                         By default the restored files are created under current directory 'RECOVERED_FILES'.
  --restore-all          Attempts to restore everything.
  -j journal             Reads an external journal from the named file.
  -b blocknumber         Uses the backup superblock at blocknumber when opening
                         the file system.
  -B blocksize           Uses blocksize as the block size when opening the file
                         system.  The number should be the number of bytes.

end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值