Oh, at least one additional thing that's likely needed in this scenario is the attached patch to make busybox's mkswap generate UUIDs.
* util-linux/mkswap.c: Set UUIDs on version 1 swap areas. * util-linux/Makefile.in: mkswap needs uuid/uuid.h from e2fsprogs. * e2fsprogs/Makefile.in: Build libuuid if building mkswap. Ubuntu's volumeid.postinst also has some nasty code to add a UUID to swap partitions that don't have one (due to busybox's mkswap not doing this in the past). This was necessary because we were expecting to have to change a lot of hard disk device names due to recent libata changes in the kernel and forcibly moving over to UUIDs in /etc/fstab in advance was the only way we could think of to prevent wholesale breakage. UUIDs certainly have their disadvantages (verbosity being the main one), but they're a hell of a lot better than labels for automatic use like this. UUIDs are suitable for automatic generation while labels should only be set by the sysadmin. The fiasco with Red Hat's installer setting labels which can then end up conflicting with itself if you do multiple parallel installs should demonstrate this (and some of the people involved in Anaconda development said to me in person that in hindsight this was probably a mistake). We've already backed away from automatic use of labels once (http://bugs.debian.org/310754) so let's not have to do so again! -- Colin Watson [EMAIL PROTECTED]
only in patch2: unchanged: --- busybox-1.1.3.orig/e2fsprogs/Makefile.in +++ busybox-1.1.3/e2fsprogs/Makefile.in @@ -61,6 +61,7 @@ E2FSPROGS-$(CONFIG_LSATTR) += lsattr.o $(E2P_OBJS) E2FSPROGS-$(CONFIG_MKE2FS) += mke2fs.o util.o $(E2P_OBJS) $(BLKID_OBJS) $(EXT2FS_OBJS) $(UUID_OBJS) E2FSPROGS-$(CONFIG_TUNE2FS) += tune2fs.o util.o $(E2P_OBJS) $(BLKID_OBJS) $(EXT2FS_OBJS) $(UUID_OBJS) +E2FSPROGS-$(CONFIG_MKSWAP) += $(UUID_OBJS) E2FSPROGS-y:=$(sort $(E2FSPROGS-y)) only in patch2: unchanged: --- busybox-1.1.3.orig/util-linux/mkswap.c +++ busybox-1.1.3/util-linux/mkswap.c @@ -44,6 +44,7 @@ #include <sys/utsname.h> #include <asm/page.h> /* for PAGE_SIZE and PAGE_SHIFT */ /* we also get PAGE_SIZE via getpagesize() */ +#include "uuid/uuid.h" #include "busybox.h" #ifndef _IO @@ -81,6 +82,17 @@ unsigned int badpages[1]; } *p; +struct swap_header_v1_2 { + char bootbits[1024]; /* Space for disklabel etc. */ + unsigned int version; + unsigned int last_page; + unsigned int nr_badpages; + unsigned char uuid[16]; + char volume_name[16]; + unsigned int padding[117]; + unsigned int badpages[1]; +}; + static inline void init_signature_page(void) { pagesize = getpagesize(); @@ -276,6 +288,9 @@ int goodpages; int offset; int force = 0; + uuid_t uuid_dat; + + uuid_generate(uuid_dat); init_signature_page(); /* get pagesize */ @@ -401,6 +416,21 @@ version, (long) (goodpages * pagesize)); write_signature((version == 0) ? "SWAP-SPACE" : "SWAPSPACE2"); + if (version == 1) { + struct swap_header_v1_2 *h; + + /* Sanity check */ + if (sizeof(struct swap_header_v1) != sizeof(struct swap_header_v1_2)) + bb_error_msg("Bad swap header size; no UUID written."); + else { + char uuid_string[37]; + h = (struct swap_header_v1_2 *) signature_page; + memcpy(h->uuid, uuid_dat, sizeof(h->uuid)); + uuid_unparse(uuid_dat, uuid_string); + printf("UUID=%s\n", uuid_string); + } + } + offset = ((version == 0) ? 0 : 1024); if (lseek(DEV, offset, SEEK_SET) != offset) bb_error_msg_and_die("unable to rewind swap-device"); only in patch2: unchanged: --- busybox-1.1.3.orig/util-linux/Makefile.in +++ busybox-1.1.3/util-linux/Makefile.in @@ -10,6 +10,8 @@ endif srcdir=$(top_srcdir)/util-linux +UTILLINUX_CFLAGS := -I$(top_srcdir)/e2fsprogs + UTILLINUX-y:= UTILLINUX-$(CONFIG_DMESG) +=dmesg.o UTILLINUX-$(CONFIG_FBSET) +=fbset.o @@ -49,11 +51,14 @@ APPLET_SRC-y+=$(UTILLINUX_SRC-y) APPLET_SRC-a+=$(UTILLINUX_SRC-a) +APPLETS_DEFINE-y+=$(UTILLINUX_CFLAGS) +APPLETS_DEFINE-a+=$(UTILLINUX_CFLAGS) + $(UTILLINUX_DIR)$(UTILLINUX_AR): $(patsubst %,$(UTILLINUX_DIR)%, $(UTILLINUX-y)) $(do_ar) $(UTILLINUX_DIR)%.o: $(srcdir)/%.c - $(compile.c) + $(compile.c) $(UTILLINUX_CFLAGS) ifneq ($(strip $(CONFIG_LFS)),y) ifeq ($(strip $(FDISK_SUPPORT_LARGE_DISKS)),y)