Re: (un)corrupted ext2 partitions

Mike A. Harris (mharris@ican.net)
Wed, 13 Jan 1999 04:14:36 -0500 (EST)


On Mon, 11 Jan 1999, Arvind Sankar wrote:

>Does the ext2 file system depend on /dev/hda5 staying /dev/hda5?

The kernel filesystem code doesn't care where a filesystem is.
If you have something on hda2 and move the whole works of it to
/dev/hdj24, it is still an ext2 filesystem (assuming that hdj24
was properly formatted with mke2fs). You need to be careful
moving the files over however and ensure that permissions,
ownership, etc do not change.

The only thing that changes when a filesystem moves from
partition to partition is the way you mount it. So if your
/etc/fstab says to mount /usr from /dev/hda2, and you move that
data from /dev/hda2 to dev/hdj24 then you need to change fstab to
mount /usr from /dev/hdj24.

>What happened was that I had a working Linux system on my hdd, with
>/dev/hda1 as DOS, /dev/hda2 as linux /boot, /dev/hda3 unused, and /dev/hda4
>an extended partition with the other linux partitions on it (/, /home etc).
>The first partition inside the extended one was unused.

An "fdisk -l" screenshot would be more descriptive. You can use
the mouse to cut and paste the output of that command into your
email.

>My original idea was to use the two unused partitions to install NetBSD.
>However, when I actually looked at the thing, I found of course that it
>wants to sit inside a primary partition and carve it up itself.

2 unused partitions? /dev/hda3 and /dev/hda5? /dev/hda5 would
be the first partition inside the extended one.

>So I decided to repartition the hdd to allow for installing BSD. I know
>this is not a nice thing to do, but still. I noted down the location of all
>my Linux partitions, and then proceeded:

I'm assuming that you're meaning you copied the raw partition
table down by hand/printer so you knew the physical locations of
all primary/extended/logical partitions on your disk.

>I deleted /dev/hda3

No problem. You could have just changed it's partition id to
another type though, and then ran the proper filesystem creation
program on it.

>and 4,

/dev/hda4 is your extended partition. When you undid it, you
opened up the space for partitioning for ALL of your extended
partitions and lost your extended partition table.

>and recreated them with /dev/hda3 bigger, and the extended
>partition no longer containing the unused partition that it
>earlier had.

So you wanted the extended partition to START where /dev/hda6 was
instead of where your currently unused /dev/hda5 was? That way
your original /dev/hda6 if unharmed by the process would become
now /dev/hda5?

In other words, "if I remove hda3, and move hda4's start point to
hda6, then my new hda3 can be bigger (the size of old hda3+hda5),
and my original hda6 now becomes the first partition in hda4.

Ok, now draw a chart down, of what all I said above (if you
didn't pass out reading it ;o) and go through it slow. ;o) I
think I follow your idea so far.

>So now / changed from /dev/hda6 to /dev/hda5. When I booted to
>try this out, fsck cribbed that my /dev/hda5 had big problems,
>and advised me to run e2fsck manually.

Assuming that you manually edited the raw partition table and
actually got everything correct, you should have booted from
floppy, then edited your lilo.conf and reinstalled lilo. I'm not
even sure that the entire process discussed above is possible
without some sort of advanced filesystem remapper.

>I didn't, and instead repartitioned again, with /dev/hda3 a little smaller,
>and a tiny partition in /dev/hda4, so that my / went back to /dev/hda6, and
>now everything checked clean.
>
>How come this happens? Does the ext2 fs depend on the device number in
>some vague way?

No, but you need to change your filesystem table so that mount
mounts everything in the right space. That is the only thing I
can think that you possibly did wrong besides possibly LILO. I
would think that your repartitioning should have worked.

>I was running kernel 2.1.130 on a Celeron 333. The hdd is an IBM Deskstar.
>Model number:IBM-DHEA-38451

Hmmm. I personally would have done it with a 2.0.36 kernel to be
safe, but without further details of your system, etc.. it's hard
to say what exactly it could be.

--
Mike A. Harris  -  Computer Consultant  -  Linux advocate

Linux software galore: http://freshmeat.net

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/