Полезная информация

The Linux Partition-Rescue mini-HOWTO

Rolf Klausen, <rolfk@romsdal.vgs.no>

Version 1.1, 22 Oct 1997

This mini-HOWTO document describes how to rescue your Linux partition if M$-DOG has deleted it for you.


2.Some preparations and needs

3.Let's do it! I want my partition back!


1. Introduction

Previous  Next  Table of Contents

On my computer I have installed Linux, and I have used it for over an year now, and I think it is the best OS ever created. I also have M$-DOG and Windows NT 4.0 installed on my computer. The reason that I use M$-DOG is simply because, as Lars Wirzenius once wrote: "MS-DOS - you can't live with it, you can't live without it". I use it to play games and run demos and stuff with.

But enough about that. I have two DOS partitions, one primary partition and onelogical drive (I assume you know what a partition is - if not read the Partition mini-HOWTO. It is located at sunsite.unc.edu somewhere and probably many other places too.). They are about 500 MB each (I have one 3.2 GB disk and one 1.2 GB disk :). My Linux partition is 1200 MB. I have a free space of about 800 MB which I don't know what do do with yet, and I was wondering about what I should do if I needed more space for DOS (some large game or something), because I wasn't sure how many logical drives DOS could use / access. I don't know why, but for some reason I thought that DOS could use only one (in addition to the primary DOS partition). So I thought that I could check out if DOS could access more logical drives. I fired up fdisk (in DOS), and used the menu system to create a "logical DOS drive", and that worked fine. I created one with the size of 100 MB. Then I formatted it and it worked fine! Great! I thought. Then I knew that! But I didn't need that drive now, so I decided to delete it. I used DOS' fdisk again, chose "delete DOS primary partition or logical drive" (or something like that) on the menu, selected drive E to be deleted, typed the volume label, which was nothing (I just tapped ENTER) and fdisk told me that the disk was successfully deleted. Then I rebooted. On my computer I use a program called System Commander. It is a great program which displays a nice menu (a la OS/2's Boot Manager) with icons and many nice features. It detects and removes new/deleted OSes automatically etc. But when I rebooted, Linux wasn't on the menu anymore! I started DOS, typed e: and enter, and there it was still! Then I started fdisk. It chose to print the partition table, and it said that drive E was there, and where my Linux partition was before, now only a free space was left! SHOCK! HORROR! I started to sweat and shake! What should I do now! I couldn't just reinstall everything! It had to be a way to get it all back. And, yes, it was! Thank God (even though I don't believe in him), it was! I had lots of useful information and programs on that partition! Before I figured out how to rescue my partition, I wished Bill Gates was never even born! Have you experienced the same thing recently? Don't be afraid! The rescue is here! Just read on a little bit more...!
Oh, BTW: Due to the fact that I live in Norway, my english is probably not so good, but I hope you understand it anyway :-)

1.1 Disclaimer

Previous  Next  Table of Contents

This mini-HOWTO is Copyright (C) 1997 Rolf Klausen. All rights reserved. You may do (almost) whatever you want with it. I don't care. Just be sure to keep my name intact. I just hope it becomes useful for any person in the Linux community. But please read section 1.2 below.


I am not responsible of any damage on any computer as a result of anyone reading this HOWTO. If you do any damage, it is YOUR fault, NOT MINE! Be careful when partitioning disks, and don't make any mistakes, because it can be fatal! Backup all your important data and check that everything you do is correct! What is described here worked on my computer, but it may or may not work on your computer. Although it should work for everyone, I can't garantee anything. This is the last warning you get: BACKUP IMPORTANT DATA! Or, to put it short: Use at your own risk!

1.2 Legal stuff

Previous  Next  Table of Contents

Unless otherwise stated, Linux HOWTO documents are copyrighted by their respective authors. Linux HOWTO documents may be reproduced and distributed in whole or in part, in any medium physical or electronic, as long as this copyright notice is retained on all copies. Commercial redistribution is allowed and encouraged; however, the author would like to be notified of any such distributions.

All translations, derivative works, or aggregate works incorporating Linux HOWTO documents must be covered under this copyright notice. That is, you may not produce a derivative work from a HOWTO and impose additional restrictions on its distribution. Exceptions to these rules may be granted under certain conditions; please contact the Linux HOWTO coordinator at the address given below.

In short, we wish to promote dissemination of this information through as many channels as possible. However, we do wish to retain copyright on the HOWTO documents, and would like to be notified of any plans to redistribute the HOWTOs.

If you have any questions, please contact Tim Bynum, the Linux HOWTO coordinator, at linux-howto@sunsite.unc.edu via email.

