How to re-distribute space between FreeBSD partitions?

Hello everyone,

I need your advice on how to re-disribute space between existing FreeBSD partitions. # gpart show returns the following:

Code:
# gpart show
=>       63  104857515  ad0  MBR  (50G)
         63       1953       - free -  (977K)
       2016  104855184    1  freebsd  (50G)
  104857200        378       - free -  (189K)

=>        0  104855184  ad0s1  BSD  (50G)
          0    4194304      1  freebsd-ufs  (2.0G)
    4194304    8384512      2  freebsd-swap  (4.0G)
   12578816    4194304      4  freebsd-ufs  (2.0G)
   16773120   88074240      5  freebsd-ufs  (42G)
  104847360       7824         - free -  (3.8M)

I'd like to decrease partition 5 by 5GB and add that 5GB space to partition 1. I wonder if it can be done in principle (I am a newbie to Unix-like systems).

Although I figured out a way to decrease partition 5 (in single-user mode): # gpart resize -i 5 -s 37GB ad0s1, but the system does not boot in multi-user mode after that.

Regards
 
Unfortunately the best way to do it is to back up the data, remove the old partitions, create new ones and restore the data.

But why do you want to add 5GB to partition 1? What's the layout like? Normally 2GB should be enough for the root partition (/). I'm assuming the others are /var/ and /usr/?
 
Yes, you're right, the others are /var/ and /usr/. Actually, I try to increase the size of /, because we are unable to install some softaware (Mathematica). I launch the installer (located in the /usr/local/) and after quite some time get message about absence of free space.

I googled that one possible reason for that is the fact /tmp/ is not mounted as a separate partition, but iincorporated into / and problem possibly can be solved by addition of space. That's why I try to increase its size (apart from curiosity on how partitioning mechanism works in FreeBSD :-)).
 
Ah. If you just want some more room in /tmp you could try tmpfs(5). That'll use RAM + swap to create a dynamic filesystem. Or, as you already did, resize partition 5 to make it smaller, create a new filesystem on the available space and mount that on /tmp.

Enlarging partition 1 is not possible because all the other partitions would have to move to make room.
 
I decided to try it the second way first. But after repartitioning the system fails booting. Could you, please, tell, what I'm doing wrong:

[cmd=]gpart resize -i 5 -s 37GB ad0s1[/cmd]
[cmd=]gpart add -t freebsd-ufs -i 6 -s 5100M ad0s1[/cmd]
(used 5100M instead of 5G to guarantee some free space remains after the last partition, wonder if it is needed)
[cmd=]newfs /dev/ad0s1f[/cmd]

After that, the system can not start (I attached a screenshot, since I'm not sure which line is of importance here).

http://screencast.com/t/9gQmkwsnDyX1
 
That's not "Can not start" That's "Wants to start in single user mode" so.. hit enter.. and re-label the "missing" partition.
 
Yep, you made an error in your /etc/fstab. While in single user mode:
Code:
fsck -y
mount -u /
mount -a -t ufs
swapon -a
After that you should be able to edit /etc/fstab and fix the error.
 
Unfortunately, it didn't work.

# fsck -y returns
Code:
Can't stat /dev/label/usr0: No such file or directory
# mount -u / returns no output.
# mount -a -t ufs returns the same error message ("Can't stat" is replaced with "Mount").
# swapon -a returns no output.

Still no way to boot in "normal" mode.

Not quite sure how to re-label (executed the same command with -L option, i. e. # newfs -L tmp /dev/ad0s1f, it did not make any difference).
 
Forgot to mention, that I edited /etc/fstab in sinle-user mode -- added line
Code:
/dev/label/tmp0 /tmp ufs rw,noatime 1 1
--
still no luck.
 
Back
Top