[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reducing the size of an ext2 partition



On Sat, 19 Sep 1998, Shlomi Fish wrote:
> 
> 
> I was told that tune2fs can do that thing. If I create a root diskette
> with fdisk and the e2fs-tools, will I be able to do it? Did anybody manage
> to do that before?

I don't know whether anyone tried that before, but the design of the
ext2 filesystem lets you resize it (tune2fs can't do it).

I can explain you how to do it, and you could write a program that resize
an ext2 filesystem so others will be able to use it too (I would have done
it myself, had I had the time....)

The ext2 filesystem is built of several groups, each group has the its own
inodes, blocks, group-descriptors and  inode/blocks allocation bitmaps. 

I think that all you have to do is first defrag the filesystem (There is a
utility that does that), calculate (using the information from the
superblock) how many groups you have to take out, and update all the
superblocks of the filesystem with reduced number of blocks and inodes. I 
think I heard of a program called ext2ed that can help you do that, but
you can do it manually too.

Next you'll have to destroy the two partitions, and create them both with
the new sizes.

Few problems with that method:
1. You have to be ulra-careful (better back up beforehand...).
2. You have to carefully calculate it to the (disk) block-level.
3. You have to check that defrag didn't leave any information in the
   going-to-be-deleted groups.
4. There is a lot of stuff to read, but I can save you the searching time.
   I think that I have all the information you'll be able to find about 
   ext2 (and some information that doesn't exists on the web anymore)
5. I might have forgotten something, so don't blame me later.

If you need anymore information email me.

BTW: I think that PartitionMagic said they'd include a program to resize
ext2 filesystems in the next version.
I just went to their site, they released PartitionMagic 4.0, and say it
has full support for ext2 partitions, and in another place they write that
they can do whatever you want with a filesystem, so I guess that they can
resize an ext2 partition....

> 
> Assuming I'll have to re-partition my hard-disk: will tarring everything
> in / into a tgz file, and then un-tarring it in the empty partition, do
> the trick?

Just remember to tar it with --preserve 
> 
> 	Shlomi Fish
> 

Liran.
---
http://www.math.tau.ac.il/~liranz/