Article Title: Restoring hard disk partition data in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Delete an oracle database in linux this afternoon and use fdisk to re-partition the hard disk. My hard disk partition table is as follows:
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 x 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: I want to delete partitions 5th, 6, and 7 and create two new partitions to install the oracle database program files and database files respectively, I use fdisk in this way:
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 cocould 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. After exiting fdisk, it is found that the partition 5th, 7, and 9 has been deleted! Among them, hda9 has a total of 28 GB, and there are a lot of valuable things in it, so it's hard for me to die! This reminds me that fdisk Automatically sorts the following partitions after each partition is deleted, that is, when the 5th partition is deleted, the 6th partition is changed to 5, and the 7th partition is changed to 6 ......
Depressed !......
The road to success: I thought I had just backed up the hda partition table and put it in another partition this morning! I didn't think about it. I took the backup and started to restore the hard disk partition (don't laugh at me ):
QUOTE: # dd if = hda-2006-03-21.mbr of =/dev/hda bs = 512 count = 1 # reboot restart the computer with fdisk and then look at the Partition Table-no effect!
What's going on? It's too simple to start from a partition table -- the partition table has only 512 bytes, of which only 64 bytes are used to store partition information. At the beginning, the hard disk capacity was very small and 64 bytes was enough, later, as hard disk space increased, it was not enough, so I began to have extended partitions, and all the partitions I deleted were in the extended partitions! Restoring mbr will definitely not work!
What should I do !!! Staring at my hda from the hardware manager for a long time! I found that all the partitions I deleted are several independent spaces. Can I create a new logical partition table to restore the partition content ??? There is no other way at all. Try it!
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 cocould 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 what should I do next? As usual, it should be mkfs. vfat! But why? If you only create a partition table to restore data, isn't it necessary to re-create a file allocation table ?! Absolutely not!
Let's take a look.
QUOTE: # mount-t vfat-o iocharset = utf8/dev/hda14/mnt/tmp/# cd/mnt/tmp/# ls haha !!! Success! I finally saw those files again!
Restart your computer and go to windows. You can also see partition E:. The items in the window are still intact!
As a result, I trust the linux system more. The tool is small but practical! It is also very powerful. At the same time, this reminds me to be careful and pay attention to some details in future use!