2 Some preparations and needs

Previous  Next  Table of Contents

2.1 What you need

Previous  Next  Table of Contents

OK! So, MS-DOG has deleted your Linux partition? Here is what you need to bring it back from the dead:

2.2 I assume that...

Previous  Next  Table of Contents

If this suites you, then the chances for succesfully recovering your partition are very large!

3. Let's do it! I want my partiton back!

Previous  Next  Table of Contents

OK! Get ready to rescue... grab a cup of coffee, and relax. Everything will be just fine :)
BTW - Can you imagine how I felt when MeSsy-DOS deleted my partiton? I have never been so angry in my entire life (almost). But I found a way to rescue the partition. Here it is...:

3.1 Using the Partition Magic program to recover your partition.

Previous  Next  Table of Contents

Get the partition magic program from the internet somewhere. Fire it up, and you will get a nice win95 look-alike user interface. It is very easy to use, and if you have used windoze 95, you should be able to use this program too. Press the OK button, and then a graphical presentation (is that the right word to use? I'm not so very good in english.) of your disk should appear on your disk. The different partitions and filesystems have different colors. I have a DOS primary partiton, and I assume you have the same. One of my logical drives is my Linux partition. Where that previously were, now only a grey bar of free space is left. To the right or left of it you should have a small logical drive which is you Linux Swap partition. Now right click on the free space and select "create", or choose from the menus. You should be able to figure out how it works. It is, as said earlier, a very easy to use interface. When the create partition dialog box appears, select "Unformatted" where it says "FAT". You can choose from "FAT", "HPFS" and "Unformatted". If you choose FAT or HPFS, a FAT or HPFS filesystem will be created on that partition and your linux filesystem destroyed, so make sure that you have selected the right value. Now select OK, and the partition will be created. But the partition is now marked as a DOS FAT16 partition (in the partition table, every partition has a mark (a hexadecimal number) which shows what OS the partition belongs to.). What do you do then? Goes on to section 3.2 :)

3.2 Changing the partition type to Linux Native

Previous  Next  Table of Contents

Now you need the boot and root floppies, so I hope you have them. It is also possible to use loadlin. Just make sure you can start Linux and run fdisk under it. First thing to do is login ;). fire up fdisk by typing fdisk at the shell prompt. If you have more than one hd, then check that fdisk is using the right one. Type 'p' (only the letter p) and tap ENTER. You should now get a listing of your partition table. It should have one "DOS 16-BIT >= 32M" more than normal. Find out which one is your Linux partition (look at the sizes etc) and remember its number (i.e. mine is /dev/hda6, so I would have to remember the number 6 :). Now type 't' and ENTER to change a partitions type, or ID as it is called in Linux fdisk (i'm not sure which one is right; type or id, but I use the word type). Now type the number you should remember and press ENTER. Now you shall type the hex code of the OS which the partition belongs to. Type the number 83 and press ENTER. 83 means that the partition is a Linux Native partition. Linux Swap partitions have the type set to 82. You can type 'L' to see a list of codes when you are asked to type the hex code of the partition.

When you have done all this, and when you have done everything right, your partition shall be OK!! YES! It is true! It did work for me, and should work for you too! All you now have to do is the final step:

3.3 The final touches

Previous  Next  Table of Contents

There are some small details still remaining. First of all, reboot and fire up Linux the way you usually do it (LILO etc) and see if everything works. If it doesn't, then you have odne something wrong or my recovery mothod doesn't work for you :( But if it boots correctly, then congratulations! You have done everything correctly! Now fsck will check you filesystem once (it checked mine twice, I dunno why ;), and then everything shall work fine again! If not, then don't blame me. As said, it worked for me, but maybe not for you. If I saved your partition, then a e-mail would be very nice :)

4. Contributors

Previous  Next  Table of Contents

4.1 Authors

Previous  Next  Table of Contents

There are only one author, and that one is me:

Rolf Klausen
E-mail: rolfk@romsdal.vgs.no
WWW: http://www2.romsdal.vgs.no/~rolfk/
Snail mail:

Rolf Klausen
Neptunvn. 10
6400 Molde

4.2 Thanx go out to:

Previous  Next  Table of Contents

4.3. Thanx does NOT go out to:

Previous  Next  Table of Contents

Bill Gates (bill.gates@microsoft.com (?)) for creating the worst "operating systems" in the world and for deleting my Linux partition (Yes, I blame him. If he wasn't born, then my partition wouldn't have been deleted and I wouldn't have had to recover it or even write this little HOWTO.