Are quotas possbile on md filesystems?
Bob Johnson
bob89 at eng.ufl.edu
Fri Mar 4 14:56:26 PST 2005
Michael R. Wayne wrote:
>On Thu, 03 Mar 2005 16:53:19 -0500, Michael R. Wayne <wayne at staff.msen.com> wrote:
>
>
>>Is it possible to use quotas on file-backed md filesystems
>>on 5.3? I was guessing that a line in fstab like:
>>
>>
>
>OK, I see the error in my ways. My goal is to use file-based
>filesystems that are preserved acoss boots. vnconfig says to
>use mdconfig, the handbook suggests that the method I used is
>correct. But everything is cleared on reboot, which is not
>what I was looking for.
>
>
>
It appears that it always formats a new filesystem because that's what
mount_mfs did, and mdmfs is a replacement for mount_mfs. I agree
with you that that should not be the default behavior for a file-backed
(vnode) disk, so I wrote a little patch to fix that:
===========
--- mdmfs.c 2005/03/04 21:09:50 1.1
+++ mdmfs.c 2005/03/04 22:04:54
@@ -32,6 +32,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/sbin/mdmfs/mdmfs.c,v 1.20 2004/05/17 07:07:20
ru Exp $");
+/*$Id: mdmfs.c,v 1.5 2005/03/04 22:04:47 bobj Exp bobj $*/
#include <sys/param.h>
#include <sys/mdioctl.h>
@@ -89,7 +90,7 @@
*mount_arg;
enum md_types mdtype; /* The type of our memory disk. */
bool have_mdtype;
- bool detach, softdep, autounit;
+ bool detach, softdep, autounit, want_newfs;
char *mtpoint, *unitstr;
char *p;
int ch;
@@ -100,6 +101,7 @@
detach = true;
softdep = true;
autounit = false;
+ want_newfs = true;
have_mdtype = false;
mdname = MD_NAME;
mdnamelen = strlen(mdname);
@@ -119,10 +121,10 @@
compat = true;
while ((ch = getopt(argc, argv,
- "a:b:Cc:Dd:e:F:f:hi:LlMm:Nn:O:o:p:Ss:t:Uv:w:X")) != -1)
+ "a:b:Cc:Dd:e:F:f:hi:LlMm:Nn:O:o:p:Ss:Uuv:w:X")) != -1)
switch (ch) {
case 'a':
- argappend(&newfs_arg, "-a %s", optarg);
+ argappend(&newfs_arg, "-a %s", optarg);
break;
case 'b':
argappend(&newfs_arg, "-b %s", optarg);
@@ -151,6 +153,7 @@
usage();
mdtype = MD_VNODE;
have_mdtype = true;
+ want_newfs = false;
argappend(&mdconfig_arg, "-f %s", optarg);
break;
case 'f':
@@ -213,6 +216,9 @@
case 'U':
softdep = true;
break;
+ case 'u':
+ want_newfs = true;
+ break;
case 'v':
argappend(&newfs_arg, "-O %s", optarg);
break;
@@ -268,7 +274,8 @@
do_mdconfig_attach_au(mdconfig_arg, mdtype);
else
do_mdconfig_attach(mdconfig_arg, mdtype);
- do_newfs(newfs_arg);
+ if (want_newfs)
+ do_newfs(newfs_arg);
do_mount(mount_arg, mtpoint);
do_mtptsetup(mtpoint, &mi);
@@ -666,7 +673,7 @@
if (!compat)
fprintf(stderr,
"usage: %s [-DLlMNSUX] [-a maxcontig [-b block-size] [-c cylinders]\n"
-"\t[-d rotdelay] [-e maxbpg] [-F file] [-f frag-size] [-i bytes]\n"
+"\t[-d rotdelay] [-e maxbpg] [-F file [-u]] [-f frag-size] [-i bytes]\n"
"\t[-m percent-free] [-n rotational-positions] [-O optimization]\n"
"\t[-o mount-options] [-p permissions] [-s size] [-w user:group]\n"
"\tmd-device mount-point\n", name);
================
>So, what IS the correct way to create and use file-based file
>systems?
>
>
>
Apply the patch above, then something in /etc/fstab like the following will
not reformat the filesystem:
/dev/md3 /mnt mfs rw,-F/vnodes/fileimage,noauto 0 0
If you want it to reformat the filesystem as the old mount_mfs did
(or at least, as the old man pages say it did), then use something like
/dev/md3 /mnt mfs rw,-F/vnodes/fileimage,-u,noauto 0 0
Note that -u MUST follow -F on the command line to have any effect.
This breaks compatibility with the old mount_newfs. I guess I should
have used to opposite sense for "-u". Which still would have broken
compatibility, but not as much. This means that if this patch ever
makes it into a FreeBSD distribution, it is likely to default to formatting
rather than not formatting. This will lead to a nasty surprise if you
aren't expecting it. In other words, don't use this patch unless you
are desperately seeking a solution to a problem that makes it worth
the risk. Don't blame me when some future change in behavior
deletes your important filesystem.
>And, can I put quotas on them?
>
>
Don't know, but probably.
If applying a patch is a mystery to you, try (assuming you have the
full source installed) something that approximates this:
# cd /usr/src/sbin/mdmfs
# patch < /path/to/patch.file
# make
# make install
If you want to be thorough, apply the following patch to fix the
man page as well:
===========
--- mdmfs.8 2005/03/04 22:06:21 1.1
+++ mdmfs.8 2005/03/04 22:38:38
@@ -24,6 +24,7 @@
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/sbin/mdmfs/mdmfs.8,v 1.20 2004/05/17 08:35:41 ru Exp $
+.\" $Id: mdmfs.8,v 1.4 2005/03/04 22:17:07 bobj Exp $
.\"
.Dd February 26, 2004
.Dt MDMFS 8
@@ -36,13 +37,13 @@
driver
.Sh SYNOPSIS
.Nm
-.Op Fl DLlMNSUX
+.Op Fl DLlMNSUuX
.Op Fl a Ar maxcontig
.Op Fl b Ar block-size
.Op Fl c Ar cylinders
.Op Fl d Ar rotdelay
.Op Fl e Ar maxbpg
-.Op Fl F Ar file
+.Op Fl F Ar file
.Op Fl f Ar frag-size
.Op Fl i Ar bytes
.Op Fl m Ar percent-free
@@ -57,7 +58,7 @@
.Ar mount-point
.Nm
.Fl C
-.Op Fl lNU
+.Op Fl lNUu
.Op Fl a Ar maxcontig
.Op Fl b Ar block-size
.Op Fl c Ar cylinders
@@ -238,6 +239,15 @@
It is only really useful to negate the
.Fl S
flag, should such a need occur.
+.It Fl u
+Install new UFS filesystem. This is only meaningful if
+.Fl F
+has already been specified, and is always done for swap-backed
+.Pq Dv MD_SWAP
+or
+.Xr malloc 9
+.Pq Dv MD_MALLOC
+backed disks.
.It Fl v Ar version
Specify the UFS version number for use on the file system; it may be
either
===========
- Bob
Replies to my @eng.ufl.edu address will not be read on weekends.
For that, send to @bobj.org or @wb4jcm.org
More information about the freebsd-questions
mailing list