LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 02-16-2010, 09:01 AM   #1
wearetheborg
Member
 
Registered: Sep 2004
Distribution: Mint 13 Maya
Posts: 268

Rep: Reputation: 31
How to repair filesystem (it is appearing as free space) ?


Original disk:
XP NTFS primary
Linux / ext4 logical
Linux /home ext4 logical
Win 7 NTFS logical
NTFS data logical
swap space
NTFS recovery partition


I tried to install linux, as there was a problem with XP overwriting grub, I chose write grub to /dev/sda8 (which is where the linux install was appearing earlier).

I guess this borked the filesystem somehow. Now the NTFS data partition and the swap space are appearing as one free space.
Well actually before that some linux live CDs (including gparted were seeing the entire drive as unpartitioned). I had to go into XP and delete the /ext4 partitions.


Is there any way for me to recover the NTFS data partition ?
 
Old 02-16-2010, 09:09 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
I think we are going to need more detail on the exact steps you went thru.. Just installing GRUB to a partition is not going to do what you are describing.

In principle, you can recover at lease some of the data on the original partition(s). To do this, do not do anything the the disk which could cause a write. Ideally, mount the disk such that it is not being used for the OS.
 
Old 02-16-2010, 09:20 AM   #3
wearetheborg
Member
 
Registered: Sep 2004
Distribution: Mint 13 Maya
Posts: 268

Original Poster
Rep: Reputation: 31
There were two primary partitions that I could see: NTFS XP and NTFS recovery partition.
There was an extended parition with
Linux / ext4 logical
Linux /home ext4 logical
Win 7 NTFS logical
NTFS data logical
swap space

This was from an earlier install and all the partitions were fine. I had data on the NTFS data partition.
However, there was a problem in that if I wrote grub to MBR, XP was deleting it.

So I reinstalled linux, deleted the two linux logical partitions, recreated them, and finally chose write grub to /dev/sda8
sda8 was where the earlier linux install had the / partition.

Now, the two NTFS data and swap space logical partitions are appearing as free space.

There is only one drive in the laptop
 
Old 02-16-2010, 11:48 AM   #4
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Post the results of "sudo /sbin/fdisk -l" and "sudo /sbin/fdisk -lu".

Did you recreate new partitions over the old ones or move them to the beginning of the drive?

If the part of the disk where your XP partition used to be isn't damaged, you can still mount it. I would then backup the files for insurance before attempting to repair your partition table.

Code:
# Assuming standard XP/Linux partition scheme:
sudo /sbin/losetup -fs /dev/sda1 -o $((63*512))

# will use the first available loop device and print which loop device was used.
# if your version of losetup doesn't print the device used run "sudo /sbin/losetup -a" to show you
# all of the loop devices.
# assuming loop0 was used:
sudo file -s /dev/loop0

# hopefully you will see something like this (my laptop has vista with a different offset)
# /dev/sda1: x86 boot sector, code offset 0x52, OEM-ID "NTFS    ", sectors/cluster 8, reserved sectors 0, Media descriptor 0xf8, heads 255, hidden sectors 2048, dos < 4.0 BootSector (0x80)

# this will return the size of the filesystem, allowing you to set end of that partition in the partition table by adding it to 63 blocks.
sudo df /dev/loop0
sudo mount -t ntfs /dev/loop0 /mnt/

# at this point if successful, you can backup the files on your XP partition.  Then use the values obtained to fix your partition table for the first partition on the disk.
 
Old 02-16-2010, 05:04 PM   #5
wearetheborg
Member
 
Registered: Sep 2004
Distribution: Mint 13 Maya
Posts: 268

Original Poster
Rep: Reputation: 31
I wimped out and used http://www.partition-recovery.com to recover the NTFS data partition (I was under a time constraint).

But I would still like to know how to fix this using a free open source tool/methods. So I am still very much into this thread. The tool I used did not have any problem at all and so I assume its a simple problem to fix.


Perhaps imp info that should be mentioned: I am using easyBCD 2.0 beta:
http://neosmart.net/forums/showthread.php?t=642

(but it had not caused problems earlier)


I recreated the linux logical partitions over the old linux logical partitions.

So, before I did the reinstall, my HDD looked like

111222333444555666777 where

1=XP NTFS primary
2=Linux / ext4 logical
3=Linux /home ext4 logical
4=Win 7 NTFS logical
5=NTFS data logical
6=swap space
7=NTFS recovery partition

In the intermediate reinstall, I deleted 2& 3, so my HDD looked like
111FFFFFFFF444555666777

Then I created the ext4 partitions back in the old place.
So, the HDD looked like as before
111222333444555666777

Then I said write grub to /dev/sda8 (sda8 was where the old linux parition (2) was). Then the reinstall went fine.


But then after I added the linux entry in easy BCD, linux/gparted would not see ANY partitions over the entire HDD.
However, both XP and win 7 would boot fine (but would show 222333 & 555666 area as free space (seperated by the win 7 partition).


In the future, how can I fix the borked HDD ?


BTW, the free version of partition recovery showed the missing NTFS data partiton as First sector: 215640558 amd sectors = 75409040 & cluster size = 4096. Is this info useful ?


Finally another piece of info (I'm trying to think of everything). When I put in the linux entry in easyBCD, it seems to cause a minor hiccup, in that when I reboot into linux for the first time, it complains that inode access time is in the future and tells me to do fsck for both the ext4 partitions. Fsck runs fine and does one repair operation, and from then on everythign is fine.

So, 1) is easyBCD the culprit ? 2) perhaps writing grub to wrong device ? and 3) how to fix a similar borked HDD ?




Quote:
Originally Posted by jschiwal View Post
Post the results of "sudo /sbin/fdisk -l" and "sudo /sbin/fdisk -lu".

Did you recreate new partitions over the old ones or move them to the beginning of the drive?

If the part of the disk where your XP partition used to be isn't damaged, you can still mount it. I would then backup the files for insurance before attempting to repair your partition table.

Code:
# Assuming standard XP/Linux partition scheme:
sudo /sbin/losetup -fs /dev/sda1 -o $((63*512))

# will use the first available loop device and print which loop device was used.
# if your version of losetup doesn't print the device used run "sudo /sbin/losetup -a" to show you
# all of the loop devices.
# assuming loop0 was used:
sudo file -s /dev/loop0

# hopefully you will see something like this (my laptop has vista with a different offset)
# /dev/sda1: x86 boot sector, code offset 0x52, OEM-ID "NTFS    ", sectors/cluster 8, reserved sectors 0, Media descriptor 0xf8, heads 255, hidden sectors 2048, dos < 4.0 BootSector (0x80)

# this will return the size of the filesystem, allowing you to set end of that partition in the partition table by adding it to 63 blocks.
sudo df /dev/loop0
sudo mount -t ntfs /dev/loop0 /mnt/

# at this point if successful, you can backup the files on your XP partition.  Then use the values obtained to fix your partition table for the first partition on the disk.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot detect free space in mounted SMB filesystem Saint Simian Linux - Networking 5 02-12-2009 01:50 AM
Free disk space not appearing gmartin Slackware 3 02-03-2008 04:21 PM
How to assign non-contiguous free space to a filesystem fab_lab_99 Linux - Server 2 06-28-2007 11:54 AM
Not enough free space on hard drive with 50g of free space??? auoq Suse/Novell 5 10-13-2004 08:21 PM
Formating free space: WinXP pro and RH9 dualboot with free space on 3rd drive Vermicious Linux - General 2 03-22-2004 05:10 AM


All times are GMT -5. The time now is 07:55 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration