EXT3 Accidentally Mounted as SWAP - Need files


Results 1 to 14 of 14

Thread: EXT3 Accidentally Mounted as SWAP - Need files

  1. #1
    Join Date
    May 2001
    Location
    Uh, I'm somewhere where I don't know where I am.
    Posts
    1,228

    EXT3 Accidentally Mounted as SWAP - Need files

    I had an install of F7 on one disk, installed another harddrive and then installed FC5 on the second drive, making sure that the new install didn't format the drives. Apparently I forgot to check if the new install was going to use the first drive. It did. After messing around with the FC5 for a bit, I decided to mount the main F7 partition. It didn't let me. So I checked fstab and it was using it as swap. That's bad. I tried fsck.ext3, no workie.

    I wrote a few little programs which can search the disk(by taking the output of dd) and find the location of keywords. Using this I was able to grab some data which I needed. I am sure this has happened in the past, so does anyone know of a tool which will automagically fix this issue?
    if (i_forgot && this_is_about_code)
    language = c++;

  2. #2
    Join Date
    Jun 2004
    Location
    Newcastle upon Tyne
    Posts
    2,978
    Don't I would be able to help but just trying to piece the events together to see if something is missing, as your F7 partition may still be good.

    It is unlikely to me any installer would use a Linux partition type 83 as a swap which must be type 82. Therefore you have to give expressed permission to FC5 installer to format the F7 partition and that sounds quite impossible.

    If you gave FC5 installer to freely arrange the partitions then the boundary of F7 must change too as a result.

    In both case of FC5 and F7 in a standard installation their installers would sell LVM to you. Did you use the LVM which could have made the partition harder for a misuse.

    The F7 now uses sda notation for hda but FC5 would still stick with hda. Was a mistake with the hard disk notation to blame for this problem?

    Lastly had the partition be used as a swap then its first 1Gb may have been disfigured and the filing indexing system may have gone too. Are you able to mount it say with a Live CD to see if it is still readable, assuming you alter the partition ID back to 83 first.
    Linux user started Jun 2004 - No. 361921
    Using a Linux live CD to clone XP
    To install Linux and keep Windows MBR untouched
    Adding extra Linux & Doing it in a lazy way
    A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
    Just cloning tips Just booting tips A collection of booting tips

    Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"

  3. #3
    Join Date
    Aug 2005
    Location
    Saint, Paul, MN USA
    Posts
    83
    Hi.

    I have seen this recommended, but have not had the bad luck to need to try it yet -- on the other hand, all of us should probably practice actions like this before we are faced with a crisis.

    Best wishes ... cheers, hotcold

    TestDisk is a powerful free data recovery software! It was primarily designed to help recover lost partitions and/or make non-booting disks bootable again when these symptoms are caused by faulty software, certain types of viruses or human error (such as accidentally deleting your Partition Table). Partition table recovery using TestDisk is really easy.

    TestDisk can

    * Fix partition table, recover deleted partition
    * Recover FAT32 boot sector from its backup
    * Rebuild FAT12/FAT16/FAT32 boot sector
    * Fix FAT tables
    * Rebuild NTFS boot sector
    * Recover NTFS boot sector from its backup
    * Fix MFT using MFT mirror
    * Locate ext2/ext3 Backup SuperBlock

    http://www.cgsecurity.org/wiki/TestDisk
    Also seen:

    http://www.gnu.org/software/ddrescue/ddrescue.html

    http://www.garloff.de/kurt/linux/ddrescue/

    (unknown if they are same or different)
    Last edited by hotcold; 07-04-2007 at 02:21 PM.
    [ "Sure, I can help you with that." -- USBank voice recognition system. ]
    ( Mn, 2.6.11-x1, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  4. #4
    Join Date
    May 2001
    Location
    Uh, I'm somewhere where I don't know where I am.
    Posts
    1,228
    Quote Originally Posted by saikee
    Don't I would be able to help but just trying to piece the events together to see if something is missing, as your F7 partition may still be good.

    It is unlikely to me any installer would use a Linux partition type 83 as a swap which must be type 82. Therefore you have to give expressed permission to FC5 installer to format the F7 partition and that sounds quite impossible.

    If you gave FC5 installer to freely arrange the partitions then the boundary of F7 must change too as a result.

    In both case of FC5 and F7 in a standard installation their installers would sell LVM to you. Did you use the LVM which could have made the partition harder for a misuse.

    The F7 now uses sda notation for hda but FC5 would still stick with hda. Was a mistake with the hard disk notation to blame for this problem?

    Lastly had the partition be used as a swap then its first 1Gb may have been disfigured and the filing indexing system may have gone too. Are you able to mount it say with a Live CD to see if it is still readable, assuming you alter the partition ID back to 83 first.
    I always check the partitions before I let the new installation begin it's work. I unchecked the old partitions, so they shouldn't have been reformatted. fdisk read the partitions as LVM 83, I checked a few times with a few different rescue disks.

    From what I saw from hexediting the drive, it does look like it was only the first gig or so bit the dust. FC5 still does see the disk as sda and the hda as the right disk as well.
    if (i_forgot && this_is_about_code)
    language = c++;

  5. #5
    Join Date
    May 2001
    Location
    Uh, I'm somewhere where I don't know where I am.
    Posts
    1,228
    Hotcold, I'll give these tools a try. I have what I believe is the correct portions of the disk dded onto a separate disk, so if I have to do it the hard way, I have the data backed up.

    Thanks.
    if (i_forgot && this_is_about_code)
    language = c++;

  6. #6
    Join Date
    Jun 2004
    Location
    Newcastle upon Tyne
    Posts
    2,978
    tecknophreak,

    You can dd the whole disk, put away the original and start rescuing with the coned copy.

    By the way if the partition is a LVM it should have been Type df, which you can check with cfdisk or fdisk. Your Post #4 reported it is LVM 83!

    You could use fdisk to correct the partition ID if you know definitely its original/correct partition type. Using the wrong type can cause the filing system incorrectly read. Changing the partiton ID only affect one byte in the partition table and does not alter the partition interior.
    Linux user started Jun 2004 - No. 361921
    Using a Linux live CD to clone XP
    To install Linux and keep Windows MBR untouched
    Adding extra Linux & Doing it in a lazy way
    A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
    Just cloning tips Just booting tips A collection of booting tips

    Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"

  7. #7
    Join Date
    Apr 2003
    Location
    UK
    Posts
    1,180
    e2fsck worked for me when I formatted a ext3 partition as swap, although in my case I realised immediately after I had done it so it wasn't actually used, I think I had to use the -f option to force it to run and it managed to find one of the backup superblocks and fix it on it's own.

    Perhaps try running "mke2fs -jn" on the partition to do a pretend format to find out where the backup superblocks would be and then feed one of them to e2fsck with the -b option. This might not work anyway since e2fsck should be able to find the backup superblocks itself, but is probably worth a try anyway.

  8. #8
    Join Date
    May 2001
    Location
    Uh, I'm somewhere where I don't know where I am.
    Posts
    1,228
    Quote Originally Posted by saikee
    tecknophreak,
    By the way if the partition is a LVM it should have been Type df, which you can check with cfdisk or fdisk. Your Post #4 reported it is LVM 83!
    My bad, it was actually 8e, I wasn't at the PC when I wrote that. According to fdisk it lists the LVM at 8e.

    Well, I got the files I needed off the disk, using dd and hexedit. Not fun, but it got the job done. Thanks for the help all. Time to backup then reinstall!
    if (i_forgot && this_is_about_code)
    language = c++;

  9. #9
    Join Date
    Jun 2004
    Location
    Newcastle upon Tyne
    Posts
    2,978
    tecknophreak ,

    Think you have to come clean on this one.

    Did you FC5 mount the LVM partition as a swap? or there could have been a mistake somewhere, say by imposing it yourself explicitly during an installation?

    I am hoping FC5 isn't silly enough to mount it just because you edit its fstab.

    Your information can help us to anticipate such mishap is possible.
    Linux user started Jun 2004 - No. 361921
    Using a Linux live CD to clone XP
    To install Linux and keep Windows MBR untouched
    Adding extra Linux & Doing it in a lazy way
    A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
    Just cloning tips Just booting tips A collection of booting tips

    Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"

  10. #10
    Join Date
    May 2001
    Location
    Uh, I'm somewhere where I don't know where I am.
    Posts
    1,228
    I'm not entirely sure how it happened. My guess is that on the installation I told it not to reformat, but I might not have check to see what the installation wanted to do with it.

    Again, I have no idea. I'm sure it was some sort of user error on the installation, because this never happened with other FC/F installs.
    if (i_forgot && this_is_about_code)
    language = c++;

  11. #11
    Join Date
    Jun 2004
    Location
    Newcastle upon Tyne
    Posts
    2,978
    That's OK

    We are just interested to know if an installer would knowingly "dare" to use a LVM for a swap without an explicit instruction from a user.

    Under the normal circumstance we expect some sort of warning would be issued by the installer before the action is committed. It is the installer's duty to protect the integrity of the system and most of them are pretty careful about this sort of things. If you do want to use the LVM as a swap Fedora's installer would still have to (1) alter the partition ID from "df" to "82" and (2) format the partition.
    Last edited by saikee; 07-06-2007 at 11:04 AM.
    Linux user started Jun 2004 - No. 361921
    Using a Linux live CD to clone XP
    To install Linux and keep Windows MBR untouched
    Adding extra Linux & Doing it in a lazy way
    A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
    Just cloning tips Just booting tips A collection of booting tips

    Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"

  12. #12
    Join Date
    Sep 2003
    Location
    Rochester, MN
    Posts
    3,604
    Hmm, this makes me very curious. *runs off to find an unused partition to see if it can be set as swap when not having an id of 82*

    Nope, no trouble doing that. The partition id's must be "more guidelines, than actual rules" as they say. Kinda sucks though, you'd think the installer would pick up the existing swap partition and use that.

  13. #13
    Join Date
    Jun 2004
    Location
    Newcastle upon Tyne
    Posts
    2,978
    cybertron,

    In all the Linux installation very few installers bothered me with the swap partition. They all seem to latch on to it. My hda5 swap serves over a hundred distros.

    I suppose if you mount it in a post installation situation it is a different circumstance because it is you who activates the arrangement and the installer isn't party to the decision.

    Just my 2 pences.

    By the way when I had more than one swaps the installers got confused asking should they use a or b or combine the two together.
    Linux user started Jun 2004 - No. 361921
    Using a Linux live CD to clone XP
    To install Linux and keep Windows MBR untouched
    Adding extra Linux & Doing it in a lazy way
    A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
    Just cloning tips Just booting tips A collection of booting tips

    Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"

  14. #14
    Join Date
    Sep 2003
    Location
    Rochester, MN
    Posts
    3,604
    Yeah, it just seems like mkswap shouldn't let you run it on a non-swap partition. Then again the installer definitely shouldn't be automatically using a non-swap partition for swap, so I guess I would file a bug report to the distro in this situation.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •