0

I was upgrading FreeBSD packages as part of a minor version upgrade and I ran out of space on /var/cache/pkg. Now I need to

  • shrink /usr
  • move /usr and /tmp
  • grow /var

Is this possible with FreeBSD? If I've understood what I've read so far, I should be able to shrink /usr with growfs -s <smallersize> /dev/ada0p6 but I have no idea how to relocate the partitions. (It would be easy with gparted, but the manual says gparted can't modify UFS partitions.)

Can anyone give me a step-by-step to do this, or do I need to bite the bullet and do a wipe-and-reinstall? Thanks.

1
  • Maybe would be useful if you post gpart show -l: if /usr and /var aren't side-by-side you can't do this.
    – uzsolt
    Feb 25, 2021 at 8:06

1 Answer 1

0

In pracitcal use I would clearly recommend to just back up the data, recreate the partitions and restore. This will be much faster.

growfs(8) has had the ability to resize a mounted file system since FreeBSD 10.0.

From the Handbook we learn that the partitions can only be resized into contiguous free space. This is why a commenter (@uzsolt) asked for the output of gpart show -l.

So you can do all the things you want easily except relocate the partition. I know of no tool which does this automatically for you. And this would be the problem if your space is not contiguous. You will then need to create a new partition and move the data there. To be able to do that you need to have enough free space and if space is a problem this becomes painful.

If your system is in a VM then you can probably easily attach more space. If this is a physical system then I would attach a USB disk and do a backup/restore rather than a full reinstall. Or maybe it was what you were implying.

Dumping and restoring a slice (s1d) is not too scary:

dump -0Laf - /dev/ada0s1d  | restore -rf -

You can see all the steps to go trough in the article Resize Existing FreeBSD Root Partition or Slice Safely Without Re-Installing or Rebooting

And a final little note: You have a couple of other options to solve your current problem with the minor upgrade. You could link to another location for var/cache/pkg - or even better - set PKG_CACHEDIR in pkg.conf(5)

3
  • 1
    Changing PKG_CACHEDIR via setenv solved my problem. I've revised my question title slightly to reflect this. Thanks. Feb 25, 2021 at 15:20
  • 1
    Wouldn't you want to omit the -u ( update ) flag?
    – psusi
    Feb 26, 2021 at 19:49
  • Absolutely. No reason to create /etc/dumpdates in this case (I'll update) Feb 26, 2021 at 21:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .