Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Hardware
User Name
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?


  Search this Thread
Old 03-24-2005, 11:01 AM   #1
Registered: Jul 2003
Posts: 44

Rep: Reputation: 15
(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
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.


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.
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
Then i deleted some things on my hda1 partition, re-ran the same procedure, but when i ran resize2fs to enlarge my hda2 partition:
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 . 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:
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


Last edited by pawn-o-matic; 03-24-2005 at 12:52 PM.
Old 03-24-2005, 11:38 AM   #2
Registered: May 2003
Location: Lisbon Falls, Maine
Distribution: RH 8.0, 9.0, FC2 - 4, Slack 9.0 - 10.2, Knoppix 3.4 - 4.0, LFS,
Posts: 789

Rep: Reputation: 30
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.

Old 03-24-2005, 12:02 PM   #3
Registered: Jul 2003
Posts: 44

Original Poster
Rep: Reputation: 15
Here's my cfdik output:
    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

Old 03-24-2005, 02:17 PM   #4
Registered: Jul 2003
Posts: 44

Original Poster
Rep: Reputation: 15
I decided to forgot about my datas. I deleted the partition and will start everything from scratch. What an hard moment



Last edited by pawn-o-matic; 03-24-2005 at 02:47 PM.


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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Recover ext2 data after reformat?? swell Linux - Software 4 04-03-2006 10:53 PM
How to recover data from hard disk dongyan_liu Linux - Newbie 1 12-01-2005 05:56 PM
Software to acess and recover data on Fat32 data NeoSpawn Linux - Software 2 09-04-2005 11:37 AM
can't mount swap & win partitions anymore Dominik Linux - Newbie 6 12-22-2003 09:29 AM
Fat32, Ext2, Swap???? darxoul Linux - Software 4 07-09-2003 01:38 PM > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 09:55 AM.

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