Re: shrinking a filesystem using resize_ffs(8)

2024-02-01 Thread Jan Schaumann
Michael van Elst  wrote:
> jscha...@netmeister.org (Jan Schaumann) writes:

> >$ sudo newfs -C 2 /dev/rvnd0a
>
> There is no '-C'. Maybe -O 2 ?

Yes. :-)

> But resize_ffs doesn't support shrinking FFS2 and should
> complain when you try.

> You tell resize_fsck the new size with -s and then
> reduce the partition size accordingly.

Ah, the order is first resize_ffs, then update the
disklabel.  So the order is:

$ sudo newfs -O 1 vnd0a  # start out with 1GB
/dev/rvnd0a: 1024.0MB (2097152 sectors) block size
16384, fragment size 2048
using 6 cylinder groups of 170.67MB, 10923 blks, 21504 inodes.
super-block backups (for fsck_ffs -b #) at:
33, 349568, 699104, 1048640, 1398176, 1747712,
$ sudo resize_ffs -s 1048576 /dev/rvnd0a  # shrink to 512MV
$ sudo disklabel -e vnd0  # adjust disklabel
$ sudo mount /dev/vnd0a /mnt
$ df -h /mnt
Filesystem Size   Used  Avail %Cap Mounted on
/dev/vnd0a 504M   2.0K   479M   0% /mnt
$ 

Nice, that works.

Thanks!
-Jan


Re: shrinking a filesystem using resize_ffs(8)

2024-02-01 Thread Michael van Elst
jscha...@netmeister.org (Jan Schaumann) writes:

>Hi,

Hi,

>$ sudo newfs -C 2 /dev/rvnd0a

There is no '-C'. Maybe -O 2 ?

But resize_ffs doesn't support shrinking FFS2 and should
complain when you try.


>[ back to two '1048576' sized partitions ]

>$ sudo fsck_ffs -y -f /dev/rvnd0b
>[ all ok ]

The 'b' filesystem was probably never changed but maybe trashed in
a way that fsck doesn't understand.


>$ sudo resize_ffs -v /dev/rvnd0b
>No change requested: already 524288 blocks

The superblock and partition agree. Nothing
to do and nothing to check.


>$ sudo fsck_ffs -y -f /dev/rvnd0a
>** /dev/rvnd0a

>CANNOT READ: BLK 2010160
>CONTINUE? yes

The 'a' filesystem still thinks it is 1GB and you try to shrink
it. But the disklabel already restricts access to the lower half.
Any attempt to access data from the upper half fails.


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

Dito. Shrinking requires access to all the data.


>So... how do I shrink a filesystem?

You tell resize_fsck the new size with -s and then
reduce the partition size accordingly.