Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Aug 1998 11:07:18 +0930
From:      Greg Lehey <grog@lemis.com>
To:        Spidey <beaupran@JSP.UMontreal.CA>, "Jose M. Megias Sanchez" <jms@caja-granada.es>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: extend file system
Message-ID:  <19980811110718.L20188@freebie.lemis.com>
In-Reply-To: <Pine.BSF.3.96.980810070003.343A-100000@outpost.nada.org>; from Spidey on Mon, Aug 10, 1998 at 07:39:33AM -0400
References:  <01bdc436$5cc60000$00008282@jms> <Pine.BSF.3.96.980810070003.343A-100000@outpost.nada.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Monday, 10 August 1998 at  7:39:33 -0400, Spidey wrote:
> I really got to finish the paper I have to write on this...
>
> I wish that someone corrects me if I make any mistake. Don't start the
> procedure in a hurry. Maybe you should wait for a second advice, such as
> Julian Elisher or Greg Lehey...

Well, since you invoked my name...

> On Mon, 10 Aug 1998, Jose M. Megias Sanchez wrote:
>
>> 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.
>
> Indeed. It would be a quite great adding, if you ask me...

One of the things we're planning for Vinum is an extendible UFS.  This
won't help you here, unfortunately.  The real problem is that UFS
expects a contiguous disk partition.  Vinum gives it that illusion,
but that's about the only way--that's why UFS is currently
non-extensible.

>> 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 really don't think it is a solution. I did the thing. And it was
> freespace that I was adding at the end of my /usr... All the stuff is on
> disklabel.
>
> 1- Make sure your backups are OK... I don't know DUMP, but I know that it
> is a risky procedure.

I personally don't use dump for a number of reasons.  I'd personally
use tar.  Back up everything, including the root file system.  If you
shoot yourself in the foot, you could end up installing from scratch.

> 2- Check disklabel -r /dev/sd0s2. (you have 2.2.5R or lower uh?, or else
> your sd0a would be sd0s2a, I think...:). With disklabel, you'll see the
> size and offset of your partitions.
>
> One problem is that your /var is after your /usr, which means we got to
> make some room, which implies that you BACKUP /var, because it's gonna be
> *deleted*.
>
> 'En resume': /var, /usr and /home will be deleted. Back them up. Double
> check to see if you have the necessary software to restore these on
> **other** partitions than these 3!!!
>
> Then what you will do is, in single-user (not necessarly needed, but take
> no chaces...), edit the disklabel with:
>
> disklabel -r -e /dev/sd0s2

> You may need to mount certain filesystems, 'cause disklabel uses a text
> editor (vi generally), and files in /tmp... In your case this shouldn't
> be a problem, 'cause /tmp is on a seperate partition. However, *** make
> sure you have vi under your path!!! ****

This contradicts what you said below.  I agree with what you said
below, not with this.

It's a problem to run an editor in single-user mode.  You also have an
alternative.  Do this any time (it doesn't change the disks).

  # disklabel -r /dev/sd0s2 >myoldlabel
  # vi myoldlabel
  # mv myoldlabel mynewlabel 

Make the changes, and make sure that mynewlabel is on the root file
system.  Make *very* sure you don't change the definition of the root
file system.

> There is the 'fun part'... You edit the sizes and offsets as your
> convenience. As I understood, you don't need to change the /var size, so
> just add the size you're adding to /usr to the *offset* of /var.
>
> You may also like to put /var *before* /usr, if you ever need (plan?) to
> do this again, but this may imply things that I am noot aware of (fstab
> changes etc...)
>
> You'll also have to add the adding size to the offset of /home, and
> substract it from the size of /home (to your calculators!!!! we don't want
> any mistake here!!!)

When you're in single user mode, do

  # disklabel -R -r sd0s2 mynewlabel

> Then:
>
> newfs /dev/sd0s2f
> newfs /dev/sd0s2g
> newfs /dev/sd0s2h
>
> This should give you the 3 new filesystems, empty, ready to be restored!
>
> There is only oone thing I would be worried about. The -11000 blocks
> "available"... I'm not sure as of how to handle this...

That's not a problem.  The files are still there.  The 100% mark
represents the number of blocks available to non-root users.

> So, briefly this goes on like:
>
> 1- Backup /var /usr and /home.
> 2- Install necessary software on a 'neutral zone', let's say /.
>    a- vi or another editor that will be in $EDITOR
>    b- disklabel, newfs (I think it's already on /bin, but...)
>    c- you might also like a fixit and install floppies, if something goes
> wrong.
> 3- Go single-user, and mount necessary partitions. I don't think it would
> be a very good idea to mount /var, /home or /usr... Try to avoid it.

Avoid it at all costs.

> 4- disklabel -r -e /dev/sd0s2

What editor are you going to use?  If it's vi, you'll need
/usr/lib/libc.so.<mumble>.  But /usr isn't mounted.  What you can do
here is a nasty trick:

  # cp /usr/lib/libc.so* /tmp
  # umount /usr
  # mv /tmp /usr/lib/libc.so*

Huh?  Yes, it works.  You'll copy them to the root file system.  This
assumes, of course, that your /tmp is on the root file system.
Otherwise find somewhere else to put them while you umount /usr.

> 5- Edit to it your needs.
>    [optionnal]- Swap /var and /usr
> 6- Wish.
> 7- newfs /home , /var and /usr (don't use this syntax! :)
> 8- Restore the partitions.
> 9- Modify /etc/fstab if you swap /var and /usr.
> 10- Be happy.
> 11- Quickly fill up /usr
> 12- 'GOTO 1-' :)
>
> Give me feedback!

That's an important one.

Greg
--
See complete headers for address and phone numbers
finger grog@lemis.com for PGP public key

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?19980811110718.L20188>