There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Linux and Unix
Tag Cloud
access acer asus bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop malware memory modem monitor motherboard netgear network printer problem ram registry repair router slow software sound toshiba trojan usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless xbox
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
I accidentally put swap file on my NTFS partition and lost data. Am I screwed?

Reply  
Thread Tools
AiMingQi's Avatar
Junior Member with 2 posts.
 
Join Date: Feb 2009
21-Feb-2009, 12:10 AM #1
Angry I accidentally put swap file on my NTFS partition and lost data. Am I screwed?
I had a complete windows failure and couldn't load windows on my drive. I installed Kubuntu onto one of my open partitions to see if the hd was actually broken. Then I created a swap file on another partition but I accidentally choose the wrong partition. I choose one that is loaded with my entire photo collection. I have some of it backed up, but my latest work is still there. I am going to be really sad if it is completely gone.

I put on a fresh install of Windows onto another partition, but Windows won't read the affected partition and I can't do a 'quick' format back to NTFS and hope that the data is not gone. I plan to use pcinspector to recover the data. It is a 100gb partition so there is a lot of data there and I'm sure Kubuntu's swap file only affected a small part of the partition. But I can't figure out how to convert the partition back to NTFS.

Does anyone know what affect Kubuntu might have had on that drive?

I'm really unclear how to use Kubuntu. I only experiemented with it a little. Which is why I got into this mess in the first place. I don't know how to run programs and I'm having a difficult time finding the right program.

This is my biggest computer disaster yet.
SOMEBODY HELP ME PLEASE!
saikee's Avatar
Senior Member with 3,409 posts.
 
Join Date: Jun 2004
Location: Newcastle
Experience: A Linux user gone nuts on multi-boot
21-Feb-2009, 11:22 AM #2
It is quite possible that you have lost everything.

You are right in thinking the swap will affect a tiny area of the partition or even none of it but the real damage is the filing indexing system at the beginning of the partition. Without it it is a forensic exercise to piece the files back.

You can only blame yourself because you actually instructed explicitly a Linux to use the data partition as a scratch pad.

In your case I would suggest the following

(1) Load a Linux live CD. Kubuntu is as good as any

(2) When Linux is operational click terminal mode and obtain root privilege by command
Code:
sudo su
(3) You then ask Linux to display all the partitions of every disk by command
Code:
 fdisk -l
(4) A partition has a Type number or ID. For NTFS it is type 7. A normal Linux partition is Type 83 whereas a swap is type 82. Thus if your report is accurate then you should see a partition still listed as Type 82 but has a ridiculously large size of 100Gb. Normal swap needs only to be 0.5 to 1Gb and a Linux may even survive without it.

(5) If you locate this swap partition successfully then you proceed to turn the partition back to Type 7 for NTFS filing system. Assuming the hard disk is sda you do this by command
Code:
cfdisk /dev/sda
Inside the cfdisk program you have an option on "type", Highlight the affected partition, select type and press return. You can see the 100+ partition types supported by Linux. Select type 7 or simply type "7" (without the ") and press return. At this stage nothing is permanent. You make it permanent by select "write" for effecting the change. After exiting cfdisk program I recommend a reboot.

(6) You reboot Kubuntu and use it to mount the changed partition. Assuming it is sda2 (adjust to suit your case and don't follow everything blindly, if in doubt ask question here!) the commands in terminal, after acquiring root privilege again, are
Code:
mkdir /mnt/sda2
mount -t ntfs /dev/sda2 /mnt/sda2 
ls /mnt/sda2
If you get a listing of directory after command "ls /mnt/sda2" go out to buy yourself a drink as most if not all your data will be intact. If an error is reported or the partition cannot be mounted then kick the dog and report back here. I run out of idea but others may be able to help.

A little explanation does no harm here-----------------------------------------

When you selected the ntfs partition as a swap and didn't alter the size then your action can cause change of just one byte in the partition table. As a swap has no filing system it does not need to be formatted. Therefore if there was no need for Kubuntu to use your swap, assuming you have a reasonably amount of ram, then your original ntfs indexing system could be intact.

My suggestion is just to change the partition ID, of one byte, from type 82 to 7. The operating system checks the partition type before deciding how to use it. The creation, deletion and modification of the partition table never touch the internal data. Everything is done in the 4x16 bytes within the MBR (because every hard disk has 4 primary partitions). Therefore my suggested change is "reversible" . You can go ahead to change it any number of times. If your NTFS filing index has not been damaged then your data is recoverable.

Good luck! as you might need it.

Last edited by saikee; 21-Feb-2009 at 05:08 PM..
TerryNet's Avatar
Computer Specs
Moderator with 48,388 posts.
 
Join Date: Mar 2005
Location: Ottawa, IL
Experience: Intermediate to Advanced
21-Feb-2009, 01:08 PM #3
Super advice and explanation, saikee!
saikee's Avatar
Senior Member with 3,409 posts.
 
Join Date: Jun 2004
Location: Newcastle
Experience: A Linux user gone nuts on multi-boot
21-Feb-2009, 05:10 PM #4
TerryNet,

We have to wait and see.

If the OP fails to recover the data and the dog is kicked because of my recommendation the animal cruelty prevention people may come down on me like a ton of brick!
AiMingQi's Avatar
Junior Member with 2 posts.
 
Join Date: Feb 2009
22-Feb-2009, 01:29 AM #5
Talking I solved the problem!
Thanks Saikee for your help.

I actually solved the problem a different way. I pulled my drive out and used a SATA external case I had to use my laptop to access the drive. Then I used Partition Table Doctor 3.5 to fix the drive. It was really quick and painless. Luckily I recovered all of my data and rebuilt the proper NTFS index system on the partition. So I'm back in business.

I'm never going to touch Kubuntu again.
saikee's Avatar
Senior Member with 3,409 posts.
 
Join Date: Jun 2004
Location: Newcastle
Experience: A Linux user gone nuts on multi-boot
22-Feb-2009, 08:16 AM #6
Quote:
I'm never going to touch Kubuntu again.
Your problem is not specific to any Linux distro but the knowledge of what a swap is for.

Linux rarely need to defrag its partition because the use of a swap.

Like I explained before you can change the partition table without damaging its interior. You can learn the working of the partition table better in Linux than the MS systems because it has tools for you to carry out the changes.

Putting the disk on an eSata is to arrange it as a non-bootable disk so that you can use another operating system to fix the disk.(actually you can boot any MS or Linux system in an eSata if the main internal disk is absent!).

Linux, installed in the hard disk or on a Live CD, can fix this kind of problems regardless it is an internal or external, Sata or Pata, USB, Firewire or eSata disk.

Anyway I am glad you got it sorted.
newieGus's Avatar
Junior Member with 1 posts.
 
Join Date: Mar 2009
Experience: Intermediate
05-Mar-2009, 01:02 PM #7
Dear guys / saikee, thank you help. I could solve my problem, the same (identical) which AiMingQi.
I did change the partition type from 82 to 7, but not mount.
Then I used the PTDD, I was not previously an option FixedDisk but now yes!! and... repairing the unit successfully.
Thanks again!
saikee's Avatar
Senior Member with 3,409 posts.
 
Join Date: Jun 2004
Location: Newcastle
Experience: A Linux user gone nuts on multi-boot
05-Mar-2009, 06:53 PM #8
newieGus,

Welcome to the TSG Forum.


Glad you found something useful.
Reply

Tags
accidental format, drive failure, kubuntu

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:02 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.