[[PageOutline]] = NTFS = * [http://blogs.technet.com/b/extreme/archive/2008/02/19/windows-server-2008-self-healing-ntfs.aspx Windows Server 2008 - Self-healing NTFS - eXtreme. tech. - Site Home - TechNet Blogs] = mount with UUID = * [http://sourceforge.jp/magazine/08/09/18/0148228/2 UUIDを使ったディスクドライブ指定 - SourceForge.JP Magazine] * 「vol_id /dev/*」 でUUIDを取得できる * knoppix(debian)では「/lib/udev/vol_id」という変な場所にコマンドがあるので注意 = swapが複数あるときの優先順位 = * [http://www.linux.com/learn/docs/man/4244-swapon2 swapon.2] * Each swap area has a priority, either high or low. The default priority is low. Within the low-priority areas, newer areas are even lower priority than older areas. * All priorities set with swapflags are high-priority, higher than default. They may have any non-negative value chosen by the caller. Higher numbers mean higher priority. * Swap pages are allocated from areas in priority order, highest priority first. For areas with different priorities, a higher-priority area is exhausted before using a lower-priority area. If two or more areas have the same priority, and it is the highest priority available, pages are allocated on a round-robin basis between them. * [http://ubuntuforums.org/showthread.php?t=38613 SWAP Priority Setting - Ubuntu Forums] = mount disk image = * [http://lostman-worlds-end.blogspot.com/2009/05/blog-post_18.html (鬱とSEと)コンピュータ: ディスクイメージのマウント] * [http://ubuntuforums.org/showthread.php?t=711773 mount dd image of and entire disk - Ubuntu Forums] = testing xfs_growfs = * 結論 * diskの後方に向けて拡張するのは、開始セクタを変えずにパーティションを切り直し、リマウントしてxfs_growfsすればよい * diskの前方に向けて拡張するのは、パーティション内容をあらかじめdd等で移動する手間が必要 * データ総量が十分小さければ、前方にあらかじめ別のパーティションを切り、cpした上で古いパーティションを削除して、新しいパーティションを後方拡張する方が操作ミスを起こしにくいと思われる * LVMを使えばより単純になると思われる * ただし、LVM自体を扱う手間が増える(障害時の復旧手順が複雑化) == expanding /dev/sdb1 == 1. mkfs * sudo fdisk /dev/sdb -l {{{ Disk /dev/sdb: 4294 MB, 4294967296 bytes 255 heads, 63 sectors/track, 522 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/sdb doesn't contain a valid partition table }}} * sudo fdisk /dev/sdb {{{ Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-522, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522): +1G /dev/sdb1 1 132 1060258+ 83 Linux }}} * sudo mkfs.xfs /dev/sdb1 {{{ meta-data=/dev/sdb1 isize=256 agcount=4, agsize=66266 blks = sectsz=512 attr=2 data = bsize=4096 blocks=265064, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 }}} * sudo blkid /dev/sdb1 {{{ /dev/sdb1: UUID="e47dbfff-97ca-43b8-9a29-89700956a7dd" TYPE="xfs" }}} 1. mount * sudo mkdir /mnt/sdb1 * sudo mount /dev/sdb1 /mnt/sdb1 * df /mnt/sdb1/ -h {{{ /dev/sdb1 1.1G 4.2M 1022M 1% /mnt/sdb1 }}} 1. テストデータの用意 * sudo dd if=/dev/urandom of=/mnt/sdb1/rand.10M bs=1024 count=10240 * cp /mnt/sdb1/rand.10M . 1. remake partition * sudo umount /mnt/sdb1/ * sudo fdisk /dev/sdb {{{ Command (m for help): d Selected partition 1 Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-522, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522): Using default value 522 /dev/sdb1 1 522 4192933+ 83 Linux }}} * sudo blkid /dev/sdb1 {{{ /dev/sdb1: UUID="e47dbfff-97ca-43b8-9a29-89700956a7dd" TYPE="xfs" }}} * sudo mount /dev/sdb1 /mnt/sdb1 * df /mnt/sdb1/ -h {{{ /dev/sdb1 1.1G 15M 1012M 2% /mnt/sdb1 }}} * sha1sum -b rand.10M /mnt/sdb1/rand.10M {{{ 72d3a67ecd23e77bbc57eb959b945c6cbdae58e1 *rand.10M 72d3a67ecd23e77bbc57eb959b945c6cbdae58e1 */mnt/sdb1/rand.10M }}} 1. resize xfs filesystem * sudo xfs_growfs /mnt/sdb1/ {{{ meta-data=/dev/sdb1 isize=256 agcount=4, agsize=66266 blks = sectsz=512 attr=2 data = bsize=4096 blocks=265064, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 265064 to 1048233 }}} * df /mnt/sdb1/ -h {{{ Filesystem Size Used Avail Use% Mounted on /dev/sdb1 4.0G 15M 4.0G 1% /mnt/sdb1 }}} * sha1sum -b rand.10M /mnt/sdb1/rand.10M {{{ 72d3a67ecd23e77bbc57eb959b945c6cbdae58e1 *rand.10M 72d3a67ecd23e77bbc57eb959b945c6cbdae58e1 */mnt/sdb1/rand.10M }}} * 問題なく拡張された == test with 3 partitions == 1. make partitions * sudo fdisk /dev/sdb * snip * sudo fdisk /dev/sdb -l {{{ /dev/sdb1 1 132 1060258+ 83 Linux /dev/sdb2 133 394 2104515 83 Linux /dev/sdb3 395 522 1028160 83 Linux }}} 1. mkfs * sudo mkfs.xfs /dev/sdb1 {{{ meta-data=/dev/sdb1 isize=256 agcount=4, agsize=66266 blks = sectsz=512 attr=2 data = bsize=4096 blocks=265064, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 }}} * sudo mkfs.xfs /dev/sdb2 {{{ meta-data=/dev/sdb2 isize=256 agcount=4, agsize=131532 blks = sectsz=512 attr=2 data = bsize=4096 blocks=526128, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 }}} * sudo mkfs.xfs /dev/sdb3 {{{ meta-data=/dev/sdb3 isize=256 agcount=4, agsize=64260 blks = sectsz=512 attr=2 data = bsize=4096 blocks=257040, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 log =internal log bsize=4096 blocks=1200, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 }}} * sudo blkid /dev/sdb![123] {{{ /dev/sdb1: UUID="9065c3c2-ab3d-4460-978e-e37c88f31f5f" TYPE="xfs" /dev/sdb2: UUID="b9515b82-4d3c-457d-8d32-330cfea692df" TYPE="xfs" /dev/sdb3: UUID="17374506-2cb1-4451-a5a8-b15cb1410870" TYPE="xfs" }}} 1. mount * sudo mkdir /mnt/sdb1 * sudo mkdir /mnt/sdb2 * sudo mkdir /mnt/sdb3 * sudo mount /dev/sdb1 /mnt/sdb1 * sudo mount /dev/sdb2 /mnt/sdb2 * sudo mount /dev/sdb3 /mnt/sdb3 * df -h {{{ /dev/sdb1 1.1G 4.2M 1022M 1% /mnt/sdb1 /dev/sdb2 2.0G 4.2M 2.0G 1% /mnt/sdb2 /dev/sdb3 1000M 4.2M 996M 1% /mnt/sdb3 }}} 1. テストデータの用意 * sudo dd if=/dev/urandom of=/mnt/sdb1/rand1.10M bs=1024 count=10240 * sudo dd if=/dev/urandom of=/mnt/sdb2/rand2.10M bs=1024 count=10240 * sudo dd if=/dev/urandom of=/mnt/sdb3/rand3.10M bs=1024 count=10240 * sha1sum -b /mnt/sdb*/rand*.10M {{{ 11b2836d9c88f3890224f5d4250e2dd86ddca3e6 */mnt/sdb1/rand1.10M 3b2fb16c6416b5c6314c396f03275fd20ff8f24b */mnt/sdb2/rand2.10M 0fb674e54da58858fa1a825f724f5e0c782a8a04 */mnt/sdb3/rand3.10M }}} === /dev/sdb2をdisk後方に向けて拡張 === 1. remake partition * sudo umount /dev/sdb![123] * sudo fdisk /dev/sdb {{{ /dev/sdb1 1 132 1060258+ 83 Linux /dev/sdb2 133 394 2104515 83 Linux /dev/sdb3 395 522 1028160 83 Linux Command (m for help): d Partition number (1-4): 3 Command (m for help): d Partition number (1-4): 2 Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (133-522, default 133): Using default value 133 Last cylinder, +cylinders or +size{K,M,G} (133-522, default 522): Using default value 522 /dev/sdb1 1 132 1060258+ 83 Linux /dev/sdb2 133 522 3132675 83 Linux }}} 1. resize xfs filesystem * sudo mount /dev/sdb2 /mnt/sdb2 * df -h {{{ /dev/sdb2 2.0G 15M 2.0G 1% /mnt/sdb2 }}} * sha1sum -b /mnt/sdb*/rand*.10M {{{ 3b2fb16c6416b5c6314c396f03275fd20ff8f24b */mnt/sdb2/rand2.10M }}} * sudo xfs_growfs /mnt/sdb2/ {{{ meta-data=/dev/sdb2 isize=256 agcount=4, agsize=131532 blks = sectsz=512 attr=2 data = bsize=4096 blocks=526128, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 526128 to 783168 }}} * sudo blkid /dev/sdb![123] {{{ /dev/sdb1: UUID="9065c3c2-ab3d-4460-978e-e37c88f31f5f" TYPE="xfs" /dev/sdb2: UUID="b9515b82-4d3c-457d-8d32-330cfea692df" TYPE="xfs" }}} * df -h {{{ /dev/sdb2 3.0G 15M 3.0G 1% /mnt/sdb2 }}} * 問題なく拡張された === /dev/sdb2をdisk前方に向けて拡張 === ==== 適当でない手順 ==== ===== remake partition with name sdb1 ===== * sudo umount /dev/sdb![123] * sudo fdisk /dev/sdb {{{ /dev/sdb1 1 132 1060258+ 83 Linux /dev/sdb2 133 522 3132675 83 Linux Command (m for help): d Partition number (1-4): 1 Command (m for help): d Selected partition 2 Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-522, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522): Using default value 522 /dev/sdb1 1 522 4192933+ 83 Linux }}} * sudo mount /dev/sdb1 /mnt/sdb1 * sha1sum -b /mnt/sdb*/rand*.10M {{{ 11b2836d9c88f3890224f5d4250e2dd86ddca3e6 */mnt/sdb1/rand1.10M }}} * 当然だがsdb2ではなくsdb1がmountされてしまう ===== remake partition with name sdb2 ===== * sudo umount /dev/sdb![123] * sudo fdisk /dev/sdb {{{ /dev/sdb1 1 522 4192933+ 83 Linux Command (m for help): d Selected partition 1 Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (1-522, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522): Using default value 522 /dev/sdb2 1 522 4192933+ 83 Linux }}} * sudo mount /dev/sdb2 /mnt/sdb2 * sha1sum -b /mnt/sdb*/rand*.10M {{{ 11b2836d9c88f3890224f5d4250e2dd86ddca3e6 */mnt/sdb2/rand1.10M }}} * やはりsdb1の内容がmountされる ===== overwrite sdb1 with 0x00 and remake partition ===== * sudo umount /dev/sdb![123] * sudo fdisk /dev/sdb {{{ /dev/sdb2 1 522 4192933+ 83 Linux Command (m for help): d Selected partition 2 Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-522, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522): 132 Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (133-522, default 133): Using default value 133 Last cylinder, +cylinders or +size{K,M,G} (133-522, default 522): Using default value 522 /dev/sdb1 1 132 1060258+ 83 Linux /dev/sdb2 133 522 3132675 83 Linux }}} * sudo dd if=/dev/zero of=/dev/sdb1 bs=1024 count=10240 * sudo mount /dev/sdb1 /mnt/sdb1 -t xfs {{{ [ 8848.630996] XFS: bad magic number [ 8848.630996] XFS: SB validate failed }}} * sudo mount /dev/sdb2 /mnt/sdb2 * sha1sum -b /mnt/sdb*/rand*.10M {{{ 3b2fb16c6416b5c6314c396f03275fd20ff8f24b */mnt/sdb2/rand2.10M }}} * sudo umount /dev/sdb![123] * sudo fdisk /dev/sdb {{{ /dev/sdb1 1 132 1060258+ 83 Linux /dev/sdb2 133 522 3132675 83 Linux Command (m for help): d Partition number (1-4): 1 Command (m for help): d Selected partition 2 Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (1-522, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522): Using default value 522 /dev/sdb2 1 522 4192933+ 83 Linux }}} * sudo mount /dev/sdb2 /mnt/sdb2 -t xfs {{{ [ 9060.520973] XFS: bad magic number [ 9060.520973] XFS: SB validate failed }}} * 全くmount出来なくなる ==== 適当(と思われる)方法 ==== 1. mount * sudo fdisk -l /dev/sdb {{{ /dev/sdb1 1 132 1060258+ 83 Linux /dev/sdb2 133 522 3132675 83 Linux }}} * sudo fdisk -lu /dev/sdb {{{ /dev/sdb1 63 2120579 1060258+ 83 Linux /dev/sdb2 2120580 8385929 3132675 83 Linux }}} * sudo mount /dev/sdb1 /mnt/sdb1 * sudo mount /dev/sdb2 /mnt/sdb2 * df -h {{{ /dev/sdb1 1.1G 15M 1012M 2% /mnt/sdb1 /dev/sdb2 3.0G 15M 3.0G 1% /mnt/sdb2 }}} * sha1sum -b /mnt/sdb*/rand*.10M {{{ 11b2836d9c88f3890224f5d4250e2dd86ddca3e6 */mnt/sdb1/rand1.10M 3b2fb16c6416b5c6314c396f03275fd20ff8f24b */mnt/sdb2/rand2.10M }}} 1. テストデータの用意 * sudo dd if=/dev/urandom of=/mnt/sdb1/rand1.900M bs=512 count=921600 * sudo dd if=/dev/urandom of=/mnt/sdb2/rand2.2900M bs=1024 count=2969600 * sudo dd if=/dev/urandom of=/mnt/sdb1/rand1.max bs=512 * sudo dd if=/dev/urandom of=/mnt/sdb2/rand2.max bs=512 & * df -h {{{ /dev/sdb1 1.1G 1.1G 20K 100% /mnt/sdb1 /dev/sdb2 3.0G 3.0G 20K 100% /mnt/sdb2 }}} * sha1sum -b /mnt/sdb*/rand* > checksum.sha1 1. remake partition * sudo umount /dev/sdb![123] * sudo fdisk /dev/sdb {{{ Command (m for help): d Partition number (1-4): 1 Command (m for help): d Selected partition 2 Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-522, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522): Using default value 522 /dev/sdb1 1 522 4192933+ 83 Linux }}} * sudo mount /dev/sdb1 /mnt/sdb1 * sha1sum -c checksum.sha1 {{{ /mnt/sdb1/rand1.10M: OK /mnt/sdb1/rand1.900M: OK /mnt/sdb1/rand1.max: OK sha1sum: /mnt/sdb2/rand2.10M: No such file or directory /mnt/sdb2/rand2.10M: FAILED open or read sha1sum: /mnt/sdb2/rand2.2900M: No such file or directory /mnt/sdb2/rand2.2900M: FAILED open or read sha1sum: /mnt/sdb2/rand2.max: No such file or directory /mnt/sdb2/rand2.max: FAILED open or read sha1sum: WARNING: 3 of 6 listed files could not be read }}} * 旧sdb1の内容がmountされる 1. copy sdb2 to sdb1 with dd * sudo umount /dev/sdb![123] * sudo dd if=/dev/sdb of=/dev/sdb bs=512 count=6265350 seek=63 skip=2120580 & {{{ /dev/sdb1 63 2120579 1060258+ 83 Linux /dev/sdb2 2120580 8385929 3132675 83 Linux }}} * seek=BLOCKS * skip BLOCKS obs-sized blocks at start of output * skip=BLOCKS * skip BLOCKS ibs-sized blocks at start of input * 6265350 = 8385929 - 2120580 + 1 1. re-mount * sudo mount /dev/sdb1 /mnt/sdb2 * df -h {{{ /dev/sdb1 3.0G 3.0G 20K 100% /mnt/sdb2 }}} 1. verify data * sha1sum -c checksum.sha1 {{{ sha1sum: /mnt/sdb1/rand1.10M: No such file or directory /mnt/sdb1/rand1.10M: FAILED open or read sha1sum: /mnt/sdb1/rand1.900M: No such file or directory /mnt/sdb1/rand1.900M: FAILED open or read sha1sum: /mnt/sdb1/rand1.max: No such file or directory /mnt/sdb1/rand1.max: FAILED open or read /mnt/sdb2/rand2.10M: OK /mnt/sdb2/rand2.2900M: OK /mnt/sdb2/rand2.max: OK sha1sum: WARNING: 3 of 6 listed files could not be read }}} * 問題なく旧sdb2の内容になっている 1. resize xfs filesystem * sudo xfs_growfs /mnt/sdb2 {{{ meta-data=/dev/sdb1 isize=256 agcount=6, agsize=131532 blks = sectsz=512 attr=2 data = bsize=4096 blocks=783168, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 783168 to 1048233 }}} * df -h {{{ /dev/sdb1 4.0G 3.0G 1.1G 75% /mnt/sdb2 }}}