当前位置:操作系统 > Unix/Linux >>

Linux下恢复硬盘分区数据

今天下午在linux下删除操作,想安装oracle数据库,整理硬盘的时候用fdisk重新划分分区,我的硬盘分区表是这样的:

  QUOTE:# fdisk -l /dev/hda

  Disk /dev/hda: 82.3 GB, 82348277760 bytes 255 heads, 63 sectors/track, 10011 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes

  Device

  Boot

  Start

  End

  Blocks

  Id

  System /dev/hda1

  *

  1

  1044

  8385898+

  7

  HPFS/NTFS

  C:/dev/hda2

  1045

  1057

  104422+

  83

  Linux

  /boot /dev/hda3

  1058

  1249

  1542240

  82

  Linux swap /dev/hda4

  1250

  10011 70380765

  f

  W95 Ext'd (LBA)

  /dev/hda8

  1250

  2032

  6289384+

  83

  Linux

  /usr /dev/hda9

  2033

  2293

  2096451

  83

  Linux

  /tmp /dev/hda10

  2294

  2554

  2096451

  83

  Linux

  /var /dev/hda11

  2555

  2746

  1542208+

  83

  Linux

  / /dev/hda12

  2747

  3046

  2409718+

  83

  Linux

  /home /dev/hda5

  3047

  3189

  1025860+

  83

  Linux not used /dev/hda6

  3190

  3380

  2048108+

  83

  Linux not used /dev/hda7

  3381

  3670

  2048108+

  83

  Linux not used /dev/hda13

  3671

  6287

  21021021

  b

  W95 FAT32 D:/dev/hda14

  6288

  10011

  29912998+

  b

  W95 FAT32 E:我想把第5、6、7分区删除然后重新建立两个分区,分别安装oracle数据库程序文件和数据库文件,我用fdisk是这样操作的:

  QUOTE:# fdisk /dev/hda

  The number of cylinders for this disk is set to 10011. There is nothing wrong with that, but this is larger than 1024,and could in certain setups cause problems with:1) software that runs at boot time (e.g., old versions of LILO)

  2) booting and partitioning software from other OSs(e.g., DOS FDISK, OS/2 FDISK)

  Command (m for help): d Partition number (1-13): 5

  Command (m for help): d Partition number (1-12): 6

  Command (m for help): d Partition number (1-11): 7

  Command (m for help): w退出fdisk后才发现删错了,竟然把第5、7、9分区删除了!其中hda9共28G,里面存了好多有价值的东西,难受死我了!这才想起来fdisk在每一次删除分区后都会自动把后面的分区重新排序,即:删除第5分区时,第6分区变成5,第7分区成为6……

  

  郁闷!……

  天无绝人之路:我想到今天早上刚刚把hda的分区表备份了,并且放到了其它分区!也没有细想,把那个备份拿过来就开始恢复硬盘分区(别笑话我啊):

  QUOTE:#dd if=hda-2006-03-21.mbr of=/dev/hda bs=512 count=1 #reboot重启电脑用fdisk再看分区表——没有效果!

  怎么回事?从分区表开始想——太简单了——分区表只有512字节,其中只有64字节存储分区信息,开始的时候硬盘容量很小,64字节够用了,后来随着硬盘空间增大显得不够了,因此开始有了扩展分区,而我删除的分区正好都在扩展分区内!恢复mbr肯定是不行的了!

  怎么办啊!!!从硬件管理器盯着我的hda看了半天!发现我删除的分区都是几个独立的空间,就想能不能重新建立我的逻辑分区表来恢复分区内容呢???一不做二不休,反正没有别的办法了,试试吧!

  QUOTE:# fdisk /dev/hda

  The number of cylinders for this disk is set to 10011. There is nothing wrong with that, but this is larger than 1024,and could in certain setups cause problems with:1) software that runs at boot time (e.g., old versions of LILO)

  2) booting and partitioning software from other OSs(e.g., DOS FDISK, OS/2 FDISK)

  Command (m for help): n First cylinder (3047-10011, default 3047):Using default value 3047 Last cylinder or +size or +sizeM or +sizeK (3047-3189, default 3047):Using default value 3047

  Command (m for help): n First cylinder (3381-10011, default 3670):Using default value 3670 Last cylinder or +size or +sizeM or +sizeK (3381-3670, default 3670):Using default value 3670

  Command (m for help): n First cylinder (6288-10011, default 628:Using default value 6288 Last cylinder or +size or +sizeM or +sizeK (6288-10011, default 10011):Using default value 10011

  Command (m for help): t Partition number (1-14): 14 Hex code (type L to list codes): b

  Command (m for help): w接下来该干什么呢?按照常规应该是mkfs.vfat啦!可是为什么呢?如果只是建立分区表来恢复数据,那么这么做不就是重新建立文件分配表了吗?!绝对不行!

  还是先看看吧。

  

  QUOTE:#mount -t vfat -o iocharset=utf8 /dev/hda14 /mnt/tmp/ #cd /mnt/tmp/ #ls哈哈!!!大功告成!终于又看到那些文件了!

  重新启动电脑进入windows也看到了分区E:,里面的东西也是完好无损的在那儿呆着呢!

  由此我更加信任linux系统了,工具虽小但是很实用!也很强大。同时这件事情提醒我在以后的使用中注意要细心,注意一些细节问题
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,