Guest User

lvm_resize

a guest
Aug 27th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 8.48 KB | None | 0 0
  1. [root@testvm ~]# lsblk
  2. NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
  3. sr0          11:0    1  4.3G  0 rom
  4. sda           8:0    0   20G  0 disk
  5. ├─sda2        8:2    0   19G  0 part
  6. │ ├─ol-swap 252:1    0    2G  0 lvm  [SWAP]
  7. │ └─ol-root 252:0    0   17G  0 lvm  /
  8. └─sda1        8:1    0    1G  0 part /boot
  9. [root@testvm ~]# for i in `ls /sys/class/scsi_host`; do echo "- - -" | sudo tee /sys/class/scsi_host/${i}/scan; done
  10. - - -
  11. - - -
  12. - - -
  13. [root@testvm ~]# lsblk
  14. NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
  15. sdb           8:16   0    5G  0 disk
  16. sr0          11:0    1  4.3G  0 rom
  17. sda           8:0    0   20G  0 disk
  18. ├─sda2        8:2    0   19G  0 part
  19. │ ├─ol-swap 252:1    0    2G  0 lvm  [SWAP]
  20. │ └─ol-root 252:0    0   17G  0 lvm  /
  21. └─sda1        8:1    0    1G  0 part /boot
  22. [root@testvm ~]# pvs
  23.   PV         VG Fmt  Attr PSize   PFree
  24.   /dev/sda2  ol lvm2 a--  <19.00g    0
  25. [root@testvm ~]# lvs
  26.   LV   VG Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  27.   root ol -wi-ao---- <17.00g
  28.   swap ol -wi-ao----   2.00g
  29. [root@testvm ~]# pvcreate /dev/sdb
  30.   Physical volume "/dev/sdb" successfully created.
  31. [root@testvm ~]# vgcreate test_vg /dev/sdb
  32.   Volume group "test_vg" successfully created
  33. [root@testvm ~]# lvcreate -l +100%FREE -n test_lv test_vg
  34.   Logical volume "test_lv" created.
  35. [root@testvm ~]# lvs
  36.   LV      VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  37.   root    ol      -wi-ao---- <17.00g
  38.   swap    ol      -wi-ao----   2.00g
  39.   test_lv test_vg -wi-a-----  <5.00g
  40. [root@testvm ~]# mkfs.xfs /dev/test_vg/test_lv
  41. meta-data=/dev/test_vg/test_lv   isize=256    agcount=4, agsize=327424 blks
  42.          =                       sectsz=512   attr=2, projid32bit=1
  43.          =                       crc=0        finobt=0, sparse=0, rmapbt=0, reflink=0
  44. data     =                       bsize=4096   blocks=1309696, imaxpct=25
  45.          =                       sunit=0      swidth=0 blks
  46. naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
  47. log      =internal log           bsize=4096   blocks=2560, version=2
  48.          =                       sectsz=512   sunit=0 blks, lazy-count=1
  49. realtime =none                   extsz=4096   blocks=0, rtextents=0
  50. [root@testvm ~]# df -h
  51. Filesystem           Size  Used Avail Use% Mounted on
  52. devtmpfs             474M     0  474M   0% /dev
  53. tmpfs                488M     0  488M   0% /dev/shm
  54. tmpfs                488M  6.8M  481M   2% /run
  55. tmpfs                488M     0  488M   0% /sys/fs/cgroup
  56. /dev/mapper/ol-root   17G  2.3G   15G  14% /
  57. /dev/sda1           1014M  221M  794M  22% /boot
  58. tmpfs                 98M     0   98M   0% /run/user/0
  59. [root@testvm ~]# mkdir /test_mount
  60. [root@testvm ~]# vim /etc/fstab
  61. [root@testvm ~]# ls /dev/mapper/
  62. control  ol-root  ol-swap  test_vg-test_lv
  63. [root@testvm ~]# ls /dev/mapper/test_vg-test_lv
  64. /dev/mapper/test_vg-test_lv
  65. [root@testvm ~]# ls /dev/mapper/
  66. control  ol-root  ol-swap  test_vg-test_lv
  67. [root@testvm ~]# vim /etc/fstab
  68. [root@testvm ~]# mount -a
  69. [root@testvm ~]# df -h
  70. Filesystem                   Size  Used Avail Use% Mounted on
  71. devtmpfs                     474M     0  474M   0% /dev
  72. tmpfs                        488M     0  488M   0% /dev/shm
  73. tmpfs                        488M  6.8M  481M   2% /run
  74. tmpfs                        488M     0  488M   0% /sys/fs/cgroup
  75. /dev/mapper/ol-root           17G  2.3G   15G  14% /
  76. /dev/sda1                   1014M  221M  794M  22% /boot
  77. tmpfs                         98M     0   98M   0% /run/user/0
  78. /dev/mapper/test_vg-test_lv  5.0G   33M  5.0G   1% /test_mount
  79. [root@testvm ~]# lsblk
  80. NAME              MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
  81. sdb                 8:16   0   10G  0 disk
  82. └─test_vg-test_lv 252:2    0    5G  0 lvm  /test_mount
  83. sr0                11:0    1  4.3G  0 rom
  84. sda                 8:0    0   20G  0 disk
  85. ├─sda2              8:2    0   19G  0 part
  86. │ ├─ol-swap       252:1    0    2G  0 lvm  [SWAP]
  87. │ └─ol-root       252:0    0   17G  0 lvm  /
  88. └─sda1              8:1    0    1G  0 part /boot
  89. [root@testvm ~]# pvs
  90.   PV         VG      Fmt  Attr PSize   PFree
  91.   /dev/sda2  ol      lvm2 a--  <19.00g    0
  92.   /dev/sdb   test_vg lvm2 a--   <5.00g    0
  93. [root@testvm ~]# lvs
  94.   LV      VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  95.   root    ol      -wi-ao---- <17.00g
  96.   swap    ol      -wi-ao----   2.00g
  97.   test_lv test_vg -wi-ao----  <5.00g
  98. [root@testvm ~]# vgs
  99.   VG      #PV #LV #SN Attr   VSize   VFree
  100.   ol        1   2   0 wz--n- <19.00g    0
  101.   test_vg   1   1   0 wz--n-  <5.00g    0
  102. [root@testvm ~]# for i in `ls /sys/class/scsi_host`; do echo "- - -" | sudo tee /sys/class/scsi_host/${i}/scan; done
  103. - - -
  104. - - -
  105. - - -
  106. [root@testvm ~]# lvs
  107.   LV      VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  108.   root    ol      -wi-ao---- <17.00g
  109.   swap    ol      -wi-ao----   2.00g
  110.   test_lv test_vg -wi-ao----  <5.00g
  111. [root@testvm ~]# vgs
  112.   VG      #PV #LV #SN Attr   VSize   VFree
  113.   ol        1   2   0 wz--n- <19.00g    0
  114.   test_vg   1   1   0 wz--n-  <5.00g    0
  115. [root@testvm ~]# pvresize /dev/sdb
  116.   Physical volume "/dev/sdb" changed
  117.   1 physical volume(s) resized or updated / 0 physical volume(s) not resized
  118. [root@testvm ~]# df -h
  119. Filesystem                   Size  Used Avail Use% Mounted on
  120. devtmpfs                     474M     0  474M   0% /dev
  121. tmpfs                        488M     0  488M   0% /dev/shm
  122. tmpfs                        488M  6.8M  481M   2% /run
  123. tmpfs                        488M     0  488M   0% /sys/fs/cgroup
  124. /dev/mapper/ol-root           17G  2.3G   15G  14% /
  125. /dev/mapper/test_vg-test_lv  5.0G   33M  5.0G   1% /test_mount
  126. /dev/sda1                   1014M  221M  794M  22% /boot
  127. tmpfs                         98M     0   98M   0% /run/user/0
  128. [root@testvm ~]# lvresize /dev/test_vg/test_lv -r -l +100%FREE
  129.   Size of logical volume test_vg/test_lv changed from <5.00 GiB (1279 extents) to <10.00 GiB (2559 extents).
  130.   Logical volume test_vg/test_lv successfully resized.
  131. meta-data=/dev/mapper/test_vg-test_lv isize=256    agcount=4, agsize=327424 blks
  132.          =                       sectsz=512   attr=2, projid32bit=1
  133.          =                       crc=0        finobt=0 spinodes=0 rmapbt=0
  134.          =                       reflink=0
  135. data     =                       bsize=4096   blocks=1309696, imaxpct=25
  136.          =                       sunit=0      swidth=0 blks
  137. naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
  138. log      =internal               bsize=4096   blocks=2560, version=2
  139.          =                       sectsz=512   sunit=0 blks, lazy-count=1
  140. realtime =none                   extsz=4096   blocks=0, rtextents=0
  141. data blocks changed from 1309696 to 2620416
  142. [root@testvm ~]# lvs
  143.   LV      VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  144.   root    ol      -wi-ao---- <17.00g
  145.   swap    ol      -wi-ao----   2.00g
  146.   test_lv test_vg -wi-ao---- <10.00g
  147. [root@testvm ~]# xfs_repair /dev/test_vg/test_lv
  148. xfs_repair: /dev/test_vg/test_lv contains a mounted filesystem
  149. xfs_repair: /dev/test_vg/test_lv contains a mounted and writable filesystem
  150.  
  151. fatal error -- couldn't initialize XFS library
  152. [root@testvm ~]# umount /test_mount/
  153. [root@testvm ~]# xfs_repair /dev/test_vg/test_lv
  154. Phase 1 - find and verify superblock...
  155. Phase 2 - using internal log
  156.        - zero log...
  157.        - scan filesystem freespace and inode maps...
  158.        - found root inode chunk
  159. Phase 3 - for each AG...
  160.        - scan and clear agi unlinked lists...
  161.        - process known inodes and perform inode discovery...
  162.        - agno = 0
  163.        - agno = 1
  164.        - agno = 2
  165.        - agno = 3
  166.        - agno = 4
  167.        - agno = 5
  168.        - agno = 6
  169.        - agno = 7
  170.        - agno = 8
  171.        - process newly discovered inodes...
  172. Phase 4 - check for duplicate blocks...
  173.        - setting up duplicate extent list...
  174.        - check for inodes claiming duplicate blocks...
  175.        - agno = 0
  176.        - agno = 1
  177.        - agno = 2
  178.        - agno = 3
  179.        - agno = 4
  180.        - agno = 5
  181.        - agno = 6
  182.        - agno = 7
  183.        - agno = 8
  184. Phase 5 - rebuild AG headers and trees...
  185.        - reset superblock...
  186. Phase 6 - check inode connectivity...
  187.        - resetting contents of realtime bitmap and summary inodes
  188.        - traversing filesystem ...
  189.        - traversal finished ...
  190.        - moving disconnected inodes to lost+found ...
  191. Phase 7 - verify and correct link counts...
  192. done
Advertisement
Add Comment
Please, Sign In to add comment