Easy solution
Just reanalyze the badblocks list after filesystem creation. e2fsck resembles mkfs.ext4 in having -c. Use the GUI to create the filesystem, unmount it, then e2fsck -cc /dev/mapper/luks-<new partition>. Make sure you select the right partition shown in gnome-disk-utility's "Device" row when the ext4 partition is clicked.
This uses the GUI, but we needed to add a step after the GUI. The "Repair Filesystem" option in the GUI doesn't allow checking for badblocks.
Not using the GUI and using your generic tutorial link is easier. It's just cryptsetup luksFormat /dev/sdc1 && cryptsetup luksOpen /dev/sdcsdc1 openedname && mkfs.ext4 <your options like -c> /dev/mapper/openedname
Hard solution
The LUKS header is always 32768 512-byte sectors. We can offset the old badblocks list (50964096-byte sectors) by that. This is much faster on a slow disk but is human-error-prone.
- Don't yet erase your old filesystem on
/dev/sdc1with the badblocks info present - Verify
dumpe2fs -h /dev/sdc1 | grep 'Block size'. Stop if it's not 4096 - Export old badblocks list:
dumpe2fs -b /dev/sdc1 > /root/badblocks.old - Use your gnome-disk-utility to erase and format the partition as LUKS-encrypted ext4
- Use the GUI to unmount the ext4 partition but don't lock its LUKS container
- Note the "Device" row's path after clicking on the new ext4 partition in gnome-disk-utility. Remove the
/dev/mapper/prefix - Verify
dmsetup table | grep luks-<new partition>. The output should look likeluks-<new parition>: 0 <number> crypt aes-xts-plain64 :64:logon:cryptsetup:<your device>-d0 <ignore but usually 0> <major>:<minor number> 32768 <options...>. Stop if the 0 and 32768 are different - Verify
dumpe2fs -h /dev/mapper/luks-<new partition> | grep 'Block size'. Stop if it's not 4096 - Offset the badblocks list:
</root/badblocks.old awk '{print $0-((32768)*512/4096)}' >/root/badblocks.new - Import the badblocks list:
e2fsck /dev/mapper/luks-<new partition> -l /root/badblocks.new