Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 Aug 1998 08:29:56 -0400 (EDT)
From:      CyberPeasant <djv@bedford.net>
To:        jms@caja-granada.es (Jose M. Megias Sanchez)
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: extend file system
Message-ID:  <199808101229.IAA09487@lucy.bedford.net>
In-Reply-To: <01bdc436$5cc60000$00008282@jms> from "Jose M. Megias Sanchez" at "Aug 10, 98 10:10:40 am"

next in thread | previous in thread | raw e-mail | index | archive | help
Jose M. Megias Sanchez wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hello, I have a little problem. My fylesystem /usr is full and I would like
> to extend its size, in other unix (hp-ux) its too easy with the command
> extendfs but FreeBSD don't has it.
> 
> I have the following fylesystems:
> mulhacen2# df -k
> Filesystem  1K-blocks     Used    Avail Capacity  Mounted on
> /dev/sd0a      297423    18048   255582     7%    /
> /dev/sd0s2h   2244926       17  2065315     0%    /home
> /dev/sd0s2e    248175     3362   224959     1%    /tmp
> /dev/sd0s2f    496367   467706   -11048   102%    /usr
> /dev/sd0s2g    695311     2094   637593     0%    /var
> procfs              4        4        0   100%    /proc
> /dev/wcd0c     600108   600108        0   100%    /dist
> 
>     I would like extend /usr with 100 Mb catching the space from /home (by
> the moment not used). I have a backup of all fylesystems obtained with DUMP,
> How can I do now to extend /usr?, newfs -s maybe?. Regards.

I'll assume that the partitions are laid out in alphabetical order
on the disk, and that newfs will DESTROY the contents of any partition
on which it is run.

Currently:

		size in K	offset in blocks

	/usr	248175		X
	/var	695311		X + 2*(248175)
	/home  2244926		X + 2*(248175 + 695311)

Later:
	/usr	348175		X
	/var	695311		X + 2*(248175) + 200000
	/home  2144926		X + 2*(248175 + 695311) + 200000

/var is saved somewhere. /home is empty. We shall "slide" var and
home 200K blocks down the disk, shrinking home (sd0s2h) and expanding
sd0s2f (usr).

Go to single user mode. (kill -TERM 1)

Umount /home. Redefine home (sd0s2h) to have a size 200K blocks
smaller than at present, and an offset 200K farther into the disk.
(use disklabel -r -e sd0s2 ).

Newfs the new sd0s2h  partition, and mount it on /home

Copy the current /usr partiton to this new /home. (build it as the whole
tree, not a tar archive or something else.

	(cd /usr; tar cpf - . )|(cd /home; tar xvpf -)

Redefine (disklabel -r -e sd0s2 ) the /var (sd0s2g) partition to have an
offset 200K blocks larger than at present.

newfs the new /var partition, and restore it from wherever it is stored.
(I'd just make a tar file on / or somewhere on disk-- you've got plenty
of space on /. (Don't use /tmp -- maybe you'll get a reboot by mistake).
Remount the /var partition. (We're done with it).

umount /usr
umount /home

mount the home (sd0s2h) partiton temporarily on /usr, if you need
man pages, or other stuff on /usr. (vi from /usr/bin? who knows?)
(mount /dev/sd0s2h /usr)

disklabel the usr (sd0s2f) partition, adding 200K blocks to the size.
Leave offset alone.

newfs the new sd0s2f partition. Mount it on /mnt  Restore the files:
(assuming that the home partition is on /usr)

	(cd /usr; tar cpf - . )|(cd /mnt; tar xvpf -)

umount /dev/sd0s2h
umount /mnt   
mount /dev/sd0s2f /usr
mount /home	(maybe newfs it later -- quicker than rm -r *)

return to multiuser mode. Check operation. Then clean out /home.

Check my work before preceding. Some people say I'm not "definitive"
enough.  You may wish to replace "200000" and "200K" with a number
of blocks that is an integer multiple of cylinders.

Keep those backups -- it's too easy to ruin a disk layout with disklabel.
Watch disklabel messages carefully.

Dave
-- 
         Bedford County, PA -- 47,000 polite, friendly Appalachians,
                4,000 of whom have concealed-carry permits.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199808101229.IAA09487>