# problem of expanding /usr



## nicholas1918717 (Jun 4, 2009)

hi,

my FreeBSD box is build on VMware Fusion, the /usr dir seems not enough space to use, so i have increased the cap of HD for BSD in VM. i just know to use fdisk in sysinstall to add an additional HD, however, i only want to expand the cap of /usr. howto? any ideas?

Thanks


----------



## vivek (Jun 4, 2009)

Do you want to resize /usr? If so use growfs(8). However chances  are high that you do not prepare it for such option in advance. We can provide more info if you run df -h. 

Another option is  some parts some parts of /usr elswhere and symlink back to the normal position in /usr. In particular the /usr/ports and /usr/src trees.


----------



## SirDice (Jun 4, 2009)

I use separate partitions for /usr/ports/, /usr/src/ and /usr/obj.

Another one I quite frequently set aside is /usr/home.


----------



## indexofire (Jun 4, 2009)

I don't know how to enlarge the hd in vm so that I usually add a another hd in freebsd which will be ad1 as default. then format the new disk.

```
# fidsk -BIq /dev/ad1
# bsdlabel -w -B /dev/ad1s1 auto
# newfs /dev/ad1s1a
```
boot to single user

```
# reboot
# boot -s
# fsck
# mount -a -t ufs
# mount /dev/ad1s1a /mnt
# cd /mnt
# dump -0af - /usr| restore rf -
# umount /mnt
```
set the fstab, if the /usr slice is ad0s1e

```
# sed -I .bak 's/ad0s1e/ad1s1a/' /etc/fstab
# reboot
# tail -f /var/log/messeges
# rm /etc/fstab.bak
# rm /var/restoresymtable
```


----------



## nicholas1918717 (Jun 5, 2009)

hi,

First of all, thanks all of u with kindly help, fortunately the problem have been solved.
i spend a whole morning to google and go through the man pages of fdisk, bsdlabel and growfs. Following is the procedure step by step:

1) reboot system then go to single user mode.
2) use fdisk to enlarge the slice which i want to expand.
3) exit let the system boot again.
4) use bsdlabel to edit which partition size (i just use one and whole partition  for /usr) i want to expand.
5) force umount /usr.
6) use growfs to enlarge /usr.
7) run fsck.
8) mount /usr again. Bingo!

Its just an experiment for my BSD box, of course, if you are in production environment, backup is necessary.

Thanks


----------



## SirDice (Jun 5, 2009)

nicholas1918717 said:
			
		

> 5) force umount /usr.


Drop back to single user mode then you don't have to force it.

`# init 1`


----------

