LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   (hard one) cant mount ext2(or swap) anymore - recover data (https://www.linuxquestions.org/questions/linux-hardware-18/hard-one-cant-mount-ext2-or-swap-anymore-recover-data-305517/)

pawn-o-matic 03-24-2005 11:01 AM

(not solved) cant mount ext2(or swap) anymore - recover data
 
Hi all,

I was going to shrink my ext3 root partition to make place for a home one. So i booted knoppix and started playing with resize2fs and fdisk
Code:

root@ttyp1[knoppix]# e2fsck -f /dev/hda1 && resize2fs /dev/hda1 60G
e2fsck 1.35 (28-Feb-2004)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/hda1: 703731/9928704 files (3.6% non-contiguous), 14083581/19827730 blocks
resize2fs 1.35 (28-Feb-2004)
Resizing the filesystem on /dev/hda1 to 15728640 (4k) blocks.
The filesystem on /dev/hda1 is now 15728640 blocks long.

::FDISK OUTPUT AFTER SHRINKING:

Device Boot      Start        End      Blocks  Id  System
/dev/hda1              1      119068    60010240+  83  Linux
/dev/hda2          157364      158816      732312  83  Linux

Then deleted hda2 with cfdisk and created a bigger one (hda2 20Go). Here's maybe my error: i ran mke2fs.ext2, but it said that hda2 was mounted (i omited to run swapoff). When i re-ran mke2fs, it did it very quickly (less than 1 sec) but i idnt care. I managed to mount the partition and started to backup my home directory in mc.
Code:

root@ttyp2[knoppix]# mount /dev/hda2 /mnt/hda1/
root@ttyp2[knoppix]# mount
/dev/root on / type ext2 (rw)
/dev/scd1 on /cdrom type iso9660 (ro)
/dev/cloop on /KNOPPIX type iso9660 (ro)
/ramdisk on /ramdisk type tmpfs (rw,size=194196k)
/proc/bus/usb on /proc/bus/usb type usbdevfs (rw,devmode=0666)
automount(pid935) on /mnt/auto type autofs (rw,fd=4,pgrp=935,minproto=2,maxproto=4)
/dev/hda2 on /mnt/hda1 type ext2 (rw)
root@ttyp2[knoppix]# cd /mnt/hda1/
root@ttyp2[hda1]# ls
pawn

Then i deleted some things on my hda1 partition, re-ran the same procedure, but when i ran resize2fs to enlarge my hda2 partition:
Code:

root@ttyp1[mnt]# resize2fs -p /dev/hda2
resize2fs 1.35 (28-Feb-2004)
resize2fs: Bad magic number in super-block while trying to open /dev/hda2
Couldn't find valid filesystem superblock.
root@ttyp1[mnt]# fsck.ext2 /dev/hda2
e2fsck 1.35 (28-Feb-2004)
Couldn't find ext2 superblock, trying backup blocks...
fsck.ext2: Bad magic number in super-block while trying to open /dev/hda2

The superblock could not be read or does not describe a correct ext2
filesystem.  If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>

So the partition became corrupt, i dont know why:scratch: . I cant mount it again. I dont know how to recover data. It seems like it is in fact still swap.

Here's my actual partition table:
Code:

Command (m for help): p

Disk /dev/hda: 81.9 GB, 81964302336 bytes
16 heads, 63 sectors/track, 158816 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/hda1              1      59544    30010144+  83  Linux
/dev/hda2          119069      158816    20032992  83  Linux
/dev/hda3          59545      119068    30000096  83  Linux

Please help me recovering my datas. :(
Thx for any help

pawn

slightcrazed 03-24-2005 11:38 AM

Hmmm...... if Hda2 was your swap partition did you possibly neglect to change the type to linux native (type 82 in cfdisk I think) from linux swap (type 83). I've never run into this problem, but it may explain why you are getting the error above. You may be able to change the type without harming your data, I would either check cfdisk's man page or google for the above.

Also, as far as backup, I think you can copy the entire contents of the ext2 partition by accessing it with it's device name /dev/hda2. Someone correct me if I'm wrong, but you only need to mount it if you want it to be part of the filesystem. The data can still be accessed using the device name (you just can't navigate the tree). Best bet may be to try making a tape archive (tar) of everything on the /dev/hda2 partition, and then seeing if you can un-tar it onto the /dev/hda1 partition.

slight

pawn-o-matic 03-24-2005 12:02 PM

Here's my cfdik output:
Code:

    hda1                          Primary    Linux ext2                              30730.43
    hda3                          Primary    Linux ext2                              30720.10
    hda2                          Primary    Linux                                  20513.79

As you can see, hda2 is not an Linux swap anymore. But not an linux ext2 too.
I dont find linux ext2 type in the cfdisk partition types and i dont know what Linux represent. So i didnt do anything at this point.

For accessing my data from /dev/hda2, i can use dd if=/dev/hda2, but i dont know what to do with the output. tar -cf backup.tar /dev/hda2 create an archive with the special device in.

Ive tried to force mounting as ext2 but i cant find my files.

A good think would be being able to mount swap partition, or finding why i cant mount it as ext2 anymore. I checked my consoles several times but i cant see the cause.

thx for your reply

pawn

pawn-o-matic 03-24-2005 02:17 PM

I decided to forgot about my datas. I deleted the partition and will start everything from scratch. What an hard moment :(

thx


pawn


All times are GMT -5. The time now is 06:00 AM.