| 1 | [[PageOutline]] |
| 2 | |
| 3 | = resizing = |
| 4 | == testing xfs_growfs == |
| 5 | === expanding /dev/sdb1 === |
| 6 | 1. mkfs |
| 7 | * sudo fdisk /dev/sdb -l |
| 8 | {{{ |
| 9 | Disk /dev/sdb: 4294 MB, 4294967296 bytes |
| 10 | 255 heads, 63 sectors/track, 522 cylinders |
| 11 | Units = cylinders of 16065 * 512 = 8225280 bytes |
| 12 | Sector size (logical/physical): 512 bytes / 512 bytes |
| 13 | I/O size (minimum/optimal): 512 bytes / 512 bytes |
| 14 | Disk identifier: 0x00000000 |
| 15 | |
| 16 | Disk /dev/sdb doesn't contain a valid partition table |
| 17 | }}} |
| 18 | * sudo fdisk /dev/sdb |
| 19 | {{{ |
| 20 | Command (m for help): n |
| 21 | Command action |
| 22 | e extended |
| 23 | p primary partition (1-4) |
| 24 | p |
| 25 | Partition number (1-4): 1 |
| 26 | First cylinder (1-522, default 1): |
| 27 | Using default value 1 |
| 28 | Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522): +1G |
| 29 | |
| 30 | /dev/sdb1 1 132 1060258+ 83 Linux |
| 31 | }}} |
| 32 | * sudo mkfs.xfs /dev/sdb1 |
| 33 | {{{ |
| 34 | meta-data=/dev/sdb1 isize=256 agcount=4, agsize=66266 blks |
| 35 | = sectsz=512 attr=2 |
| 36 | data = bsize=4096 blocks=265064, imaxpct=25 |
| 37 | = sunit=0 swidth=0 blks |
| 38 | naming =version 2 bsize=4096 ascii-ci=0 |
| 39 | log =internal log bsize=4096 blocks=2560, version=2 |
| 40 | = sectsz=512 sunit=0 blks, lazy-count=1 |
| 41 | realtime =none extsz=4096 blocks=0, rtextents=0 |
| 42 | }}} |
| 43 | * sudo blkid /dev/sdb1 |
| 44 | {{{ |
| 45 | /dev/sdb1: UUID="e47dbfff-97ca-43b8-9a29-89700956a7dd" TYPE="xfs" |
| 46 | }}} |
| 47 | 1. mount |
| 48 | * sudo mkdir /mnt/sdb1 |
| 49 | * sudo mount /dev/sdb1 /mnt/sdb1 |
| 50 | * df /mnt/sdb1/ -h |
| 51 | {{{ |
| 52 | /dev/sdb1 1.1G 4.2M 1022M 1% /mnt/sdb1 |
| 53 | }}} |
| 54 | 1. テストデータの用意 |
| 55 | * sudo dd if=/dev/urandom of=/mnt/sdb1/rand.10M bs=1024 count=10240 |
| 56 | * cp /mnt/sdb1/rand.10M . |
| 57 | 1. remake partition |
| 58 | * sudo umount /mnt/sdb1/ |
| 59 | * sudo fdisk /dev/sdb |
| 60 | {{{ |
| 61 | Command (m for help): d |
| 62 | Selected partition 1 |
| 63 | |
| 64 | Command (m for help): n |
| 65 | Command action |
| 66 | e extended |
| 67 | p primary partition (1-4) |
| 68 | p |
| 69 | Partition number (1-4): 1 |
| 70 | First cylinder (1-522, default 1): |
| 71 | Using default value 1 |
| 72 | Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522): |
| 73 | Using default value 522 |
| 74 | |
| 75 | /dev/sdb1 1 522 4192933+ 83 Linux |
| 76 | }}} |
| 77 | * sudo blkid /dev/sdb1 |
| 78 | {{{ |
| 79 | /dev/sdb1: UUID="e47dbfff-97ca-43b8-9a29-89700956a7dd" TYPE="xfs" |
| 80 | }}} |
| 81 | * sudo mount /dev/sdb1 /mnt/sdb1 |
| 82 | * df /mnt/sdb1/ -h |
| 83 | {{{ |
| 84 | /dev/sdb1 1.1G 15M 1012M 2% /mnt/sdb1 |
| 85 | }}} |
| 86 | * sha1sum -b rand.10M /mnt/sdb1/rand.10M |
| 87 | {{{ |
| 88 | 72d3a67ecd23e77bbc57eb959b945c6cbdae58e1 *rand.10M |
| 89 | 72d3a67ecd23e77bbc57eb959b945c6cbdae58e1 */mnt/sdb1/rand.10M |
| 90 | }}} |
| 91 | 1. resize xfs filesystem |
| 92 | * sudo xfs_growfs /mnt/sdb1/ |
| 93 | {{{ |
| 94 | meta-data=/dev/sdb1 isize=256 agcount=4, agsize=66266 blks |
| 95 | = sectsz=512 attr=2 |
| 96 | data = bsize=4096 blocks=265064, imaxpct=25 |
| 97 | = sunit=0 swidth=0 blks |
| 98 | naming =version 2 bsize=4096 ascii-ci=0 |
| 99 | log =internal bsize=4096 blocks=2560, version=2 |
| 100 | = sectsz=512 sunit=0 blks, lazy-count=1 |
| 101 | realtime =none extsz=4096 blocks=0, rtextents=0 |
| 102 | data blocks changed from 265064 to 1048233 |
| 103 | }}} |
| 104 | * df /mnt/sdb1/ -h |
| 105 | {{{ |
| 106 | Filesystem Size Used Avail Use% Mounted on |
| 107 | /dev/sdb1 4.0G 15M 4.0G 1% /mnt/sdb1 |
| 108 | }}} |
| 109 | * sha1sum -b rand.10M /mnt/sdb1/rand.10M |
| 110 | {{{ |
| 111 | 72d3a67ecd23e77bbc57eb959b945c6cbdae58e1 *rand.10M |
| 112 | 72d3a67ecd23e77bbc57eb959b945c6cbdae58e1 */mnt/sdb1/rand.10M |
| 113 | }}} |
| 114 | |
| 115 | * 問題なく拡張された |
| 116 | |
| 117 | === test with 3 partitions === |
| 118 | 1. make partitions |
| 119 | * sudo fdisk /dev/sdb |
| 120 | * snip |
| 121 | * sudo fdisk /dev/sdb -l |
| 122 | {{{ |
| 123 | /dev/sdb1 1 132 1060258+ 83 Linux |
| 124 | /dev/sdb2 133 394 2104515 83 Linux |
| 125 | /dev/sdb3 395 522 1028160 83 Linux |
| 126 | }}} |
| 127 | 1. mkfs |
| 128 | * sudo mkfs.xfs /dev/sdb1 |
| 129 | {{{ |
| 130 | meta-data=/dev/sdb1 isize=256 agcount=4, agsize=66266 blks |
| 131 | = sectsz=512 attr=2 |
| 132 | data = bsize=4096 blocks=265064, imaxpct=25 |
| 133 | = sunit=0 swidth=0 blks |
| 134 | naming =version 2 bsize=4096 ascii-ci=0 |
| 135 | log =internal log bsize=4096 blocks=2560, version=2 |
| 136 | = sectsz=512 sunit=0 blks, lazy-count=1 |
| 137 | realtime =none extsz=4096 blocks=0, rtextents=0 |
| 138 | }}} |
| 139 | * sudo mkfs.xfs /dev/sdb2 |
| 140 | {{{ |
| 141 | meta-data=/dev/sdb2 isize=256 agcount=4, agsize=131532 blks |
| 142 | = sectsz=512 attr=2 |
| 143 | data = bsize=4096 blocks=526128, imaxpct=25 |
| 144 | = sunit=0 swidth=0 blks |
| 145 | naming =version 2 bsize=4096 ascii-ci=0 |
| 146 | log =internal log bsize=4096 blocks=2560, version=2 |
| 147 | = sectsz=512 sunit=0 blks, lazy-count=1 |
| 148 | realtime =none extsz=4096 blocks=0, rtextents=0 |
| 149 | }}} |
| 150 | * sudo mkfs.xfs /dev/sdb3 |
| 151 | {{{ |
| 152 | meta-data=/dev/sdb3 isize=256 agcount=4, agsize=64260 blks |
| 153 | = sectsz=512 attr=2 |
| 154 | data = bsize=4096 blocks=257040, imaxpct=25 |
| 155 | = sunit=0 swidth=0 blks |
| 156 | naming =version 2 bsize=4096 ascii-ci=0 |
| 157 | log =internal log bsize=4096 blocks=1200, version=2 |
| 158 | = sectsz=512 sunit=0 blks, lazy-count=1 |
| 159 | realtime =none extsz=4096 blocks=0, rtextents=0 |
| 160 | }}} |
| 161 | * sudo blkid /dev/sdb![123] |
| 162 | {{{ |
| 163 | /dev/sdb1: UUID="9065c3c2-ab3d-4460-978e-e37c88f31f5f" TYPE="xfs" |
| 164 | /dev/sdb2: UUID="b9515b82-4d3c-457d-8d32-330cfea692df" TYPE="xfs" |
| 165 | /dev/sdb3: UUID="17374506-2cb1-4451-a5a8-b15cb1410870" TYPE="xfs" |
| 166 | }}} |
| 167 | 1. mount |
| 168 | * sudo mkdir /mnt/sdb1 |
| 169 | * sudo mkdir /mnt/sdb2 |
| 170 | * sudo mkdir /mnt/sdb3 |
| 171 | * sudo mount /dev/sdb1 /mnt/sdb1 |
| 172 | * sudo mount /dev/sdb2 /mnt/sdb2 |
| 173 | * sudo mount /dev/sdb3 /mnt/sdb3 |
| 174 | * df -h |
| 175 | {{{ |
| 176 | /dev/sdb1 1.1G 4.2M 1022M 1% /mnt/sdb1 |
| 177 | /dev/sdb2 2.0G 4.2M 2.0G 1% /mnt/sdb2 |
| 178 | /dev/sdb3 1000M 4.2M 996M 1% /mnt/sdb3 |
| 179 | }}} |
| 180 | 1. テストデータの用意 |
| 181 | * sudo dd if=/dev/urandom of=/mnt/sdb1/rand1.10M bs=1024 count=10240 |
| 182 | * sudo dd if=/dev/urandom of=/mnt/sdb2/rand2.10M bs=1024 count=10240 |
| 183 | * sudo dd if=/dev/urandom of=/mnt/sdb3/rand3.10M bs=1024 count=10240 |
| 184 | * sha1sum -b /mnt/sdb*/rand*.10M |
| 185 | {{{ |
| 186 | 11b2836d9c88f3890224f5d4250e2dd86ddca3e6 */mnt/sdb1/rand1.10M |
| 187 | 3b2fb16c6416b5c6314c396f03275fd20ff8f24b */mnt/sdb2/rand2.10M |
| 188 | 0fb674e54da58858fa1a825f724f5e0c782a8a04 */mnt/sdb3/rand3.10M |
| 189 | }}} |
| 190 | |
| 191 | ==== /dev/sdb2をdisk後方に向けて拡張 ==== |
| 192 | 1. remake partition |
| 193 | * sudo umount /dev/sdb![123] |
| 194 | * sudo fdisk /dev/sdb |
| 195 | {{{ |
| 196 | /dev/sdb1 1 132 1060258+ 83 Linux |
| 197 | /dev/sdb2 133 394 2104515 83 Linux |
| 198 | /dev/sdb3 395 522 1028160 83 Linux |
| 199 | |
| 200 | Command (m for help): d |
| 201 | Partition number (1-4): 3 |
| 202 | |
| 203 | Command (m for help): d |
| 204 | Partition number (1-4): 2 |
| 205 | |
| 206 | Command (m for help): n |
| 207 | Command action |
| 208 | e extended |
| 209 | p primary partition (1-4) |
| 210 | p |
| 211 | Partition number (1-4): 2 |
| 212 | First cylinder (133-522, default 133): |
| 213 | Using default value 133 |
| 214 | Last cylinder, +cylinders or +size{K,M,G} (133-522, default 522): |
| 215 | Using default value 522 |
| 216 | |
| 217 | /dev/sdb1 1 132 1060258+ 83 Linux |
| 218 | /dev/sdb2 133 522 3132675 83 Linux |
| 219 | }}} |
| 220 | 1. resize xfs filesystem |
| 221 | * sudo mount /dev/sdb2 /mnt/sdb2 |
| 222 | * df -h |
| 223 | {{{ |
| 224 | /dev/sdb2 2.0G 15M 2.0G 1% /mnt/sdb2 |
| 225 | }}} |
| 226 | * sha1sum -b /mnt/sdb*/rand*.10M |
| 227 | {{{ |
| 228 | 3b2fb16c6416b5c6314c396f03275fd20ff8f24b */mnt/sdb2/rand2.10M |
| 229 | }}} |
| 230 | * sudo xfs_growfs /mnt/sdb2/ |
| 231 | {{{ |
| 232 | meta-data=/dev/sdb2 isize=256 agcount=4, agsize=131532 blks |
| 233 | = sectsz=512 attr=2 |
| 234 | data = bsize=4096 blocks=526128, imaxpct=25 |
| 235 | = sunit=0 swidth=0 blks |
| 236 | naming =version 2 bsize=4096 ascii-ci=0 |
| 237 | log =internal bsize=4096 blocks=2560, version=2 |
| 238 | = sectsz=512 sunit=0 blks, lazy-count=1 |
| 239 | realtime =none extsz=4096 blocks=0, rtextents=0 |
| 240 | data blocks changed from 526128 to 783168 |
| 241 | }}} |
| 242 | * sudo blkid /dev/sdb![123] |
| 243 | {{{ |
| 244 | /dev/sdb1: UUID="9065c3c2-ab3d-4460-978e-e37c88f31f5f" TYPE="xfs" |
| 245 | /dev/sdb2: UUID="b9515b82-4d3c-457d-8d32-330cfea692df" TYPE="xfs" |
| 246 | }}} |
| 247 | * df -h |
| 248 | {{{ |
| 249 | /dev/sdb2 3.0G 15M 3.0G 1% /mnt/sdb2 |
| 250 | }}} |
| 251 | |
| 252 | * 問題なく拡張された |
| 253 | |
| 254 | ==== /dev/sdb2をdisk前方に向けて拡張 ==== |
| 255 | ===== remake partition with name sdb1 ===== |
| 256 | * sudo umount /dev/sdb![123] |
| 257 | * sudo fdisk /dev/sdb |
| 258 | {{{ |
| 259 | /dev/sdb1 1 132 1060258+ 83 Linux |
| 260 | /dev/sdb2 133 522 3132675 83 Linux |
| 261 | |
| 262 | |
| 263 | Command (m for help): d |
| 264 | Partition number (1-4): 1 |
| 265 | |
| 266 | Command (m for help): d |
| 267 | Selected partition 2 |
| 268 | |
| 269 | Command (m for help): n |
| 270 | Command action |
| 271 | e extended |
| 272 | p primary partition (1-4) |
| 273 | p |
| 274 | Partition number (1-4): 1 |
| 275 | First cylinder (1-522, default 1): |
| 276 | Using default value 1 |
| 277 | Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522): |
| 278 | Using default value 522 |
| 279 | |
| 280 | |
| 281 | /dev/sdb1 1 522 4192933+ 83 Linux |
| 282 | }}} |
| 283 | * sudo mount /dev/sdb1 /mnt/sdb1 |
| 284 | * sha1sum -b /mnt/sdb*/rand*.10M |
| 285 | {{{ |
| 286 | 11b2836d9c88f3890224f5d4250e2dd86ddca3e6 */mnt/sdb1/rand1.10M |
| 287 | }}} |
| 288 | |
| 289 | * 当然だがsdb2ではなくsdb1がmountされてしまう |
| 290 | |
| 291 | ===== remake partition with name sdb2 ===== |
| 292 | * sudo umount /dev/sdb![123] |
| 293 | * sudo fdisk /dev/sdb |
| 294 | {{{ |
| 295 | /dev/sdb1 1 522 4192933+ 83 Linux |
| 296 | |
| 297 | Command (m for help): d |
| 298 | Selected partition 1 |
| 299 | |
| 300 | Command (m for help): n |
| 301 | Command action |
| 302 | e extended |
| 303 | p primary partition (1-4) |
| 304 | p |
| 305 | Partition number (1-4): 2 |
| 306 | First cylinder (1-522, default 1): |
| 307 | Using default value 1 |
| 308 | Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522): |
| 309 | Using default value 522 |
| 310 | |
| 311 | /dev/sdb2 1 522 4192933+ 83 Linux |
| 312 | }}} |
| 313 | * sudo mount /dev/sdb2 /mnt/sdb2 |
| 314 | * sha1sum -b /mnt/sdb*/rand*.10M |
| 315 | {{{ |
| 316 | 11b2836d9c88f3890224f5d4250e2dd86ddca3e6 */mnt/sdb2/rand1.10M |
| 317 | }}} |
| 318 | |
| 319 | * やはりsdb1の内容がmountされる |
| 320 | |
| 321 | ===== overwrite sdb1 with 0x00 and remake partition ===== |
| 322 | * sudo umount /dev/sdb![123] |
| 323 | * sudo fdisk /dev/sdb |
| 324 | {{{ |
| 325 | /dev/sdb2 1 522 4192933+ 83 Linux |
| 326 | |
| 327 | |
| 328 | Command (m for help): d |
| 329 | Selected partition 2 |
| 330 | |
| 331 | Command (m for help): n |
| 332 | Command action |
| 333 | e extended |
| 334 | p primary partition (1-4) |
| 335 | p |
| 336 | Partition number (1-4): 1 |
| 337 | First cylinder (1-522, default 1): |
| 338 | Using default value 1 |
| 339 | Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522): 132 |
| 340 | |
| 341 | Command (m for help): n |
| 342 | Command action |
| 343 | e extended |
| 344 | p primary partition (1-4) |
| 345 | p |
| 346 | Partition number (1-4): 2 |
| 347 | First cylinder (133-522, default 133): |
| 348 | Using default value 133 |
| 349 | Last cylinder, +cylinders or +size{K,M,G} (133-522, default 522): |
| 350 | Using default value 522 |
| 351 | |
| 352 | /dev/sdb1 1 132 1060258+ 83 Linux |
| 353 | /dev/sdb2 133 522 3132675 83 Linux |
| 354 | }}} |
| 355 | * sudo dd if=/dev/zero of=/dev/sdb1 bs=1024 count=10240 |
| 356 | * sudo mount /dev/sdb1 /mnt/sdb1 -t xfs |
| 357 | {{{ |
| 358 | [ 8848.630996] XFS: bad magic number |
| 359 | [ 8848.630996] XFS: SB validate failed |
| 360 | }}} |
| 361 | * sudo mount /dev/sdb2 /mnt/sdb2 |
| 362 | * sha1sum -b /mnt/sdb*/rand*.10M |
| 363 | {{{ |
| 364 | 3b2fb16c6416b5c6314c396f03275fd20ff8f24b */mnt/sdb2/rand2.10M |
| 365 | }}} |
| 366 | |
| 367 | * sudo umount /dev/sdb![123] |
| 368 | * sudo fdisk /dev/sdb |
| 369 | {{{ |
| 370 | /dev/sdb1 1 132 1060258+ 83 Linux |
| 371 | /dev/sdb2 133 522 3132675 83 Linux |
| 372 | |
| 373 | Command (m for help): d |
| 374 | Partition number (1-4): 1 |
| 375 | |
| 376 | Command (m for help): d |
| 377 | Selected partition 2 |
| 378 | |
| 379 | Command (m for help): n |
| 380 | Command action |
| 381 | e extended |
| 382 | p primary partition (1-4) |
| 383 | p |
| 384 | Partition number (1-4): 2 |
| 385 | First cylinder (1-522, default 1): |
| 386 | Using default value 1 |
| 387 | Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522): |
| 388 | Using default value 522 |
| 389 | |
| 390 | |
| 391 | /dev/sdb2 1 522 4192933+ 83 Linux |
| 392 | }}} |
| 393 | * sudo mount /dev/sdb2 /mnt/sdb2 -t xfs |
| 394 | {{{ |
| 395 | [ 9060.520973] XFS: bad magic number |
| 396 | [ 9060.520973] XFS: SB validate failed |
| 397 | }}} |
| 398 | |
| 399 | * 全くmount出来なくなる |