| | 400 | |
| | 401 | ==== 適当(と思われる)方法 ==== |
| | 402 | 1. mount |
| | 403 | * sudo fdisk -l /dev/sdb |
| | 404 | {{{ |
| | 405 | /dev/sdb1 1 132 1060258+ 83 Linux |
| | 406 | /dev/sdb2 133 522 3132675 83 Linux |
| | 407 | }}} |
| | 408 | * sudo fdisk -lu /dev/sdb |
| | 409 | {{{ |
| | 410 | /dev/sdb1 63 2120579 1060258+ 83 Linux |
| | 411 | /dev/sdb2 2120580 8385929 3132675 83 Linux |
| | 412 | }}} |
| | 413 | * sudo mount /dev/sdb1 /mnt/sdb1 |
| | 414 | * sudo mount /dev/sdb2 /mnt/sdb2 |
| | 415 | * df -h |
| | 416 | {{{ |
| | 417 | /dev/sdb1 1.1G 15M 1012M 2% /mnt/sdb1 |
| | 418 | /dev/sdb2 3.0G 15M 3.0G 1% /mnt/sdb2 |
| | 419 | }}} |
| | 420 | * sha1sum -b /mnt/sdb*/rand*.10M |
| | 421 | {{{ |
| | 422 | 11b2836d9c88f3890224f5d4250e2dd86ddca3e6 */mnt/sdb1/rand1.10M |
| | 423 | 3b2fb16c6416b5c6314c396f03275fd20ff8f24b */mnt/sdb2/rand2.10M |
| | 424 | }}} |
| | 425 | 1. テストデータの用意 |
| | 426 | * sudo dd if=/dev/urandom of=/mnt/sdb1/rand1.900M bs=512 count=921600 |
| | 427 | * sudo dd if=/dev/urandom of=/mnt/sdb2/rand2.2900M bs=1024 count=2969600 |
| | 428 | * sudo dd if=/dev/urandom of=/mnt/sdb1/rand1.max bs=512 |
| | 429 | * sudo dd if=/dev/urandom of=/mnt/sdb2/rand2.max bs=512 & |
| | 430 | * df -h |
| | 431 | {{{ |
| | 432 | /dev/sdb1 1.1G 1.1G 20K 100% /mnt/sdb1 |
| | 433 | /dev/sdb2 3.0G 3.0G 20K 100% /mnt/sdb2 |
| | 434 | }}} |
| | 435 | * sha1sum -b /mnt/sdb*/rand* > checksum.sha1 |
| | 436 | 1. remake partition |
| | 437 | * sudo umount /dev/sdb![123] |
| | 438 | * sudo fdisk /dev/sdb |
| | 439 | {{{ |
| | 440 | Command (m for help): d |
| | 441 | Partition number (1-4): 1 |
| | 442 | |
| | 443 | Command (m for help): d |
| | 444 | Selected partition 2 |
| | 445 | |
| | 446 | Command (m for help): n |
| | 447 | Command action |
| | 448 | e extended |
| | 449 | p primary partition (1-4) |
| | 450 | p |
| | 451 | Partition number (1-4): 1 |
| | 452 | First cylinder (1-522, default 1): |
| | 453 | Using default value 1 |
| | 454 | Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522): |
| | 455 | Using default value 522 |
| | 456 | |
| | 457 | /dev/sdb1 1 522 4192933+ 83 Linux |
| | 458 | }}} |
| | 459 | * sudo mount /dev/sdb1 /mnt/sdb1 |
| | 460 | * sha1sum -c checksum.sha1 |
| | 461 | {{{ |
| | 462 | /mnt/sdb1/rand1.10M: OK |
| | 463 | /mnt/sdb1/rand1.900M: OK |
| | 464 | /mnt/sdb1/rand1.max: OK |
| | 465 | sha1sum: /mnt/sdb2/rand2.10M: No such file or directory |
| | 466 | /mnt/sdb2/rand2.10M: FAILED open or read |
| | 467 | sha1sum: /mnt/sdb2/rand2.2900M: No such file or directory |
| | 468 | /mnt/sdb2/rand2.2900M: FAILED open or read |
| | 469 | sha1sum: /mnt/sdb2/rand2.max: No such file or directory |
| | 470 | /mnt/sdb2/rand2.max: FAILED open or read |
| | 471 | sha1sum: WARNING: 3 of 6 listed files could not be read |
| | 472 | }}} |
| | 473 | * 旧sdb1の内容がmountされる |
| | 474 | 1. copy sdb2 to sdb1 with dd |
| | 475 | * sudo umount /dev/sdb![123] |
| | 476 | * sudo dd if=/dev/sdb of=/dev/sdb bs=512 count=6265350 seek=63 skip=2120580 & |
| | 477 | * seek=BLOCKS |
| | 478 | * skip BLOCKS obs-sized blocks at start of output |
| | 479 | * skip=BLOCKS |
| | 480 | * skip BLOCKS ibs-sized blocks at start of input |
| | 481 | * 6265350 = 8385929 - 2120580 + 1 |
| | 482 | 1. re-mount |
| | 483 | * sudo mount /dev/sdb1 /mnt/sdb2 |
| | 484 | * df -h |
| | 485 | {{{ |
| | 486 | /dev/sdb1 3.0G 3.0G 20K 100% /mnt/sdb2 |
| | 487 | }}} |
| | 488 | 1. verify data |
| | 489 | * sha1sum -c checksum.sha1 |
| | 490 | {{{ |
| | 491 | sha1sum: /mnt/sdb1/rand1.10M: No such file or directory |
| | 492 | /mnt/sdb1/rand1.10M: FAILED open or read |
| | 493 | sha1sum: /mnt/sdb1/rand1.900M: No such file or directory |
| | 494 | /mnt/sdb1/rand1.900M: FAILED open or read |
| | 495 | sha1sum: /mnt/sdb1/rand1.max: No such file or directory |
| | 496 | /mnt/sdb1/rand1.max: FAILED open or read |
| | 497 | /mnt/sdb2/rand2.10M: OK |
| | 498 | /mnt/sdb2/rand2.2900M: OK |
| | 499 | /mnt/sdb2/rand2.max: OK |
| | 500 | sha1sum: WARNING: 3 of 6 listed files could not be read |
| | 501 | }}} |
| | 502 | * 問題なく旧sdb2の内容になっている |
| | 503 | 1. resize xfs filesystem |
| | 504 | * sudo xfs_growfs /mnt/sdb2 |
| | 505 | {{{ |
| | 506 | meta-data=/dev/sdb1 isize=256 agcount=6, agsize=131532 blks |
| | 507 | = sectsz=512 attr=2 |
| | 508 | data = bsize=4096 blocks=783168, imaxpct=25 |
| | 509 | = sunit=0 swidth=0 blks |
| | 510 | naming =version 2 bsize=4096 ascii-ci=0 |
| | 511 | log =internal bsize=4096 blocks=2560, version=2 |
| | 512 | = sectsz=512 sunit=0 blks, lazy-count=1 |
| | 513 | realtime =none extsz=4096 blocks=0, rtextents=0 |
| | 514 | data blocks changed from 783168 to 1048233 |
| | 515 | }}} |
| | 516 | * df -h |
| | 517 | {{{ |
| | 518 | /dev/sdb1 4.0G 3.0G 1.1G 75% /mnt/sdb2 |
| | 519 | }}} |