summaryrefslogtreecommitdiff
path: root/sbin/newfs
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2010-03-20 14:19:39 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2010-03-20 14:19:39 +0000
commit25ee8c5b80130a3d64b99dd5922b960c4b20a196 (patch)
treed7252cbc16e16a13880fdecbf252512799155ea6 /sbin/newfs
parent4b1d2b368062898202f9ea453f96a62593f8ce19 (diff)
Make FFS2 the default format for file systems larger than INT_MAX
512-byte blocks. Better than just blowing up. Tweak man page to document this and clarify various things. Inspired by problems noted during an install by Harald Dunkel. Suggestions and man page corrections from otto@ and jmc@ ok beck@
Diffstat (limited to 'sbin/newfs')
-rw-r--r--sbin/newfs/newfs.822
-rw-r--r--sbin/newfs/newfs.c8
2 files changed, 19 insertions, 11 deletions
diff --git a/sbin/newfs/newfs.8 b/sbin/newfs/newfs.8
index 64d12baa0c1..4d1a30da68f 100644
--- a/sbin/newfs/newfs.8
+++ b/sbin/newfs/newfs.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: newfs.8,v 1.65 2008/08/03 21:43:19 otto Exp $
+.\" $OpenBSD: newfs.8,v 1.66 2010/03/20 14:19:38 krw Exp $
.\" $NetBSD: newfs.8,v 1.12 1995/03/18 14:58:41 cgd Exp $
.\"
.\" Copyright (c) 1983, 1987, 1991, 1993, 1994
@@ -30,7 +30,7 @@
.\"
.\" @(#)newfs.8 8.3 (Berkeley) 3/27/94
.\"
-.Dd $Mdocdate: August 3 2008 $
+.Dd $Mdocdate: March 20 2010 $
.Dt NEWFS 8
.Os
.Sh NAME
@@ -189,9 +189,10 @@ format file system.
This option is primarily used to build root file systems that can
be understood by older boot ROMs.
.It 1
-Fast File System (the default).
+Fast File System (FFS), the default for file systems smaller than 1 TB.
.It 2
-Enhanced Fast File System (FFS2).
+Enhanced Fast File System (FFS2), the default for file systems larger than
+1 TB.
.El
.It Fl o Ar optimization
.Ar space
@@ -213,7 +214,8 @@ With this option,
.Nm
will not print extraneous information like superblock backups.
.It Fl S Ar sector-size
-The size of a sector in bytes (almost never anything but 512).
+The size of a sector in bytes (almost always 512).
+A sector is the smallest addressable unit on the physical device.
Changing this is useful only when using
.Nm
to build a file system whose raw image will eventually be used on
@@ -226,10 +228,12 @@ to find the alternate superblocks if the standard superblock is
lost.
.It Fl s Ar size
The size of the file system in sectors.
-The maximum size of a Fast File
-System is 2,147,483,647 (2^31 \- 1) sectors, which is slightly less
-than 1TB, assuming a sector size of 512 bytes.
-FFS2 file systems can be as large as the maximum partition size supported.
+This value is multiplied by the number of 512\-byte blocks in a sector
+to yield the size of the file system in 512\-byte blocks, which is the value
+used by the kernel.
+The maximum size of a FFS file system is 2,147,483,647 (2^31 \- 1) of these
+512\-byte blocks, slightly less than 1 TB.
+FFS2 file systems can be as large as 64 PB.
Note however that for
.Nm mount_mfs
the practical limit is based on
diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c
index 8944333ac47..55d151e5915 100644
--- a/sbin/newfs/newfs.c
+++ b/sbin/newfs/newfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: newfs.c,v 1.81 2008/08/08 23:49:53 krw Exp $ */
+/* $OpenBSD: newfs.c,v 1.82 2010/03/20 14:19:38 krw Exp $ */
/* $NetBSD: newfs.c,v 1.20 1996/05/16 07:13:03 thorpej Exp $ */
/*
@@ -152,7 +152,7 @@ main(int argc, char *argv[])
struct stat st;
struct statfs *mp;
struct rlimit rl;
- int fsi = -1, fso, len, n, maxpartitions;
+ int fsi = -1, oflagset = 0, fso, len, n, maxpartitions;
char *cp = NULL, *s1, *s2, *special, *opstring;
#ifdef MFS
char mountfromname[BUFSIZ];
@@ -189,6 +189,7 @@ main(int argc, char *argv[])
Oflag = strtonum(optarg, 0, 2, &errstr);
if (errstr)
fatal("%s: invalid ffs version", optarg);
+ oflagset = 1;
break;
case 'S':
sectorsize = strtonum(optarg, 1, INT_MAX, &errstr);
@@ -428,12 +429,15 @@ havelabel:
if (fssize > DL_GETPSIZE(pp) && !mfs)
fatal("%s: maximum file system size on the `%c' partition is %lld",
argv[0], *cp, DL_GETPSIZE(pp));
+
if (sectorsize == 0) {
sectorsize = lp->d_secsize;
if (sectorsize <= 0)
fatal("%s: no default sector size", argv[0]);
}
fssize *= sectorsize / DEV_BSIZE;
+ if (oflagset == 0 && fssize >= INT_MAX)
+ Oflag = 2; /* FFS2 */
if (fsize == 0) {
fsize = DISKLABELV1_FFS_FSIZE(pp->p_fragblock);
if (fsize <= 0)