From: Mika Eloranta <mel@ohmu.fi>
To: xfs@oss.sgi.com
Cc: Mika Eloranta <mel@ohmu.fi>
Subject: [PATCH] mkfs.xfs: option for using a pre-defined filesystem UUID
Date: Tue, 22 Sep 2015 15:24:51 +0300 [thread overview]
Message-ID: <1442924691-42001-1-git-send-email-mel@ohmu.fi> (raw)
Usage: mkfs.xfs -m uuid=<uuid> <device>
The filesystem UUID can now be optionally specified during filesystem
creation. The default behavior is still to generate a random UUID.
Allows using pre-generated UUIDs for identifying a filesystem based
on the metadata stored inside the filesystem. Filesystem labels can
be used for the same purpose, but are limited by their length
(12 chars in the case of xfs) whereas the UUID field can store an
entire 128bit UUID, which is plenty for e.g. random ID collision
avoidance.
Random UUID generated during the creation of the filesystem is not
always feasible when an external DB or other system is used to track
the created filesystem, e.g. in automated VM provisioning systems,
as this would require a feedback mechanism which is not always
available. In these cases the best approach often is to generate
a random UUID for the filesystem before the filesystem even exists,
store it in the tracking DB and later create the filesystem directly
with the correct UUID (instead of "mkfs.xfs + xfs_admin -U <new_uuid>").
---
man/man8/mkfs.xfs.8 | 4 ++++
mkfs/xfs_mkfs.c | 15 +++++++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/man/man8/mkfs.xfs.8 b/man/man8/mkfs.xfs.8
index 6260e0c..e98b94d 100644
--- a/man/man8/mkfs.xfs.8
+++ b/man/man8/mkfs.xfs.8
@@ -169,6 +169,10 @@ will create free inode btrees for filesystems created with the (default)
option set. When the option
.B \-m crc=0
is used, the free inode btree feature is not supported and is disabled.
+.TP
+.BI uuid= value
+Use the given value as the filesystem UUID for the newly created filesystem.
+The default is to generate a random UUID.
.RE
.TP
.BI \-d " data_section_options"
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index d993fc0..696c96d 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -181,6 +181,8 @@ char *mopts[] = {
"crc",
#define M_FINOBT 1
"finobt",
+#define M_UUID 2
+ "uuid",
NULL
};
@@ -948,6 +950,7 @@ main(
bool finobtflag;
int spinodes;
+ platform_uuid_clear(&uuid);
progname = basename(argv[0]);
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
@@ -1488,6 +1491,12 @@ main(
finobt = c;
finobtflag = true;
break;
+ case M_UUID:
+ if (!value || *value == '\0')
+ reqval('m', mopts, M_UUID);
+ if (platform_uuid_parse(value, &uuid))
+ illegal(optarg, "m uuid");
+ break;
default:
unknown('m', value);
}
@@ -2550,7 +2559,9 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
sbp->sb_dblocks = dblocks;
sbp->sb_rblocks = rtblocks;
sbp->sb_rextents = rtextents;
- platform_uuid_generate(&uuid);
+ if (platform_uuid_is_null(&uuid)) {
+ platform_uuid_generate(&uuid);
+ }
platform_uuid_copy(&sbp->sb_uuid, &uuid);
/* Only in memory; libxfs expects this as if read from disk */
platform_uuid_copy(&sbp->sb_meta_uuid, &uuid);
@@ -3163,7 +3174,7 @@ usage( void )
{
fprintf(stderr, _("Usage: %s\n\
/* blocksize */ [-b log=n|size=num]\n\
-/* metadata */ [-m crc=0|1,finobt=0|1]\n\
+/* metadata */ [-m crc=0|1,finobt=0|1,uuid=xxx]\n\
/* data subvol */ [-d agcount=n,agsize=n,file,name=xxx,size=num,\n\
(sunit=value,swidth=value|su=num,sw=num|noalign),\n\
sectlog=n|sectsize=num\n\
--
2.3.5
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next reply other threads:[~2015-09-22 12:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-22 12:24 Mika Eloranta [this message]
2015-09-22 22:34 ` [PATCH] mkfs.xfs: option for using a pre-defined filesystem UUID Dave Chinner
-- strict thread matches above, loose matches on Subject: below --
2015-09-23 6:16 Mika Eloranta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1442924691-42001-1-git-send-email-mel@ohmu.fi \
--to=mel@ohmu.fi \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox