root@ubuntu:~# bash -x ./test-bcache-byuuid-links.sh + DISK1=/dev/vdb + DISK2=/dev/vdc + 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: 9de7c386-bdad-44cb-9ef4-773ec4b779ec Set UUID: 4e08a0b8-76fe-4e1f-9f98-6c2c4d2e4f15 version: 0 nbuckets: 20480 block_size: 1 bucket_size: 1024 nr_in_set: 1 nr_this_dev: 0 first_bucket: 1 UUID: ca1d12ea-443e-451e-a555-382a5250e1c3 Set UUID: 4e08a0b8-76fe-4e1f-9f98-6c2c4d2e4f15 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 17:02 . drwxr-xr-x 3 root root 60 Apr 9 17:02 .. lrwxrwxrwx 1 root root 13 Apr 9 17:02 ca1d12ea-443e-451e-a555-382a5250e1c3 -> ../../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: 5e656f6c-b445-44d5-aa7b-2cf92a717140 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 17:02 . drwxr-xr-x 3 root root 60 Apr 9 17:02 .. lrwxrwxrwx 1 root root 13 Apr 9 17:02 ca1d12ea-443e-451e-a555-382a5250e1c3 -> ../../bcache0 + echo 'Everything OK' Everything OK + exit 0 root@ubuntu:~# uname -r 4.15.0-76-generic [ 16.669319] bcache: run_cache_set() invalidating existing data [ 16.673941] bcache: register_cache() registered cache device vdc [ 16.674107] bcache: register_bdev() registered backing device vdb [ 16.678570] bcache: bch_cached_dev_attach() Caching vdb as bcache0 on set 4e08a0b8-76fe-4e1f-9f98-6c2c4d2e4f15 [ 16.956311] EXT4-fs (bcache0): mounted filesystem with ordered data mode. Opts: (null) 2nd run root@ubuntu:~# bash -x ./test-bcache-byuuid-links.sh + DISK1=/dev/vdb + DISK2=/dev/vdc + 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/4e08a0b8-76fe-4e1f-9f98-6c2c4d2e4f15/stop + cdev_stop=/sys/fs/bcache/4e08a0b8-76fe-4e1f-9f98-6c2c4d2e4f15/stop + '[' -n /sys/fs/bcache/4e08a0b8-76fe-4e1f-9f98-6c2c4d2e4f15/stop -a -e /sys/fs/bcache/4e08a0b8-76fe-4e1f-9f98-6c2c4d2e4f15/stop ']' + echo 'writing 1 to /sys/fs/bcache/4e08a0b8-76fe-4e1f-9f98-6c2c4d2e4f15/stop' writing 1 to /sys/fs/bcache/4e08a0b8-76fe-4e1f-9f98-6c2c4d2e4f15/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: 68a3d0d9-0a6d-47a0-83d6-d9fde268f780 Set UUID: 787902d7-cfef-41c8-bbf8-5785d07a37da version: 0 nbuckets: 20480 block_size: 1 bucket_size: 1024 nr_in_set: 1 nr_this_dev: 0 first_bucket: 1 UUID: 60051140-6941-41b5-b244-cc8321c4b1cb Set UUID: 787902d7-cfef-41c8-bbf8-5785d07a37da 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 [ 61.325127] bcache: bcache_device_free() bcache0 stopped [ 62.379435] bcache: cache_set_free() Cache set 4e08a0b8-76fe-4e1f-9f98-6c2c4d2e4f15 unregistered [ 63.488959] bcache: run_cache_set() invalidating existing data [ 63.497501] bcache: register_cache() registered cache device vdc Missing bch_cached_dev_attach() Third run: root@ubuntu:~# bash -x ./test-bcache-byuuid-links.sh + DISK1=/dev/vdb + DISK2=/dev/vdc + 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/ec22b3ff-3016-4812-ab6b-9347dd9f7c08/stop + cdev_stop=/sys/fs/bcache/ec22b3ff-3016-4812-ab6b-9347dd9f7c08/stop + '[' -n /sys/fs/bcache/ec22b3ff-3016-4812-ab6b-9347dd9f7c08/stop -a -e /sys/fs/bcache/ec22b3ff-3016-4812-ab6b-9347dd9f7c08/stop ']' + echo 'writing 1 to /sys/fs/bcache/ec22b3ff-3016-4812-ab6b-9347dd9f7c08/stop' writing 1 to /sys/fs/bcache/ec22b3ff-3016-4812-ab6b-9347dd9f7c08/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: b3d6f57a-e445-41b0-8398-fcd907cd28b9 Set UUID: 877f659d-8202-4ef5-8abe-a13b1315d175 version: 0 nbuckets: 20480 block_size: 1 bucket_size: 1024 nr_in_set: 1 nr_this_dev: 0 first_bucket: 1 UUID: 20d210b4-c739-4815-87e1-162e04f60a0a Set UUID: 877f659d-8202-4ef5-8abe-a13b1315d175 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 17:05 . drwxr-xr-x 3 root root 60 Apr 9 17:05 .. lrwxrwxrwx 1 root root 13 Apr 9 17:05 20d210b4-c739-4815-87e1-162e04f60a0a -> ../../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: d1e9df47-4a97-4589-b448-f34150377938 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 17:05 . drwxr-xr-x 3 root root 60 Apr 9 17:05 .. lrwxrwxrwx 1 root root 13 Apr 9 17:05 20d210b4-c739-4815-87e1-162e04f60a0a -> ../../bcache0 + echo 'Everything OK' Everything OK [ 192.560591] bcache: cache_set_free() Cache set ec22b3ff-3016-4812-ab6b-9347dd9f7c08 unregistered [ 193.670979] bcache: run_cache_set() invalidating existing data [ 193.675735] bcache: register_cache() registered cache device vdc [ 193.676320] bcache: register_bdev() registered backing device vdb [ 193.681312] bcache: bch_cached_dev_attach() Caching vdb as bcache0 on set 877f659d-8202-4ef5-8abe-a13b1315d175 [ 193.865871] EXT4-fs (bcache0): mounted filesystem with ordered data mode. Opts: (null)