Package: util-linux
Version: 2.13.1-1
Severity: wishlist
Tags: patch

Hi LaMont,

a friend of mine is looking into the possibility of cloning Debian
(and other) systems automatically and stomped over swap partitions
getting assigned new UUIDs every time the new harddisk is partitioned
and swap is created.

His reseach lead him to

https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/66637

which refers to a patched version of mkswap:

http://free.nchc.org.tw/drbl-core/old/src/mkswap-uuid-0.1.0-2.tar.bz2

I'm attaching it for reference and in case the above URL becomes void.

It would be nice if you could apply this patch and send it upstream.

It's essential when partitions are to be recognised by their uuid and
not by their old device path anymore.

Regards,

        Joey

-- 
If nothing changes, everything will remain the same.  -- Barne's Law

Please always Cc to me when replying to me on the lists.
--- mkswap.c.orig	2007-08-27 15:24:14.000000000 +0200
+++ mkswap-uuid.c	2007-08-27 15:27:02.000000000 +0200
@@ -351,7 +351,7 @@ bit_test_and_clear (unsigned long *addr,
 static void
 usage(void) {
 	fprintf(stderr,
-		_("Usage: %s [-c] [-v0|-v1] [-pPAGESZ] [-L label] /dev/name [blocks]\n"),
+		_("Usage: %s [-c] [-v0|-v1] [-pPAGESZ] [-L label] [-U UUID] /dev/name [blocks]\n"),
 		program_name);
 	exit(1);
 }
@@ -501,6 +501,8 @@ main(int argc, char ** argv) {
 	char *pp;
 	char *opt_label = NULL;
 	unsigned char *uuid = NULL;
+	unsigned char *uuid_input = NULL;
+	int set_uuid = 0; // User Defined UUID, o: False, 1: True
 #ifdef HAVE_LIBUUID
 	uuid_t uuid_dat;
 #endif
@@ -546,6 +548,12 @@ main(int argc, char ** argv) {
 				case 'v':
 					version = atoi(argv[i]+2);
 					break;
+				case 'U':
+					set_uuid = 1;
+					uuid_input = argv[i]+2;
+					if (!*uuid_input && i+1 < argc)
+						uuid_input = argv[++i];
+					break;
 				default:
 					usage();
 			}
@@ -558,8 +566,14 @@ main(int argc, char ** argv) {
 	}
 
 #ifdef HAVE_LIBUUID
-	uuid_generate(uuid_dat);
-	uuid = uuid_dat;
+	if(!set_uuid)
+	{
+ 	  uuid_generate(uuid_dat);
+    	  uuid = uuid_dat;
+	} else {
+	  uuid_parse(uuid_input, uuid_dat);
+	  uuid = uuid_dat;
+	}
 #endif
 
 	init_signature_page();	/* get pagesize */
--- mkswap.8.orig	2007-08-27 16:09:54.000000000 +0200
+++ mkswap-uuid.8	2007-09-01 03:49:49.000000000 +0200
@@ -7,7 +7,7 @@
 .SH NAME
 mkswap \- set up a Linux swap area
 .SH SYNOPSIS
-.BI "mkswap [\-c] [\-v" N "] [\-f] [\-p " PSZ "] [\-L " label "] " device  " [" size "]"
+.BI "mkswap [\-c] [\-v" N "] [\-f] [\-p " PSZ "] [\-L " label "] [\-U " uuid "] " device  " [" size "]"
 .SH DESCRIPTION
 .B mkswap
 sets up a Linux swap area on a device or in a file.
@@ -156,6 +156,10 @@ when creating the swapspace.
 
 Version 0 (-v0) swap space format is no longer supported in 2.5+ kernels.
 
+.TP
+.B \-U uuid
+Specify the uuid to use.
+
 .SH "SEE ALSO"
 .BR fdisk (8),
 .BR swapon (8)

Reply via email to