Re: (un)corrupted ext2 partitions

Arvind Sankar (arvinds@mit.edu)
Wed, 13 Jan 1999 22:54:20 -0500


On Wed, Jan 13, 1999 at 04:14:36AM -0500, Mike A. Harris wrote:
> 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.

duh? what files? I'm changing the name of the device.

>
> 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.

I did edit /etc/fstab. I even reran lilo, after changing root=.

>
> >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.

sorry, no can do. I had the same problem once more, and was dumb enough
to run e2fsck on my hdd. REALLY corrupted everything, so had to reinstall
linux.

>
> >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.

yeah. It was.

>
> >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.

Yup. Noted cylinder numbers.

[snip]
> 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.

I didn't pass out, and you got my idea.

>
> >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.

what's a filesystem remapper? and why should I have booted from floppy?
I edited lilo.conf on my hdd and reinstalled lilo.

>
> >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.

yeah, I would have thought so too. Both of us were wrong :-(
Anyway, one thing I may have missed is that I didn't unmount everything
before running fdisk. (I couldn't, since my / was one of the partitions
changing, and I needed that to run fdisk in the first place). But nothing
was physically messed, witness the fact that I could remount after
restoring the partition table.

-- arvind

-
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/