From owner-freebsd-current@FreeBSD.ORG Tue Nov 30 12:06:46 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AA93F16A4CE for ; Tue, 30 Nov 2004 12:06:46 +0000 (GMT) Received: from ei.bzerk.org (ei.xs4all.nl [213.84.67.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 968C343D2F for ; Tue, 30 Nov 2004 12:06:45 +0000 (GMT) (envelope-from mail25@bzerk.org) Received: from ei.bzerk.org (BOFH@localhost [127.0.0.1]) by ei.bzerk.org (8.13.1/8.13.1) with ESMTP id iAUC8uAp045041; Tue, 30 Nov 2004 13:08:56 +0100 (CET) (envelope-from mail25@bzerk.org) Received: (from bulk@localhost) by ei.bzerk.org (8.13.1/8.13.1/Submit) id iAUC8uer045040; Tue, 30 Nov 2004 13:08:56 +0100 (CET) (envelope-from mail25@bzerk.org) Date: Tue, 30 Nov 2004 13:08:56 +0100 From: Ruben de Groot To: Michal Mertl Message-ID: <20041130120856.GA44543@ei.bzerk.org> Mail-Followup-To: Ruben de Groot , Michal Mertl , freebsd-current@freebsd.org References: <41AC57BF.6060604@traveller.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <41AC57BF.6060604@traveller.cz> User-Agent: Mutt/1.4.2.1i X-Spam-Status: No, score=-1.7 required=5.0 tests=ALL_TRUSTED, FROM_ENDS_IN_NUMS,J_CHICKENPOX_64 autolearn=failed version=3.0.0 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on ei.bzerk.org cc: freebsd-current@freebsd.org Subject: Re: enhacement to mdmfs X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Nov 2004 12:06:46 -0000 On Tue, Nov 30, 2004 at 12:21:35PM +0100, Michal Mertl typed: > Hello, > > I've recently shot my foot with mdmfs. Of course it was a pilot error but > the funcioanility I was looking for might be usefull. > > I want to mount vnode-backed md(4) on boot without formatting it (e.g. for > a jail). Is it possible with current boot scripts? > > I wrote a simple patch to mdmfs so such md disk can be put in /etc/fstab. > It adds '-K' option do mdmfs(8) to Keep contents. The line to attach such > disk in fstab looks like this: > > md /jail mfs rw,-K,-F=/var/jailfile 0 0 > > Comments welcome. If people find it usefull I'd like to have it commited. I > can fill the PR with enhancement request. I filed a PR about this allready in October 2003: http://www.freebsd.org/cgi/query-pr.cgi?pr=57641 Ruben > Patch attached. > > -- > Michal Mertl > > > > Index: mdmfs.8 > =================================================================== > RCS file: /home/fcvs/cvs/src/sbin/mdmfs/mdmfs.8,v > retrieving revision 1.20 > diff -u -3 -r1.20 mdmfs.8 > --- mdmfs.8 17 May 2004 08:35:41 -0000 1.20 > +++ mdmfs.8 30 Nov 2004 10:56:22 -0000 > @@ -36,7 +36,7 @@ > driver > .Sh SYNOPSIS > .Nm > -.Op Fl DLlMNSUX > +.Op Fl DKLlMNSUX > .Op Fl a Ar maxcontig > .Op Fl b Ar block-size > .Op Fl c Ar cylinders > @@ -57,7 +57,7 @@ > .Ar mount-point > .Nm > .Fl C > -.Op Fl lNU > +.Op Fl KlNU > .Op Fl a Ar maxcontig > .Op Fl b Ar block-size > .Op Fl c Ar cylinders > @@ -162,6 +162,12 @@ > The fragment size of the file system in bytes. > .It Fl i Ar bytes > Number of bytes per inode. > +.It Fl K > +Preserve contents of vnode-backed > +.Pq Dv MD_VNODE > +memory disk. > +Must be used in conjunction with > +.Fl F . > .It Fl l > Enable multilabel MAC on the new file system. > .It Fl L > Index: mdmfs.c > =================================================================== > RCS file: /home/fcvs/cvs/src/sbin/mdmfs/mdmfs.c,v > retrieving revision 1.20 > diff -u -3 -r1.20 mdmfs.c > --- mdmfs.c 17 May 2004 07:07:20 -0000 1.20 > +++ mdmfs.c 30 Nov 2004 10:51:56 -0000 > @@ -89,7 +89,7 @@ > *mount_arg; > enum md_types mdtype; /* The type of our memory disk. */ > bool have_mdtype; > - bool detach, softdep, autounit; > + bool detach, softdep, autounit, keepdata; > char *mtpoint, *unitstr; > char *p; > int ch; > @@ -119,7 +119,7 @@ > 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:KLlMm:Nn:O:o:p:Ss:t:Uv:w:X")) != -1) > switch (ch) { > case 'a': > argappend(&newfs_arg, "-a %s", optarg); > @@ -167,6 +167,8 @@ > usage(); > loudsubs = true; > break; > + case 'K': > + keepdata = true; > case 'l': > argappend(&newfs_arg, "-l"); > break; > @@ -233,7 +235,6 @@ > argv += optind; > if (argc < 2) > usage(); > - > /* Make compatibility assumptions. */ > if (compat) { > mi.mi_mode = 01777; > @@ -258,6 +259,11 @@ > mtpoint = argv[1]; > if (!have_mdtype) > mdtype = MD_SWAP; > + > + /* If we want to use vnode backed file and don't newfs it */ > + if (keepdata && mdtype != MD_VNODE) > + err(1, "Must specify -F with -K"); > + > if (softdep) > argappend(&newfs_arg, "-U"); > > @@ -268,7 +274,8 @@ > do_mdconfig_attach_au(mdconfig_arg, mdtype); > else > do_mdconfig_attach(mdconfig_arg, mdtype); > - do_newfs(newfs_arg); > + if (!keepdata) > + do_newfs(newfs_arg); > do_mount(mount_arg, mtpoint); > do_mtptsetup(mtpoint, &mi); > > @@ -665,13 +672,13 @@ > name = "mdmfs"; > if (!compat) > fprintf(stderr, > -"usage: %s [-DLlMNSUX] [-a maxcontig [-b block-size] [-c cylinders]\n" > +"usage: %s [-DKLlMNSUX] [-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 [-lKNU] [-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); > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"