wiki:TipAndDoc/storage/filesystem

Version 2 (modified by mitty, 15 years ago) (diff)

--

testing xfs_growfs

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"
      
  2. 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
      
  3. テストデータの用意
    • sudo dd if=/dev/urandom of=/mnt/sdb1/rand.10M bs=1024 count=10240
    • cp /mnt/sdb1/rand.10M .
  4. 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
      
  5. 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
      
  2. 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"
      
  3. 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
      
  4. テストデータの用意
    • 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
      
  2. 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出来なくなる