rbd块映射:
1 root@u18:~# rbd create kvm/test002.img --size 20 2 root@u18:~# rbd info kvm/test002.img 3 rbd image 'test002.img': 4 size 20480 kB in 5 objects 5 order 22 (4096 kB objects) 6 block_name_prefix: rb.0.2f13.2ae8944a 7 format: 1 8 root@u18:~# rbd map kvm/test002.img 9 root@u18:~# lsblk 10 NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT 11 sda 8:0 0 298.1G 0 disk 12 ├─sda1 8:1 0 296.2G 0 part / 13 ├─sda2 8:2 0 1K 0 part 14 └─sda5 8:5 0 1.9G 0 part [SWAP] 15 sdb 8:16 0 465.8G 0 disk 16 ├─sdb1 8:17 0 200G 0 part /ceph_node0 17 ├─sdb2 8:18 0 1K 0 part 18 ├─sdb5 8:21 0 100G 0 part 19 └─sdb6 8:22 0 165.8G 0 part /data2 20 rbd0 250:0 0 40G 0 disk 21 rbd1 250:16 0 20M 0 disk 22 zram0 251:0 0 936.4M 0 disk [SWAP] 23 24 root@u18:~# mkfs.ext4 /dev/rbd1 25 mke2fs 1.42 (29-Nov-2011) 26 Filesystem label= 27 OS type: Linux 28 Block size=1024 (log=0) 29 Fragment size=1024 (log=0) 30 Stride=4096 blocks, Stripe width=4096 blocks 31 5136 inodes, 20480 blocks 32 1024 blocks (5.00%) reserved for the super user 33 First data block=1 34 Maximum filesystem blocks=20971520 35 3 block groups 36 8192 blocks per group, 8192 fragments per group 37 1712 inodes per group 38 Superblock backups stored on blocks: 39 8193 40 41 Allocating group tables: done 42 Writing inode tables: done 43 Creating journal (1024 blocks): done 44 Writing superblocks and filesystem accounting information: done 45 46 47 root@u18:~# mount /dev/rbd1 /mnt 48 root@u18:~# echo test > /mnt/a.log 49 root@u18:~# vim a.log 50 root@u18:~# vim /mnt/a.log 51 root@u18:~# umount /mnt 52 root@u18:~# rbd unmap /dev/rbd1 53 root@u18:~# rbd resize --size 40960 kvm/test002.img 54 Resizing image: 100% complete...done. 55 root@u18:~# rbd info kvm/test002.img 56 rbd image 'test002.img': 57 size 40960 MB in 10240 objects 58 order 22 (4096 kB objects) 59 block_name_prefix: rb.0.2f13.2ae8944a 60 format: 1 61 root@u18:~# rbd info kvm/test002.img 62 rbd image 'test002.img': 63 size 40960 MB in 10240 objects 64 order 22 (4096 kB objects) 65 block_name_prefix: rb.0.2f13.2ae8944a 66 format: 1 67 root@u18:~# rbd map kvm/test002.img 68 root@u18:~# lsblk 69 NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT 70 sda 8:0 0 298.1G 0 disk 71 ├─sda1 8:1 0 296.2G 0 part / 72 ├─sda2 8:2 0 1K 0 part 73 └─sda5 8:5 0 1.9G 0 part [SWAP] 74 sdb 8:16 0 465.8G 0 disk 75 ├─sdb1 8:17 0 200G 0 part /ceph_node0 76 ├─sdb2 8:18 0 1K 0 part 77 ├─sdb5 8:21 0 100G 0 part 78 └─sdb6 8:22 0 165.8G 0 part /data2 79 rbd0 250:0 0 40G 0 disk 80 rbd1 250:16 0 40G 0 disk 81 zram0 251:0 0 936.4M 0 disk [SWAP] 82 root@u18:~# rbd unmap /dev/rbd1 83 root@u18:~# lsblk 84 NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT 85 sda 8:0 0 298.1G 0 disk 86 ├─sda1 8:1 0 296.2G 0 part / 87 ├─sda2 8:2 0 1K 0 part 88 └─sda5 8:5 0 1.9G 0 part [SWAP] 89 sdb 8:16 0 465.8G 0 disk 90 ├─sdb1 8:17 0 200G 0 part /ceph_node0 91 ├─sdb2 8:18 0 1K 0 part 92 ├─sdb5 8:21 0 100G 0 part 93 └─sdb6 8:22 0 165.8G 0 part /data2 94 rbd0 250:0 0 40G 0 disk 95 zram0 251:0 0 936.4M 0 disk [SWAP] 96 root@u18:~# rbd map kvm/test002.img 97 root@u18:~# lsblk 98 NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT 99 sda 8:0 0 298.1G 0 disk 100 ├─sda1 8:1 0 296.2G 0 part / 101 ├─sda2 8:2 0 1K 0 part 102 └─sda5 8:5 0 1.9G 0 part [SWAP] 103 sdb 8:16 0 465.8G 0 disk 104 ├─sdb1 8:17 0 200G 0 part /ceph_node0 105 ├─sdb2 8:18 0 1K 0 part 106 ├─sdb5 8:21 0 100G 0 part 107 └─sdb6 8:22 0 165.8G 0 part /data2 108 rbd0 250:0 0 40G 0 disk 109 rbd1 250:16 0 40G 0 disk 110 zram0 251:0 0 936.4M 0 disk [SWAP] 111 root@u18:~# mount /dev/rbd1 /mnt 112 root@u18:~# parted /dev/rbd1 print free 113 root@u18:~# parted /dev/rbd1 print free 114 Model: Unknown (unknown) 115 Disk /dev/rbd1: 42.9GB 116 Sector size (logical/physical): 512B/512B 117 Partition Table: loop 118 119 Number Start End Size File system Flags 120 1 0.00B 42.9GB 42.9GB ext4 121 122 root@u18:~# vim /mnt/a.log 123 root@u18:~# cat /mnt/a.log 124 test