Find the answer to your Linux question:
Results 1 to 5 of 5
Hi all, I used to have a partition table like this (according to fdisk) /dev/sda1 * 1 7649 61440561 7 HPFS/NTFS /dev/sda2 7650 38913 251128080 f W95 Ext'd (LBA) /dev/sda5 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2009
    Posts
    2

    fdisk killed my partition table


    Hi all,

    I used to have a partition table like this (according to fdisk)

    /dev/sda1 * 1 7649 61440561 7 HPFS/NTFS
    /dev/sda2 7650 38913 251128080 f W95 Ext'd (LBA)
    /dev/sda5 7650 11473 30716248+ b W95 FAT32
    /dev/sda6 11474 11535 497983+ 82 Linux swap / Solaris
    /dev/sda7 11536 14598 24603516 83 Linux
    /dev/sda8 14599 38913 195310206 b W95 FAT32

    I would have liked to format the first FAT32 partition (/dev/sda5 in the table above) to ext3.

    So I started fdisk /dev/sda
    deleted the 5th FAT32 partition (/dev/sda5), added a new ext3 partition.

    After this action I got this table:
    /dev/sda1 * 1 7649 61440561 7 HPFS/NTFS
    /dev/sda2 7650 38913 251128080 f W95 Ext'd (LBA)
    /dev/sda5 11474 11535 497983+ 82 Linux swap / Solaris
    /dev/sda6 11536 14598 24603516 83 Linux
    /dev/sda7 14599 38913 195310206 b W95 FAT32
    /dev/sda8 7650 11473 30716248+ 83 Linux

    OK, I thought my new linux partition is /dev/sda8, so I formatted it:

    # mkfs.ext3 /dev/sda8

    After the reboot, my linux system was unable to boot due to the nubmer of partition devices had changed. Grub exited with Error 17.

    So I took my Ubuntu disk, started live ubuntu, and changed fstab, grub's menu.lst and chaged it to the new partition devices.

    After reboot, I realised that my second FAT32 partition had disappeared. I'd have liked to mount the new partiton as ext3 but it did't work.

    I found out that I'm able to mount with only different type:

    # mount | grep sda
    /dev/sda8 on /mnt/media type vfat
    /dev/sda7 on /mnt/linmedia type ext3


    fdisk says:
    /dev/sda7 14599 38913 195310206 b W95 FAT32
    /dev/sda8 7650 11473 30716248+ 83 Linux


    Now I've got ext3 on wrong partition. Maybe I formatted my second FAT32 to ext3?

    How could I restore my second FAT32 partition?

    I use Ubuntu 8.04

  2. #2
    Just Joined!
    Join Date
    Nov 2006
    Location
    UK
    Posts
    33
    I don't know for sure if there is a way back.

    It is possible that your partition numbering is now only out of sequence with /etc/fstab, and a bit of editing will fix it. Also, if the UUID (long number !) identification is used in /etc/fstab, as is the norm with Ubuntu, that may have now changed for partitions after /dev/sda5. Try creating a folder, and then mounting the partitons to it one by one, using a root terminal, and looking at them. Maybe the Windows partition is still there, unhurt, but not seen by /etc/fstab now.

    Deliberately deleting a partition to be free space, then re-formatting it to ext3 as a new partition with a sequentially allocated number (sda8 ), before reboot to show the system the new partition table, without a backup, is not done lightly.

    If you wanted the /dev/sda5 space without shoving around the partition numbers after it, you could have simply formatted it in place. #mkfs.ext3 /dev/sda5

    When you change partitions with fdisk, the system that is running at the time only knows of the partition table as it was at boot-up. Once you have written to the partition table, it is no longer in sync with the system. The new partition table is used at the next re-boot. Then /etc/fstab has to fixed to have the new setup be mounted automatically, unless you simply use a terminal to mount it when you want to.

    I have always taken note of the little reboot message when the partition table has been modified.
    I have read that it is possible to "undo" a simple format, provided that there has not been any other writes, and that there are tools to do it, but my guess is that what you did is about as positive as confirmations get, that you did not want to keep the data.

  3. #3
    Linux Engineer rcgreen's Avatar
    Join Date
    May 2006
    Location
    the hills
    Posts
    1,134
    So I started fdisk /dev/sda
    deleted the 5th FAT32 partition (/dev/sda5), added a new ext3 partition.

    After this action I got this table:
    /dev/sda1 * 1 7649 61440561 7 HPFS/NTFS
    /dev/sda2 7650 38913 251128080 f W95 Ext'd (LBA)
    /dev/sda5 11474 11535 497983+ 82 Linux swap / Solaris
    /dev/sda6 11536 14598 24603516 83 Linux
    /dev/sda7 14599 38913 195310206 b W95 FAT32
    /dev/sda8 7650 11473 30716248+ 83 Linux

    OK, I thought my new linux partition is /dev/sda8, so I formatted it:

    # mkfs.ext3 /dev/sda8
    Here's my guess.
    You rewrote the partition table, and formatted the partition, without
    rebooting. Since the partition table was not in sync with the running
    system, it formatted the FAT32 partition to EXT3. Fdisk still says
    it is flagged FAT32, but it is now formatted EXT3.

    So, yes, you formatted the second FAT32 partition to EXT3
    and the first FAT32 partition remains FAT32.

    Whether you can recover, I don't know.

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Nov 2006
    Location
    UK
    Posts
    33
    OK - try and step through what happened.

    When you issued a formatting command was when it was aimed at /dev/sda8.
    The new (as yet un-adopted) partition table would have intended to hit the space 7650 thru 11473.

    BUT, the command mkfs.ext3 /dev/sda8 was asking your system, (still using the OLD) partition table, to format the space between 14599 up to 38913.

    Then you reboot. All the numbers get put into the new straight sequence. Your fstab no longer makes any sense after sda5. I think the partition you re-formatted was the original W95 FAT32 /dev/sda8 being 14599 up to 38913.

    So - follow the route. Open a root terminal. Be careful !!
    use command fdisk -l
    Check out the present state, regardless of what is in /etc/fstab, nor what is in /boot/grub/menu.lst.
    Be curious as to what is in /boot/grub/device.map
    Curse quietly that the grub folder is littered with files.mod, each with a music play icon (Ubuntu!)
    Create a bunch of folders anywhere you like (e.g. in /home/recovery)
    Name them sda1, sda5, etc. (leave out sda2, sda3, sda4)
    Now mount them, one by one.
    #mount /dev/sda1 /home/recovery/sda1 .. and so on.

    You may get "wrong type" objections. You may have to modify the mount command to something like ..
    #mount -t ext3 /dev/sda6 .. and try out various valid types.

    If you can mount them, you can recognize what is in there and start sorting it out.

    As for the ex sda8, (now maybe looking like empty space). Look to fsck and Google is your friend. This inadvertent format may be undo-able. Even if you can't, you may still be able to get at most of what you want.
    Here is a link to a posting from someone who recovered all their digital photos -> Debian-User: Re: Undo of mkfs - urgent

    Be aware that the ext3 format operation is very destructive, since it zeros out the inode table as well as the journal. If what was on that partition was especially valuable, you can use the "dd" command to copy out the whole partition image to someplace where you can start data recovery. That said, you are warned right now, that if ever there was a command with more destructive power than "mkfs.ext3", it is the "dd" command used wrongly. You just HAVE to read up, and be quite sure it will not hurt everything nearby you forgot to protect/backup.

  6. #5
    Just Joined!
    Join Date
    Dec 2009
    Posts
    2
    Thanks the answers!

    Yes, I'd have read that notice of fdisk, after I had written tha partition table, that I'd reboot in order to get the kernel detect my new partition table.

    Fortunately I've got everything backuped, but it gonna take a lot of time to restore.

Posting Permissions

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