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 > _at__at_ -36,7 +36,7 _at__at_ > 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 > _at__at_ -57,7 +57,7 _at__at_ > .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 > _at__at_ -162,6 +162,12 _at__at_ > 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 > _at__at_ -89,7 +89,7 _at__at_ > *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; > _at__at_ -119,7 +119,7 _at__at_ > 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); > _at__at_ -167,6 +167,8 _at__at_ > usage(); > loudsubs = true; > break; > + case 'K': > + keepdata = true; > case 'l': > argappend(&newfs_arg, "-l"); > break; > _at__at_ -233,7 +235,6 _at__at_ > argv += optind; > if (argc < 2) > usage(); > - > /* Make compatibility assumptions. */ > if (compat) { > mi.mi_mode = 01777; > _at__at_ -258,6 +259,11 _at__at_ > 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"); > > _at__at_ -268,7 +274,8 _at__at_ > 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); > > _at__at_ -665,13 +672,13 _at__at_ > 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_at_freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe_at_freebsd.org"Received on Tue Nov 30 2004 - 11:06:46 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:23 UTC