# bash -x test-bcache-byuuid-links.sh + mountpoint /mnt /mnt is not a mountpoint + '[' -e /dev/bcache0 ']' + true ++ ls /sys/class/block/bcache0/bcache/stop ls: cannot access '/sys/class/block/bcache0/bcache/stop': No such file or directory + bdev_stop= + '[' -n '' -a -e '' ']' + break + true ++ ls '/sys/fs/bcache/*-*-*-*/stop' ls: cannot access '/sys/fs/bcache/*-*-*-*/stop': No such file or directory + cdev_stop= + '[' -n '' -a -e '' ']' + break + (( x=0 )) + (( x<50 )) + wipefs -a /dev/vdc + rc=0 + '[' 0 = 0 ']' + break + '[' 0 '!=' 0 ']' + (( x=0 )) + (( x<50 )) + wipefs -a /dev/vdb + rc=0 + '[' 0 = 0 ']' + break + '[' 0 '!=' 0 ']' + make-bcache --wipe-bcache -C /dev/vdc -B /dev/vdb UUID: 02ec19a2-1eb3-4cb5-8825-365e2118b946 Set UUID: d08c9f67-0b4a-4cda-95cc-dd8606ff446a version: 0 nbuckets: 20480 block_size: 1 bucket_size: 1024 nr_in_set: 1 nr_this_dev: 0 first_bucket: 1 UUID: 5da87108-3a1c-4f16-8079-57f604b227e3 Set UUID: d08c9f67-0b4a-4cda-95cc-dd8606ff446a version: 1 block_size: 1 data_offset: 16 + udevadm settle --exit-if-exists /dev/bcache0 + '[' '!' -e /dev/bcache/by-uuid ']' + ls -al /dev/bcache/by-uuid/ total 0 drwxr-xr-x 2 root root 60 Apr 9 16:56 . drwxr-xr-x 3 root root 60 Apr 9 16:56 .. lrwxrwxrwx 1 root root 13 Apr 9 16:56 5da87108-3a1c-4f16-8079-57f604b227e3 -> ../../bcache0 + echo 'Creating filesystems on bcache0' Creating filesystems on bcache0 + mkfs.ext4 /dev/bcache0 mke2fs 1.44.1 (24-Mar-2018) Discarding device blocks: done Creating filesystem with 2621438 4k blocks and 655360 inodes Filesystem UUID: 5e3bcd5f-1c9d-4d10-b702-a25cf485463f Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Allocating group tables: done Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done + echo 'mounting bcache0 to /mnt' mounting bcache0 to /mnt + mount /dev/bcache0 /mnt + udevadm settle --exit-if-exists /dev/bcache0 + '[' '!' -e /dev/bcache/by-uuid ']' + ls -al /dev/bcache/by-uuid/ total 0 drwxr-xr-x 2 root root 60 Apr 9 16:56 . drwxr-xr-x 3 root root 60 Apr 9 16:56 .. lrwxrwxrwx 1 root root 13 Apr 9 16:56 5da87108-3a1c-4f16-8079-57f604b227e3 -> ../../bcache0 + echo 'Everything OK' Everything OK + exit 0 root@ubuntu:~# uname -r 4.15.0-20-generic [ 36.522788] bcache: run_cache_set() invalidating existing data [ 36.528680] bcache: register_cache() registered cache device vdc [ 36.529034] bcache: register_bdev() registered backing device vdb [ 36.532237] bcache: bch_cached_dev_attach() Caching vdb as bcache0 on set d08c9f67-0b4a-4cda-95cc-dd8606ff446a [ 36.777614] EXT4-fs (bcache0): mounted filesystem with ordered data mode. Opts: (null) Second invocation: root@ubuntu:~# bash -x test-bcache-byuuid-links.sh + mountpoint /mnt /mnt is a mountpoint + umount -f /mnt + '[' -e /dev/bcache0 ']' + wipefs -a /dev/bcache0 /dev/bcache0: 2 bytes were erased at offset 0x00000438 (ext4): 53 ef + true ++ ls /sys/class/block/bcache0/bcache/stop + bdev_stop=/sys/class/block/bcache0/bcache/stop + '[' -n /sys/class/block/bcache0/bcache/stop -a -e /sys/class/block/bcache0/bcache/stop ']' + echo 'writing 1 to /sys/class/block/bcache0/bcache/stop' writing 1 to /sys/class/block/bcache0/bcache/stop + echo 1 + udevadm settle + sleep 1 + true ++ ls /sys/class/block/bcache0/bcache/stop ls: cannot access '/sys/class/block/bcache0/bcache/stop': No such file or directory + bdev_stop= + '[' -n '' -a -e '' ']' + break + true ++ ls /sys/fs/bcache/d08c9f67-0b4a-4cda-95cc-dd8606ff446a/stop + cdev_stop=/sys/fs/bcache/d08c9f67-0b4a-4cda-95cc-dd8606ff446a/stop + '[' -n /sys/fs/bcache/d08c9f67-0b4a-4cda-95cc-dd8606ff446a/stop -a -e /sys/fs/bcache/d08c9f67-0b4a-4cda-95cc-dd8606ff446a/stop ']' + echo 'writing 1 to /sys/fs/bcache/d08c9f67-0b4a-4cda-95cc-dd8606ff446a/stop' writing 1 to /sys/fs/bcache/d08c9f67-0b4a-4cda-95cc-dd8606ff446a/stop + echo 1 + udevadm settle + sleep 1 + true ++ ls '/sys/fs/bcache/*-*-*-*/stop' ls: cannot access '/sys/fs/bcache/*-*-*-*/stop': No such file or directory + cdev_stop= + '[' -n '' -a -e '' ']' + break + (( x=0 )) + (( x<50 )) + wipefs -a /dev/vdc /dev/vdc: 16 bytes were erased at offset 0x00001018 (bcache): c6 85 73 f6 4e 1a 45 ca 82 65 f5 7f 48 ba 6d 81 + rc=0 + '[' 0 = 0 ']' + break + '[' 0 '!=' 0 ']' + (( x=0 )) + (( x<50 )) + wipefs -a /dev/vdb /dev/vdb: 16 bytes were erased at offset 0x00001018 (bcache): c6 85 73 f6 4e 1a 45 ca 82 65 f5 7f 48 ba 6d 81 + rc=0 + '[' 0 = 0 ']' + break + '[' 0 '!=' 0 ']' + make-bcache --wipe-bcache -C /dev/vdc -B /dev/vdb UUID: e864408d-a9a7-4157-bf8e-b2c4c509d159 Set UUID: 89539960-f362-4c45-a5cb-169a6699afa1 version: 0 nbuckets: 20480 block_size: 1 bucket_size: 1024 nr_in_set: 1 nr_this_dev: 0 first_bucket: 1 UUID: 15f11834-3d90-4b38-b5c1-290ac132f350 Set UUID: 89539960-f362-4c45-a5cb-169a6699afa1 version: 1 block_size: 1 data_offset: 16 + udevadm settle --exit-if-exists /dev/bcache0 + '[' '!' -e /dev/bcache/by-uuid ']' + echo 'bcache0 present but /dev/bcache/by-uuid does not exist!' bcache0 present but /dev/bcache/by-uuid does not exist! + exit 1 [ 135.318976] bcache: bcache_device_free() bcache0 stopped [ 136.366439] bcache: cache_set_free() Cache set d08c9f67-0b4a-4cda-95cc-dd8606ff446a unregistered [ 137.478375] bcache: run_cache_set() invalidating existing data [ 137.484237] bcache: register_cache() registered cache device vdc Notice the missing cached_dev_attach() once the two bind, the kernel emits the uevent which triggers the rules to generate the /dev/bcache/by-uuid symlinks. Third invocation: # bash -x test-bcache-byuuid-links.sh + mountpoint /mnt /mnt is not a mountpoint + '[' -e /dev/bcache0 ']' + true ++ ls /sys/class/block/bcache0/bcache/stop ls: cannot access '/sys/class/block/bcache0/bcache/stop': No such file or directory + bdev_stop= + '[' -n '' -a -e '' ']' + break + true ++ ls /sys/fs/bcache/89539960-f362-4c45-a5cb-169a6699afa1/stop + cdev_stop=/sys/fs/bcache/89539960-f362-4c45-a5cb-169a6699afa1/stop + '[' -n /sys/fs/bcache/89539960-f362-4c45-a5cb-169a6699afa1/stop -a -e /sys/fs/bcache/89539960-f362-4c45-a5cb-169a6699afa1/stop ']' + echo 'writing 1 to /sys/fs/bcache/89539960-f362-4c45-a5cb-169a6699afa1/stop' writing 1 to /sys/fs/bcache/89539960-f362-4c45-a5cb-169a6699afa1/stop + echo 1 + udevadm settle + sleep 1 + true ++ ls '/sys/fs/bcache/*-*-*-*/stop' ls: cannot access '/sys/fs/bcache/*-*-*-*/stop': No such file or directory + cdev_stop= + '[' -n '' -a -e '' ']' + break + (( x=0 )) + (( x<50 )) + wipefs -a /dev/vdc /dev/vdc: 16 bytes were erased at offset 0x00001018 (bcache): c6 85 73 f6 4e 1a 45 ca 82 65 f5 7f 48 ba 6d 81 + rc=0 + '[' 0 = 0 ']' + break + '[' 0 '!=' 0 ']' + (( x=0 )) + (( x<50 )) + wipefs -a /dev/vdb /dev/vdb: 16 bytes were erased at offset 0x00001018 (bcache): c6 85 73 f6 4e 1a 45 ca 82 65 f5 7f 48 ba 6d 81 + rc=0 + '[' 0 = 0 ']' + break + '[' 0 '!=' 0 ']' + make-bcache --wipe-bcache -C /dev/vdc -B /dev/vdb UUID: 34afb042-e7ad-4953-9d72-761d71060fc1 Set UUID: 0eeec346-4cd1-49fe-91b4-6a04db5bef91 version: 0 nbuckets: 20480 block_size: 1 bucket_size: 1024 nr_in_set: 1 nr_this_dev: 0 first_bucket: 1 UUID: b3a2e43f-667f-4870-950a-dea03e155116 Set UUID: 0eeec346-4cd1-49fe-91b4-6a04db5bef91 version: 1 block_size: 1 data_offset: 16 + udevadm settle --exit-if-exists /dev/bcache0 + '[' '!' -e /dev/bcache/by-uuid ']' + ls -al /dev/bcache/by-uuid/ total 0 drwxr-xr-x 2 root root 60 Apr 9 16:59 . drwxr-xr-x 3 root root 60 Apr 9 16:59 .. lrwxrwxrwx 1 root root 13 Apr 9 16:59 b3a2e43f-667f-4870-950a-dea03e155116 -> ../../bcache0 + echo 'Creating filesystems on bcache0' Creating filesystems on bcache0 + mkfs.ext4 /dev/bcache0 mke2fs 1.44.1 (24-Mar-2018) Discarding device blocks: done Creating filesystem with 2621438 4k blocks and 655360 inodes Filesystem UUID: 012e6ca9-c2b0-4a47-8631-67f2de7755cc Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Allocating group tables: done Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done + echo 'mounting bcache0 to /mnt' mounting bcache0 to /mnt + mount /dev/bcache0 /mnt + udevadm settle --exit-if-exists /dev/bcache0 + '[' '!' -e /dev/bcache/by-uuid ']' + ls -al /dev/bcache/by-uuid/ total 0 drwxr-xr-x 2 root root 60 Apr 9 16:59 . drwxr-xr-x 3 root root 60 Apr 9 16:59 .. lrwxrwxrwx 1 root root 13 Apr 9 16:59 b3a2e43f-667f-4870-950a-dea03e155116 -> ../../bcache0 + echo 'Everything OK' Everything OK + exit 0 [ 235.637197] bcache: cache_set_free() Cache set 89539960-f362-4c45-a5cb-169a6699afa1 unregistered [ 236.773186] bcache: run_cache_set() invalidating existing data [ 236.778364] bcache: register_cache() registered cache device vdc [ 236.779896] bcache: register_bdev() registered backing device vdb [ 236.783588] bcache: bch_cached_dev_attach() Caching vdb as bcache0 on set 0eeec346-4cd1-49fe-91b4-6a04db5bef91 [ 237.017778] EXT4-fs (bcache0): mounted filesystem with ordered data mode. Opts: (null)