This one is easier than previous (FreeBSD 7.x or older).

It may be possible to do it all live but you need to find a way for FreeBSD to see the growed disk size.

  • Shut down the server
  • Grow the disk size
  • Boot FreeBSD in single user mode (number 4 at boot)

Check the partitions layout:

gpart show

Set the system in evil mode that will allow gpart to change live filesystem:

sysctl kern.geom.debugflags=16

Grow the whole disk – consumer. Number 1 is the consumer index shown with gpart show

gpart resize -i 1 da0

Grow desired provider – partition. Number 6 is the provider index shown with gpart show

gpart resize -i 6 da0s1

Now with partition resized you can growfs

growfs /dev/da0s1f

Reboot for a clean feeling and you’re done.

S.

Comments

Eneko2014-01-22 16:58:14

Hello Simon,

I am having problems resizing my partition /usr… from your experience if you could tell me what could be wrong…

Below I am sending to you some outputs:

df -h

Filesystem Size Used Avail Capacity Mounted on
/dev/da0s1a 484M 320M 125M 72% /
devfs 1.0K 1.0K 0B 100% /dev
/dev/da0s1f 83G 14G 62G 18% /db
/dev/da0s1d 4.8G 4.4G 16M 100% /usr
/dev/da0s1e 4.8G 151M 4.3G 3% /var

gpart show

=> 63 262143882 da0 MBR (125G)
63 262143882 1 freebsd [active] (125G)

=> 0 262143882 da0s1 BSD (125G)
0 1024000 1 freebsd-ufs (500M)
1024000 8388608 2 freebsd-swap (4.0G)
9412608 10485760 4 freebsd-ufs (5.0G)
19898368 10485760 5 freebsd-ufs (5.0G)
30384128 179328319 6 freebsd-ufs (86G)
209712447 52431435 – free – (25G)

gpart list

Geom name: da0
state: OK
fwheads: 255
fwsectors: 63
last: 262143944
first: 63
entries: 4
scheme: MBR
Providers:
1. Name: da0s1
Mediasize: 134217667584 (125G)
Sectorsize: 512
Mode: r5w5e9
attrib: active
rawtype: 165
length: 134217667584
offset: 32256
type: freebsd
index: 1
end: 262143944
start: 63
Consumers:
1. Name: da0
Mediasize: 134217728000 (125G)
Sectorsize: 512
Mode: r5w5e14

Geom name: da0s1
state: OK
fwheads: 255
fwsectors: 63
last: 262143881
first: 0
entries: 8
scheme: BSD
Providers:
1. Name: da0s1a
Mediasize: 524288000 (500M)
Sectorsize: 512
Mode: r1w1e1
rawtype: 7
length: 524288000
offset: 0
type: freebsd-ufs
index: 1
end: 1023999
start: 0
2. Name: da0s1b
Mediasize: 4294967296 (4.0G)
Sectorsize: 512
Mode: r1w1e0
rawtype: 1
length: 4294967296
offset: 524288000
type: freebsd-swap
index: 2
end: 9412607
start: 1024000
3. Name: da0s1d
Mediasize: 5368709120 (5.0G)
Sectorsize: 512
Mode: r1w1e1
rawtype: 7
length: 5368709120
offset: 4819255296
type: freebsd-ufs
index: 4
end: 19898367
start: 9412608
4. Name: da0s1e
Mediasize: 5368709120 (5.0G)
Sectorsize: 512
Mode: r1w1e1
rawtype: 7
length: 5368709120
offset: 10187964416
type: freebsd-ufs
index: 5
end: 30384127
start: 19898368
5. Name: da0s1f
Mediasize: 91816099328 (86G)
Sectorsize: 512
Mode: r1w1e1
rawtype: 7
length: 91816099328
offset: 15556673536
type: freebsd-ufs
index: 6
end: 209712446
start: 30384128
Consumers:
1. Name: da0s1
Mediasize: 134217667584 (125G)
Sectorsize: 512
Mode: r5w5e9

gpart resize -i 4 da0s1

gpart: autofill: No space left on device

Thanks and regards,

Eneko

sIMON2014-01-22 22:59:34

Eneko ! 🙂

sadly you can only resize the last partition on the disk. By default this is /usr.

Bit this is clearly not the case with you.

so maybe it would be better to make new partition and rsync /usr to it and restart the server with this new (larger) partition as /usr.

S.