On Fri, 2002-01-18 at 13:19, Eric Sandeen wrote:
> On Fri, 2002-01-18 at 13:08, Steve Lord wrote:
> > Might that in place filesystem converter work for this?
>
> Hm, maybe. Convert from XFS to XFS, but make the loopback filesystem
> the size of your new, smaller filesystem. And before you map the
> loopback filesystem down to the block device, shrink the block device
by
> removing a volume.
Actually, this will work! (Except that convertfs seems to have trouble
converting _to_ xfs, let alone shrinking, I'll have to look at this...)
However, behold this example of using secret Russian technology* to
shrink an ext2 filesystem from 197 megs to 95 megs:
*http://tzukanov.narod. ru/convertfs/
-=BEFORE=-
[root@lite convertfs]# mke2fs -q /dev/sda1
mke2fs 1.23, 15-Aug-2001 for EXT2 FS 0.5b, 95/08/09
[root@lite convertfs]# mount /dev/sda1 /mnt/sda1/
[root@lite convertfs]# cp -aR /mnt/sda2/sda1/* /mnt/sda1/
[root@lite convertfs]# df -h /dev/sda1
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 197M 32M 155M 17% /mnt/sda1
[root@lite convertfs]# umount /dev/sda1
-=DURING=-
Run convertfs, with slight modifications:
(mkfs of new filesystem restricts size to new, smaller size)
(100000 blocks)
[root@lite convertfs]# ./shrinkfs
== Creating clone of filesystem's device ==
===== Creating destination filesystem =====
mke2fs 1.23, 15-Aug-2001 for EXT2 FS 0.5b, 95/08/09
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
25064 inodes, 100000 blocks
5000 blocks (5.00%) reserved for the super user
First data block=1
13 block groups
8192 blocks per group, 8192 fragments per group
1928 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
============== Copying files ==============
total 18
drwxr-xr-x 3 root root 1024 Jan 16 10:35 foo
drwxr-xr-x 2 nfsnobod nfsnobod 1024 Jan 15 16:31 linktest
drwxr-xr-x 2 root root 12288 Jan 18 13:26 lost+found
drwxr-xr-x 10 root root 2048 Jan 17 14:10 root
drwxr-xr-x 3 root root 1024 Jan 15 13:37 testing
drwxr-xr-x 2 root root 1024 Jan 17 14:12 tmp
Filesystem Size Used Avail Use% Mounted on
/dev/loop7 95M 32M 58M 36% /usr/convertfs/fs2root
=== Preparing info for block relocation ===
0+1 records in
0+1 records out
============ Relocating blocks ============
Loading indexblocks... done.
Relocating blocks... done.
<etc>
<dies with an assert, but...>
-=AFTER=-
[root@lite convertfs]# e2fsck /dev/sda1
e2fsck 1.23, 15-Aug-2001 for EXT2 FS 0.5b, 95/08/09
/dev/sda1: clean, 1475/25064 files, 35350/100000 blocks
[root@lite convertfs]# mount /dev/sda1 /mnt/sda1/
[root@lite convertfs]# df -h /dev/sda1
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 95M 32M 58M 36% /mnt/sda1
Ta-Da!
Um, don't try this with data that _matters_ - ok?
-Eric
--
Eric Sandeen XFS for Linux http://oss.sgi.com/projects/xfs
sandeen@xxxxxxx SGI, Inc.
|