#729445 No /dev/disk/by-uuid link created for ext2 partitions

#729445#5
Date:
2013-11-12 23:07:11 UTC
From:
To:
Several users reported that /dev/disk/by-uuid is not updated when d-i
creates an ext2 filesystem.  This problem does not happen when you
create an ext3 or ext4 filesysten.  I noticed that d-i uses parted to
create ext2 filesystems whereas ext3 and ext4 filesystems are created
by running mkfs.ext[34].

I ran parted mkfs outside of d-i and the /dev/disk/by-uuid was
created.

Looking at partman server, it seems to run:

command_create_file_system
timered_file_system_create
ped_file_system_create

whereas parted is like this:

do_mkfs
ped_file_system_create
....
ped_disk_commit

ped_disk_commit sounds like a command that informs the OS of the
change.  Maybe this function would trigger udev to update the
/dev/disk/by-uuid link?

Note that I don't know anything about parted, so maybe this hypothesis
is completely wrong, but there's certainly a problem somewhere.

This bug is easy to reproduce: boot d-i, enter partman, create one
partition with ext2 and one with ext3.  Then check /dev/disk/by-uuid
and you'll see there's a link for the ext3 but no link for the ext2
partition.

#729445#16
Date:
2013-11-13 00:13:20 UTC
From:
To:
Another example of this bug is #701223, which was closed because of
too little info.

#729445#23
Date:
2013-11-19 17:21:56 UTC
From:
To:
Here's a workaround for partman-basicfilesystem but obviously it would
be nice if this could get fixed properly.

diff --git a/commit.d/format_basicfilesystems b/commit.d/format_basicfilesystems
index 2b24dee..4a572ca 100755
--- a/commit.d/format_basicfilesystems
+++ b/commit.d/format_basicfilesystems
@@ -61,6 +61,13 @@ for dev in $DEVICES/*; do
 					read_line status
 					close_dialog
 					sync
+					# Create link in /dev/disk/by-uuid
+					dev=$(basename $device)
+					uuid=$(blkid $device -s UUID -o value)
+					if [ -n "$uuid" ]; then
+						rm -f /dev/disk/by-uuid/$uuid
+						ln -s ../../$dev /dev/disk/by-uuid/$uuid
+					fi
 				else
 					status=failed
 				fi

#729445#28
Date:
2013-11-19 22:32:34 UTC
From:
To:
Very clever! =) i think to be honest, this is good enough.

Regards,

Dmitrijs.

#729445#33
Date:
2015-08-06 15:02:25 UTC
From:
To:
21:59 < tbm> cjwatson_: what do you think of my hack in #729445
22:08 < cjwatson> tbm: This has all changed around since you posted that; partman no longer uses parted's fs handling code (which itself no longer exists)
22:09 < tbm> cjwatson: do you think the bug is gone then?
22:09 < cjwatson> tbm: Certainly (now that I've dug up enough patch context) the case you're patching no longer exists at all.
22:09 < cjwatson> Definitely worth retesting if you have a test case
22:10 < tbm> cjwatson: cool, will add it to my todo list