Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 Jan 2004 11:03:37 +0000
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        Robert Fitzpatrick <robert@webtent.com>
Cc:        FreeBSD <freebsd-questions@freebsd.org>
Subject:   Re: Mounting free space
Message-ID:  <20040125110337.GA5755@happy-idiot-talk.infracaninophile.co.uk>
In-Reply-To: <1074986019.4114.53.camel@columbus>
References:  <1074986019.4114.53.camel@columbus>

next in thread | previous in thread | raw e-mail | index | archive | help

--7JfCtLOvnd9MIVvH
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Jan 24, 2004 at 06:13:40PM -0500, Robert Fitzpatrick wrote:
> On FreeBSD 5.2 I have a RAID-5 host drive with 100GB of free space. What
> can I use to mount this free space? I tried the Disk Label Editor in
> /stand/sysinstall, but it does not seem to hold my settings when
> creating and the existing mount points show up as <none>.
>=20
> Can someone give me some guidance on doing this?

Sure.  In order for that free space to be useful to you, you need to
build a filesystem on it.  There's a hierarchy of data structures that
you have to create in order to do that.

Let's start by assuming your raid device is called aac0 -- obviously
substitute the correct device name and number for your system.

The first step you need to do is create a slice table on the drive,
using the fdisk(8) command.  The 'slice' structure is common between
almost all OSes you could run on i386 hardware, except that other OSes
talk (confusingly) about "partitions".  We'll cover partitions (in the
FreeBSD sense) a bit later on.  Slices are used to select chunks of
the drive for use with whatever OSes you require.  Even if you're
going to use the whole disk for one OS, you should still install a
slice table -- if this drive is initially completely empty, and you
want to dedicate all of it to FreeBSD, then you can simply run:

    # fdisk -I -v aac0

This will create a single slice covering the whole disk labelled as
'FreeBSD/NetBSD/386BSD', which corresponds to the device node

    /dev/aac0s1

If you need to split the space up between different OSes or the drive
is already sliced but you need to tell the system to dedicate one
slice to FreeBSD, then you can do all that using fdisk(8) -- although
some care is necessary.  Typing the wrong thing can trash any previous
contents of the drive.

Having sliced, the next step is to partition.  Partitions (in the
FreeBSD sense) are the FreeBSD specific subdivisions of slices.
Generally each partition will correspond to a file system but they can
also be used as raw space eg. for swap.  The partition table in each
slice has space for 8 entries a -- h, but some of those entries
conventionally have special meaning.  The 'a' partition is assumed to
be a root partition, containing a kernel image and all of the other
gubbins necessary to boot the system.  'b' partitions are used as swap
space.  The 'c' partition is always set to cover the whole slice, but
is not used for normal disk io access (partitions can overlap,
although apart from this special case, it's not generally a good idea
to do so).  Why do we need a special 'c' device covering the whole
slice, when we've already got a device entry /dev/aac0s1 that does
that?  The answer is historically the 'c' partition used to be the
only way to do that whole slice access, and there is still a great
deal of software around that still works that way.  Partitions d -- h
are general purpose.

Lets assume you want to create one single partition over the whole
slice.  We'll call this partition 'h', corresponding to the device
node /dev/aac0s1h.

The command to label the slice with a partition table is bsdlabel(8)
in FreeBSD 5.x -- it used to be known as disklabel(8) in FreeBSD 4.x.
To create an initial  disk label use:

    # bsdlabel -w aac0s1

You can see the partition layout that was created by:

    # bsdlabel aac0s1

which will look something like:

8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  a:   262144        0    4.2BSD     1024  8192    16 =20
  b:  2097152   262144      swap                      =20
  c: 71681967        0    unused        0     0       =20

although the numbers (particularly the 'size' column) will be different.

You need to edit that, using the command:

    # bsdlabel -e aac0s1

which will put you into the editor specified in your $EDITOR
environment variable (defaults to: vi(1)) with that text in there.
Edit the text so that it looks like:

8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  c: 71681967        0    unused        0     0       =20
  h: 71681967        0    4.2BSD     1024  8192    16

[ie. copy the 'size' value that your system automatically puts into
the c: partition entry]

Save, and quit out of the editor.  Your modified partition table will
be written to the disk.  [Nb.  the fsize, bsize and bps/cpg values are
all to do with the next stage: creating a filesystem.  The values
given are the defaults, suitable for general purpose use. Tweaking
that sort of thing is definitely advanced usage]

Step 3 is to create a filesystem on the partition using the newfs(8)
command.  There are any number of options you can tweak and stuff you
can fiddle with in doing that, but as a neophyte your best bet is to
let the system use the default values as it will.  The only exceptions
to that are the -U option (turn on soft-updates: you definitely want
that) and the -m option (reserved free space: usually a reserve of 8%
is kept, but for a multigigabyte filesystem, that's excessive. 1% will
be ample).  Use this command:

    # newfs -U -m 1 /dev/aac0s1h

That may take a little time to complete on a large partition.

Nearly there: Step 4 is the final step.  Mounting the newly built
partition.  Let's mount the space on /data -- we can do that as a
one-off using the command:

    # mount -t ufs -o rw /dev/aac0s1h /data

but generally you will want that partition to be mounted at boot-time.
Edit /etc/fstab to achieve that -- see mount(8) and fstab(5) for more
details, but adding a line:

    /dev/aac0s1h    /data    ufs   rw  2  2

should be sufficient.  With that in /etc/fstab, you can now mount the
partition simply by:

    # mount /data

Et voila.

	Cheers,

	Matthew

--=20
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

--7JfCtLOvnd9MIVvH
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD8DBQFAE6KJdtESqEQa7a0RAmCcAKCBYjaDAJWrFbtS3gjI9Ud+7ogIyQCdGHPJ
aNFlkPHcV0RGxWUEEkkiceU=
=kmZi
-----END PGP SIGNATURE-----

--7JfCtLOvnd9MIVvH--



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