NetBSD-Users archive

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

shrinking a filesystem using resize_ffs(8)



Hi,

I'm trying to shrink a filesystem using resize_ffs(8),
but I keep getting an error:

resize_ffs: read failed: Invalid argument


Here's the setup:

I start out with a 1GB disk with two 512MB partitions:

$ sudo disklabel vnd0
[...]
#        size    offset     fstype [fsize bsize  cpg/sgs]
 a:   1048576         0     4.2BSD      0     0     0 # (Cyl.      0 -    511)
 b:   1048576   1048576     4.2BSD      0     0     0 # (Cyl.    512 -   1023)
 d:   2097152         0     unused      0     0       # (Cyl.      0 -   1023)
$ sudo newfs -C 2 /dev/rvnd0a
[...]
$ sudo newfs -C 2 /dev/rvnd0b
[...]

I can easily grow partitiona 'a' to the size of the
full disk:

$ sudo disklabel -e vnd0
[ becomes now: ]
#        size    offset     fstype [fsize bsize  cpg/sgs]
 a:   2097152         0     4.2BSD      0     0     0 # (Cyl.      0 -   1023)
 d:   2097152         0     unused      0     0       # (Cyl.      0 -   1023)

$ sudo fsck_ffs -f /dev/rvnd0a >/dev/null
$ sudo resize_ffs /dev/rvnd0a
[...]
$ sudo mount /dev/vnd0a /mnt
$ df -h /mnt
Filesystem         Size       Used      Avail %Cap  Mounted on
/dev/vnd0a         963M       1.0K       915M   0%  /mnt

Now trying to shrink it again:

$ sudo umount /mnt
$ sudo disklabel -e vnd0
[ back to two '1048576' sized partitions ]
$ sudo fsck_ffs -y -f /dev/rvnd0b
[ all ok ]
$ sudo resize_ffs -v /dev/rvnd0b
No change requested: already 524288 blocks
$ sudo fsck_ffs -y -f /dev/rvnd0a
** /dev/rvnd0a

CANNOT READ: BLK 2010160
CONTINUE? yes

THE FOLLOWING DISK SECTORS COULD NOT BE READ: 2010160, 2010161, 2010162, 2010163,
/dev/rvnd0a: CANNOT FIGURE OUT SECTORS PER CYLINDER

$ sudo resize_ffs -v /dev/rvnd0a
resize_ffs: read failed: Invalid argument
$ 

So the second partition worked out just fine, but
vnd0a could not be shrunk.  (It's not surprising that
fsck couldn't read the noted sectors prior to running
resize_ffs, since those were now beyond its new
size.)

So... how do I shrink a filesystem?

-Jan


Home | Main Index | Thread Index | Old Index