Click to See Complete Forum and Search --> : converting from ext2 to ext3


doublec16
02-17-2003, 07:41 AM
Is it possible to convert a partition from ext2 to ext3 without losing data? If so, how? If not, is there a way to do it by archiving the data somewhere else and then recopying it over after the conversion? If so, can this be done to the /var or / partitions for example while keeping the OS running (ie does it require a complete reformat)? The computer is running RedHat 7.x or 8.0.

On a related note, is it possible to check for bad blocks and mark them as unusable so the computer doesn't try to access them, without having to put the drive into another computer and using some DOS or windows program? Is there a linux program which does this. No, fsck does not do this. It checks for and finds bad blocks but it doesn't repair them or do anything so the same bad blocks don't appear later and cause errors and crashes. Possibly I am not using fsck to its full capabilities however so if there is a fsck option to do this please tell me. I have looked at the manpage but I was not enlightened.

Thanks.

mrBen
02-17-2003, 08:41 AM
See http://www.redhat.com/docs/manuals/linux/RHL-7.3-Manual/ref-guide/s1-filesystem-ext3-convert.html

The answer is, Yes, you can, using tune2fs to add the journal.

root.veg
02-17-2003, 08:48 AM
For the first question do:

tune2fs -j /dev/hdxx

to create an ext3 journal (obviously replace hdxx with the name of the partition you want). If you do this with the partition unmounted, then you'll get a journal which can't easily be viewed normally (a good thing I think). If you do it while the partition is mounted, then you'll be able to view the journal within the filesystem. Use "man tune2fs" for more info. Oh yes, and if you want to do this on your root (/) partition then you'll probably need a root-boot disk in order to do it the invisible-journal way. tomsrtbt and Knoppix spring to mind.


No idea on the second problem, sorry!

root.veg
02-17-2003, 08:50 AM
Plus you need to change the "ext2"s in /etc/fstab to "ext3"s. Important, that. I forgot that when I first tried it.

doublec16
02-17-2003, 09:03 AM
Cool, thanks. I'll try that journal thingie when I wake up. If it is done when it is mounted, and produces a user-readable journal, then is the journal still user-readable when it is rebooted or unmounted and remounted?

Can anyone help with repairing bad sectors on a partition in linux? Surely a common problem like bad sectors shouldn't require resorting to windows or DOS. :(

bwkaz
02-17-2003, 10:47 AM
Windows/DOS don't repair bad sectors, they just map them out of existence.

From the e2fsck manpage:

-c This option causes e2fsck to run the badblocks(8) program to find any blocks
which are bad on the filesystem, and then marks them as bad by adding them
to the bad block inode. If this option is specified twice, then the bad
block scan will be done using a non-destructive read-write test. So add a -c -c to your fsck command, and the bad blocks will be added to the "bad block" inode (which is effectively mapping them out of existence).

doublec16
02-17-2003, 01:52 PM
Thanks. I did not know about e2fsck before, just regular fsck.

doublec16
02-17-2003, 02:30 PM
How can I find out what is using a particular partition so I can unmount it. I'd rather not run e2fsck on a mounted partition because it says it's dangerous. Is there a way to force it to unmount no matter what is using it?

Also, I run 2.4.18-rc2-ac1 on one particular machine (I had to upgrade because I needed SMP support) but it's saying that the kernel version doesn't support ext3. What kernel version can I use that supports both SMP and ext3?

camelrider
02-17-2003, 04:22 PM
"cat mtab"
will show mounted filesystems.

doublec16
02-17-2003, 04:26 PM
Is there anything that shows what is using a particular filesystem?

doublec16
02-17-2003, 04:48 PM
aha I found it with a search. The command is

lsof /dev/hdxx

That will go straight to my list of useful commands to remember.

doublec16
02-17-2003, 05:07 PM
How can I shut down gdm? I keep killing the gdm process but it keeps restarting itself. It's the only process using /var (the partition I want to unmount). Please tell me how to stop it for good.

doublec16
02-17-2003, 06:25 PM
Well I ended up just doing the e2fsck on the /var filesystem which I had remounted readonly, since I couldn't unmount it. Now I need to remount it read/write again but it won't let me because it's already mounted readonly. How can I remount it with read/write access? Thanks.

bwkaz
02-17-2003, 07:09 PM
You can kill gdm by getting OUT of the graphical login runlevel. Do an init 3 to shut it (and X) down.

To remount stuff read-write, do a mount -o remount,rw <mount point> (assuming the mount point is in fstab).

One other thing; most of the time, mtab is correct on what's mounted, but not always. Sometimes, for example when the root filesystem is read-only, it can't get updated properly. The official, straight-from-the-kernel list of mounts is /proc/mounts.

Also, I run 2.4.18-rc2-ac1 on one particular machine (I had to upgrade because I needed SMP support) No, you didn't need to upgrade to get SMP support. SMP has been supported in Linux since an EXTREMELY long time ago, probably 2.0 kernels. ALL of them have the SMP option. You do need to select "CONFIG_SMP" when you configure it, though. The reason your current kernel doesn't support ext3 is that again, when you were configuring it, under "filesystems", you didn't select CONFIG_EXT3 (or whatever it's called).

doublec16
02-25-2003, 12:28 AM
Well I must have run the command

e2fsck -c -c /dev/hdax

about 5 times now and it still tries to read the bad blocks. How do I do the check and actually make it so that it doesn't try to access the bad blocks? I'm getting tired of it crashing and then taking forever at bootup because it's trying to check the bad part of the disk.

Thanks.

mdwatts
02-25-2003, 07:58 AM
Have you tried

e2fsck -p /dev/hdax

to attempt to fix the errors?


Thanks. I did not know about e2fsck before, just regular fsck.


Have a look through /sbin to see what is available. Don't run anything until you have read the related manpage and understand what the program does.