From owner-freebsd-questions@FreeBSD.ORG Sun Jan 25 03:03:50 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7538416A4CE for ; Sun, 25 Jan 2004 03:03:50 -0800 (PST) Received: from smtp.infracaninophile.co.uk (happy-idiot-talk.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 96B1A43D1D for ; Sun, 25 Jan 2004 03:03:44 -0800 (PST) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost.infracaninophile.co.uk [IPv6:::1])i0PB3cjc009786 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 25 Jan 2004 11:03:38 GMT (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost)id i0PB3bZG009785; Sun, 25 Jan 2004 11:03:38 GMT (envelope-from matthew) Date: Sun, 25 Jan 2004 11:03:37 +0000 From: Matthew Seaman To: Robert Fitzpatrick Message-ID: <20040125110337.GA5755@happy-idiot-talk.infracaninophile.co.uk> Mail-Followup-To: Matthew Seaman , Robert Fitzpatrick , FreeBSD References: <1074986019.4114.53.camel@columbus> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="7JfCtLOvnd9MIVvH" Content-Disposition: inline In-Reply-To: <1074986019.4114.53.camel@columbus> User-Agent: Mutt/1.5.5.1i X-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on happy-idiot-talk.infracaninophile.co.uk cc: FreeBSD Subject: Re: Mounting free space X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Jan 2004 11:03:50 -0000 --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 . >=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--