Are quotas possbile on md filesystems?
Bob Johnson
bob89 at bobj.org
Fri Mar 4 19:33:48 PST 2005
On Friday 04 March 2005 05:56 pm, Bob Johnson wrote:
> 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:
>
[patch omitted]
>
> >So, what IS the correct way to create and use file-based file
> >systems?
>
The patch I provided defaulted to NOT formatting the
filesystem when used with the -F option. This is the
opposite of the normal behavior, creating the risk of
a /etc/fstab that assumes that the filesystem will not
be formatted being used with a new release that will format
it by default, thus destroying the filesystem. That
would be very very bad.
So here is a new patch that modifies mdmfs / mount_mfs
to behave as it does now, except that it will not format
the filesystem before mounting if you supply the -A
(mount "as-is") option. Thus, to use /etc/fstab to mount
a file-backed filesystem without reformatting the filesystem,
put something like this in /etc/fstab
/dev/md3 /mnt mfs rw,-A,-F /home/bob/mdfile,noauto 0 0
So, here is a patch to add this to the original mdmfs,
as well as a patch to the man page.
=========
--- mdmfs.c 2005/03/05 01:45:00 1.1
+++ mdmfs.c 2005/03/05 03:09:17
@@ -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/05 03:09:10 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,8 +121,11 @@
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)
+ "Aa:b:Cc:Dd:e:F:f:hi:LlMm:Nn:O:o:p:Ss:Uv:w:X")) != -1)
switch (ch) {
+ case 'A':
+ want_newfs=false;
+ break;
case 'a':
argappend(&newfs_arg, "-a %s", optarg);
break;
@@ -268,7 +273,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);
@@ -665,13 +671,13 @@
name = "mdmfs";
if (!compat)
fprintf(stderr,
-"usage: %s [-DLlMNSUX] [-a maxcontig [-b block-size] [-c cylinders]\n"
+"usage: %s [-ADLlMNSUX] [-a maxcontig [-b block-size] [-c cylinders]\n"
"\t[-d rotdelay] [-e maxbpg] [-F file] [-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);
fprintf(stderr,
-"usage: %s -C [-lNU] [-a maxcontig] [-b block-size] [-c cylinders]\n"
+"usage: %s -C [-AlNU] [-a maxcontig] [-b block-size] [-c cylinders]\n"
"\t[-d rotdelay] [-e maxbpg] [-F file] [-f frag-size] [-i bytes]\n"
"\t[-m percent-free] [-n rotational-positions] [-O optimization]\n"
"\t[-o mount-options] [-s size] md-device mount-point\n", name);
=================
--- mdmfs.8 2005/03/05 01:46:09 1.1
+++ mdmfs.8 2005/03/05 03:08: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.3 2005/03/05 03:08:21 bobj Exp bobj $
.\"
.Dd February 26, 2004
.Dt MDMFS 8
@@ -36,7 +37,7 @@
driver
.Sh SYNOPSIS
.Nm
-.Op Fl DLlMNSUX
+.Op Fl ADLlMNSUX
.Op Fl a Ar maxcontig
.Op Fl b Ar block-size
.Op Fl c Ar cylinders
@@ -57,7 +58,7 @@
.Ar mount-point
.Nm
.Fl C
-.Op Fl lNU
+.Op Fl AlNUu
.Op Fl a Ar maxcontig
.Op Fl b Ar block-size
.Op Fl c Ar cylinders
@@ -122,6 +123,12 @@
.Xr mount_mfs 8
for the same thing.
.Bl -tag -width indent
+.It Fl A
+Mount filesystem as-is. Do not use newfs to format the
+filesystem before mounting. This option only makes sense
+when used with the
+.Fl F
+option.
.It Fl a Ar maxcontig
Specify the maximum number of contiguous blocks that will be laid
out before forcing a rotational delay
@@ -342,7 +349,11 @@
.Xr getprogname 3 ) .
In this mode, only the options which would be accepted by
.Xr mount_mfs 8
-are valid.
+are valid (with the addition of
+.Fl A
+which will be needed in
+.Pa /etc/fstab
+for some uses).
Furthermore, the following behavior, as done by
.Xr mount_mfs 8 ,
is duplicated:
============
Hope that's useful.
- Bob
More information about the freebsd-questions
mailing list