From owner-freebsd-hackers Fri May 10 14:59:03 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id OAA28895 for hackers-outgoing; Fri, 10 May 1996 14:59:03 -0700 (PDT) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.211]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id OAA28883 for ; Fri, 10 May 1996 14:58:59 -0700 (PDT) Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id OAA02890; Fri, 10 May 1996 14:57:57 -0700 From: Terry Lambert Message-Id: <199605102157.OAA02890@phaeton.artisoft.com> Subject: Re: Allocation Unit and File System in General To: pchhibbe@attila.stevens-tech.edu (Parag Chhibber) Date: Fri, 10 May 1996 14:57:56 -0700 (MST) Cc: freebsd-hackers@freebsd.org In-Reply-To: <2.2.32.19960510191750.006baf38@attila.stevens-tech.edu> from "Parag Chhibber" at May 10, 96 03:17:50 pm X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > I was wondering what type of file system is used by FreeBSD, and more > importantly, what are the size of the allocation units? > > In DOS (which sucks) the file system supports names of 8+3 with allocation > unit sizes differing depending on the partition size as follows: > > Hard Disk Allocation Unit > Minimum Size > > 0 MB 512 bytes > 32 MB 1024 bytes (1 KB) > 64 MB 2048 bytes (2 KB) > 128 MB 4096 bytes (4 KB) > 256 MB 8192 bytes (8 KB) > 512 MB 16384 bytes (16 KB) > 1024 MB 32768 bytes (32 KB) > 2048 MB 65536 bytes (64 KB) > and so on... > > This means that if you have a 1.2 GB drive, in DOS, if you leave it as 1 > partition, your allocation unit is 32 KB. If you split the drive into 3 > partitions, your allocation untis is 8 KB. > > Basically your allocation unit is the minimum multiple that your actual file > size must take up. (For example, with 32 KB allocation units, files less > then 32 KB take up 32 KB, and files greater then that take up multiples of > 32 KB rounding up.) > > My question is how are allocation units handled in FreeBSD, because with > disk striping and such, disk sizes can become pretty big. If you use the default FFS, then the FS allocation unit is called a "frag". The minimum size of a "frag" depends on the FS block size, set during the "newfs" (the equivalent of a high level format). For a 4k block size, the frag size is 512b (one disk block). For an 8k block size, the frag size is 1024b (1k). Files are stored in (file_size div fs_block_size) fs blocks followed by (((file_size mod fs_block_size) + fs_block_size - 1) / fs_frag_size) frags. The frag size can be made smaller, but by default it will be the max of 512b and fs_block_size / 8 (since an unsigned char bitmap is used to index frags). This means that for a totally random distribution of file sizes, on an 8k FS block size FS, 512b per file are wasted. No matter what size the disk is. So we have: Hard Disk ----- average wasted space per file ----- Minimum Size DOS FFS 4k FFS 8k 0 MB 256b 256b 512b 32 MB 512b 256b 512b 64 MB 1k 256b 512b 128 MB 2k 256b 512b 256 MB 4k 256b 512b 512 MB 8k 256b 512b 1024 MB 16k 256b 512b 2048 MB 32k 256b 512b 4096 MB impossible 256b 512b 8192 MB impossible 256b 512b 16384 MB impossible 256b 512b 32768 MB impossible 256b 512b 65536 MB impossible 256b 512b ... 1 TB impossible 256b 512b 2 TB impossible 256b 512b 4 TB impossible impossible 512b and so on... Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.