linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么

工具: hexedit、fdisk

下文內(nèi)容操作均在root環(huán)境下完成。

hexedit:

linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么

linux上,經(jīng)常會使用hexedit來修改程序的16進(jìn)制代碼。而fdisk這里就不介紹了。

現(xiàn)在我們走進(jìn)磁盤的世界,看看磁盤它對數(shù)據(jù)做點(diǎn)了什么吧。

首先,在終端下使用root權(quán)限,來運(yùn)行下命令:

Command: fdisk -l

linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么

/dev/sdb1是今天的主角,從圖片很清晰地看到一些相關(guān)數(shù)據(jù),比如磁盤的size,、sector、I/O size等等。

linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么

磁盤格式為ext4,而非MS上的vfat32和NTFS格式,在文章的結(jié)尾貼上FAT32的圖片。

***步:

運(yùn)行fdisk,使用專家模式,來備份Partition table

linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么

ext4的partition table非常簡單,一般備份partition table為ext4.img。備份是為了避免數(shù)據(jù)恢復(fù)中被破壞。

第二步:

首先在target sdb1上執(zhí)行剪切的命令操作,把sdb1上的文件移動到電腦硬盤上,執(zhí)行完成后,使用hexedit 來打開sdb1。

被剪切的文件名:usb.png

Command : hexedit -s /dev/sdb1

linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么

圖片中可以看到文件名和它所在的sector, 是不是發(fā)現(xiàn)了圖片的設(shè)備是sdc1?由于磁盤的自動掛載發(fā)生了dev的改變,而數(shù)據(jù)是不會隨著磁盤的dev變化而變化的。這里已經(jīng)找到了文件名的所在,接下來,需要找到文件header。

如何找到文件頭呢? 可以利用hexedit進(jìn)行hex search,如果是要著ASCII,可以按下TAB切換到ASCII區(qū)域。

linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么

文件的大小決定了文件在磁盤中所占用的sector 數(shù),1 sector==512 bytes。在圖中,顯示了文件header offset和sector。

提取hex值,寫入文件。

linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么

恢復(fù)后的圖片:

linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么

上看著很簡單吧,它只是單文件的剪切操作與數(shù)據(jù)恢復(fù)。這里提醒下各位:磁盤中保存的數(shù)據(jù),不是刪除了可以恢復(fù),被剪切掉的數(shù)據(jù)一樣可恢復(fù)。

下面我們來看看從磁盤刪除數(shù)據(jù)后,如何來操作呢?

在磁盤上執(zhí)行delete命令來刪除一個名為1.gif的文件,操作如下:

linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么
linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么
linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么

圖片可以看到文件header到文件end的sector 的變化,header sector: 264056 , end sector: 264057,文件大小在1K, 圖片很小。

創(chuàng)建個新文件,然后再執(zhí)行delete操作,看看磁盤數(shù)據(jù)變化。

linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么
linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么
linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么

文件header sector : 264056, end sector: 264061 , ***次執(zhí)行刪除的文件header sector: 264056 ,end sector : 264057, 這樣可以看到***次刪除的數(shù)據(jù)被覆蓋掉,而保留了第二此刪除的數(shù)據(jù)。

這里操作是對磁盤單一文件進(jìn)行數(shù)據(jù)恢復(fù)和其磁盤中的數(shù)據(jù)變化進(jìn)行論證。接下來我們來看看雙文件的操作。

linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么

磁盤中存在兩個不同類型的文件。

文件名:partition.zip

文件名:cab.ico

linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么
linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么

***個文件的header secotor:264056,end sector:264058

linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么

linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么

?

第二個文件header sector:264064,end sector:264076。發(fā)現(xiàn)***個文件的end sector與第二個文件的header sector相差多個sector,那么中間的差值是什么呢?

linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么

可以看到中間的差值全部以00填充。到這里我們來總結(jié)下這次在linux上的實(shí)踐操作:

ext4 file system

執(zhí)行 剪貼

file name : usb.png sector 67120

file header : sector 264064 file end: sector 264076

執(zhí)行 刪除

file name : 1.gif sector 67112 (覆蓋)

file header: start : sector 264056 end: sector 264057 (覆蓋)

file name: 56.jpg sector 67112

file header:start: sector 264056 end: sector 264061

當(dāng)單文件時(shí),執(zhí)行刪除時(shí),覆蓋上一次被刪除的數(shù)據(jù)。

儲存文件

(1) file name : partition.zip sector 67112

file header: start sector 264056 end sector 264058

(2) file name : cab.ico sector 67112

file header: start sector 264064 end sector: 264068

剪切區(qū):sector 264064

刪除區(qū): sector 264056

儲存區(qū):與刪除區(qū)共存

儲存區(qū): 當(dāng)單文件時(shí),儲存文件覆蓋刪除區(qū)數(shù)據(jù)。

數(shù)據(jù)恢復(fù):當(dāng)多文件時(shí),執(zhí)行刪除時(shí),刪除區(qū)保留數(shù)據(jù)hex,如果建立新文件數(shù)據(jù)時(shí),將覆蓋被刪除數(shù)據(jù)hex。

附圖:

FAT32磁盤格式圖:

linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么
linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么
linux系統(tǒng)數(shù)據(jù)恢復(fù)的方法是什么

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點(diǎn)贊15 分享