Re: Mounting free space

From: Matthew Seaman (m.seaman_at_infracaninophile.co.uk)
Date: 01/25/04

  • Next message: Nils Vogels: "Re: help O_o"
    Date: Sun, 25 Jan 2004 11:03:37 +0000
    To: Robert Fitzpatrick <robert@webtent.com>
    
    
    

    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>.
    >
    > 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
      b: 2097152 262144 swap
      c: 71681967 0 unused 0 0

    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
      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

    -- 
    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
    
    


    • application/pgp-signature attachment: stored

  • Next message: Nils Vogels: "Re: help O_o"

    Relevant Pages

    • Re: some issues about partitions and boot manager in dual boot cases with Windows
      ... freeBSD edition. ... The first is installing on a disk that is completely given to FreeBSD ... master, Windows 2000 or XP, and on the other, on the first partition, the ... It requires its own slice. ...
      (freebsd-questions)
    • Re: Put /usr on a different drive
      ... If you finally decide that you do need to add a disk - a very real ... The fdisk creates the slice table and writes sector 0. ... NOTE, although drives are numbered 0-nn, slices are numbered 1-4. ... In this I am presuming you want a single large partition. ...
      (freebsd-questions)
    • RE: problem while installing FreeBSD
      ... I deleted the partition and made 1.5Gb of DOS partition. ... disk, it boots to dos and when I reboot without removing disk, it says ... FreeBSD will only install into empty space ... It will not resize the NTFS slice for you. ...
      (freebsd-questions)
    • Re: I dont see anything to answer my q
      ... The ones that come with FreeBSD will handle fat and fat32 ... successfully a number of times is Partition Magic. ... What the BSD UNIX world calls a disk slice, ... clear while using the terms slice and primary partition. ...
      (freebsd-questions)
    • Re: Downloads
      ... There was one unused partition. ... (used unconsistently with the rest of FreeBSD). ... division of the disk is called a slice. ...
      (freebsd-questions)