df -h 結果は VGdisplay/LVdisplay とは異なります。

df -h 結果は VGdisplay/LVdisplay とは異なります。

ディスク容量が不要になったため、仮想マシンに追加したディスクを削除しようとしています。しかし、VMのVGは、そこで利用可能なほとんどすべてのデータを使用しているようです。

しかし、zoneminder - vgのサイズを1.5TBから6Gに調整しましたが、resiz2fslvdisplayではそうではありません。

これはいくつかのコマンドの出力です。

root@zoneminder:~# lvs
  LV     VG            Attr       LSize   Pool Origin Data%  Meta%  Move Log  Cpy%Sync Convert
  root   zoneminder-vg -wi-ao----   1.52t
  swap_1 zoneminder-vg -wi-ao---- 976.00m
root@zoneminder:~# pvs
  PV         VG            Fmt  Attr PSize   PFree
  /dev/sda3  zoneminder-vg lvm2 a--  900.00g     0
  /dev/sda5  zoneminder-vg lvm2 a--  699.52g 46.57g
root@zoneminder:~# vgs
  VG            #PV #LV #SN Attr   VSize VFree
  zoneminder-vg   2   2   0 wz--n- 1.56t 46.57g

DF-H

Filesystem                       Size  Used Avail Use% Mounted on
udev                             7.9G     0  7.9G   0% /dev
tmpfs                            1.6G  8.9M  1.6G   1% /run
/dev/mapper/zoneminder--vg-root  5.6G  4.9G  431M  92% /
tmpfs                            7.9G     0  7.9G   0% /dev/shm
tmpfs                            5.0M     0  5.0M   0% /run/lock
tmpfs                            7.9G     0  7.9G   0% /sys/fs/cgroup
/dev/sda1                        472M  108M  340M  25% /boot
tmpfs                            1.6G     0  1.6G   0% /run/user/1000

太陽電池ディスプレイ

  --- Physical volume ---
  PV Name               /dev/sda5
  VG Name               zoneminder-vg
  PV Size               699.52 GiB / not usable 2.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              179077
  Free PE               11922
  Allocated PE          167155
  PV UUID               SVGqoc-SQ42-tDzp-Qc7H-n90f-1g9n-x0eLWe

  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               zoneminder-vg
  PV Size               900.00 GiB / not usable 0
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              230400
  Free PE               0
  Allocated PE          230400
  PV UUID               Cdanv0-2pLJ-Yp2n-3zsl-JvjH-72QS-Ciwhaj

LVディスプレイ

  --- Logical volume ---
  LV Path                /dev/zoneminder-vg/root
  LV Name                root
  VG Name                zoneminder-vg
  LV UUID                poThtY-v96W-e2Ai-nan7-ckqn-aeBm-T0Kqji
  LV Write Access        read/write
  LV Creation host, time zoneminder, 2018-08-01 22:22:13 +0200
  LV Status              available
  # open                 1
  LV Size                1.52 TiB
  Current LE             397311
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

  --- Logical volume ---
  LV Path                /dev/zoneminder-vg/swap_1
  LV Name                swap_1
  VG Name                zoneminder-vg
  LV UUID                SXQ36r-5Kum-Z3Wa-m9DE-CBVb-h9Wx-kmctKT
  LV Write Access        read/write
  LV Creation host, time zoneminder, 2018-08-01 22:22:13 +0200
  LV Status              available
  # open                 2
  LV Size                976.00 MiB
  Current LE             244
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:1

グラフィックディスプレイ

  --- Volume group ---
  VG Name               zoneminder-vg
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               1.56 TiB
  PE Size               4.00 MiB
  Total PE              409477

  Alloc PE / Size       397555 / 1.52 TiB
  Free  PE / Size       11922 / 46.57 GiB

  VG UUID               lTo8U0-dIL9-Yye3-RVYk-rJu6-w6WQ-zIpL8f

LVMのデータに影響を与えずに/ dev / sda3を削除するにはどうすればよいですか?その後、VGroupを100Gに再構築するか、別の方法で再構築しますか?

fdisk -l

Disk /dev/sda: 1.6 TiB, 1717986918400 bytes, 3355443200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x21880f4a

Device     Boot      Start        End    Sectors   Size Id Type
/dev/sda1  *          2048     999423     997376   487M 83 Linux
/dev/sda2          1001470 1468004351 1467002882 699.5G  5 Extended
/dev/sda3       1468004352 3355443199 1887438848   900G 8e Linux LVM
/dev/sda5          1001472 1468004351 1467002880 699.5G 8e Linux LVM

Partition table entries are not in disk order.


Disk /dev/mapper/zoneminder--vg-root: 1.5 TiB, 1666443116544 bytes, 3254771712 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/zoneminder--vg-swap_1: 976 MiB, 1023410176 bytes, 1998848 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
root@zoneminder:~#

アップデート#1:

@telcoM:親切で詳細な回答に感謝します。
言及したすべてが完了しました。また、データはもちろんディスク全体に分散しているため、データを物理的に移動する必要があるという事実も発見しました。

root@zoneminder:~# pvresize --setphysicalvolume 101G -v /dev/sda5
    Using physical volume(s) on command line.
    Archiving volume group "zoneminder-vg" metadata (seqno 9).
    /dev/sda5: Pretending size is 211812352 not 1467002880 sectors.
    Resizing volume "/dev/sda5" to 211812352 sectors.
    Resizing physical volume /dev/sda5 from 0 to 25855 extents.
  /dev/sda5: cannot resize to 25855 extents as later ones are allocated.
  0 physical volume(s) resized / 1 physical volume(s) not resized


root@zoneminder:~# pvs -v --segments /dev/sda5
    Using physical volume(s) on command line.
    Wiping cache of LVM-capable devices
  PV         VG            Fmt  Attr PSize   PFree   Start  SSize  LV     Start Type   PE Ranges
  /dev/sda5  zoneminder-vg lvm2 a--  699.52g 598.57g      0  25600 root       0 linear /dev/sda5:0-25599
  /dev/sda5  zoneminder-vg lvm2 a--  699.52g 598.57g  25600 141311            0 free
  /dev/sda5  zoneminder-vg lvm2 a--  699.52g 598.57g 166911    244 swap_1     0 linear /dev/sda5:166911-167154
  /dev/sda5  zoneminder-vg lvm2 a--  699.52g 598.57g 167155  11922            0 free

root@zoneminder:~# sudo pvmove --alloc anywhere /dev/sda5:166911-167154 /dev/sda5:25601-25845
  /dev/sda5: Moved: 0.4%
  /dev/sda5: Moved: 100.0%

root@zoneminder:~# pvresize --setphysicalvolume 101G -v /dev/sda5
    Using physical volume(s) on command line.
    Archiving volume group "zoneminder-vg" metadata (seqno 12).
    /dev/sda5: Pretending size is 211812352 not 1467002880 sectors.
    Resizing volume "/dev/sda5" to 211812352 sectors.
    Resizing physical volume /dev/sda5 from 0 to 25855 extents.
    Updating physical volume "/dev/sda5"
    Creating volume group backup "/etc/lvm/backup/zoneminder-vg" (seqno 13).
  Physical volume "/dev/sda5" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized

root@zoneminder:~# pvs -v --segments /dev/sda5
    Using physical volume(s) on command line.
    Wiping cache of LVM-capable devices
  PV         VG            Fmt  Attr PSize   PFree  Start SSize LV     Start Type   PE Ranges
  /dev/sda5  zoneminder-vg lvm2 a--  101.00g 44.00m     0 25600 root       0 linear /dev/sda5:0-25599
  /dev/sda5  zoneminder-vg lvm2 a--  101.00g 44.00m 25600     1            0 free
  /dev/sda5  zoneminder-vg lvm2 a--  101.00g 44.00m 25601   244 swap_1     0 linear /dev/sda5:25601-25844
  /dev/sda5  zoneminder-vg lvm2 a--  101.00g 44.00m 25845    10            0 free

実際に私が達成したいのは次のとおりです(投稿#18)。 https://communities.vmware.com/message/2723540#2723540

/dev/sda3今はまだ削除していないところに閉じ込められていますが、まだfdisk -lサイズが/dev/sda5700Gであることを確認しています。

root@zoneminder:~# fdisk -l
Disk /dev/sda: 1.6 TiB, 1717986918400 bytes, 3355443200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x21880f4a

Device     Boot      Start        End    Sectors   Size Id Type
/dev/sda1  *          2048     999423     997376   487M 83 Linux
/dev/sda2          1001470 1468004351 1467002882 699.5G  5 Extended
/dev/sda3       1468004352 3355443199 1887438848   900G 8e Linux LVM
/dev/sda5          1001472 1468004351 1467002880 699.5G 8e Linux LVM

Partition table entries are not in disk order.


Disk /dev/mapper/zoneminder--vg-root: 100 GiB, 107374182400 bytes, 209715200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/zoneminder--vg-swap_1: 976 MiB, 1023410176 bytes, 1998848 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

アップデート#2:

LIVE-CD管理では、GPARTEDとPARTEDを使用してディスクを取り出し、LV(M)/dev/sda2でもサイズを変更しました。/dev/sda5

ESXiでスナップショットを撮ったので、すべての手順を再実行する必要があります。 vmdkのネストが少し迷惑だからです。

元の仮想マシン(1.6TB)をコピーするのに時間がかかります。その後、他の人が後で使用できるようにすべての手順を完全にダンプします。

ベストアンサー1

いいですね。正常に縮小しました。ファイルシステムルートLV内で。

次のステップは、ファイルシステムの新しいサイズに合わせてLVを縮小することです。誤って切りすぎると、より深刻な問題が発生する可能性があるため、安全のために少し余裕を持っておくことをお勧めします。

ファイルシステムの縮小操作は常に拡張よりも危険であり、特に慣れていない場合はさらにそうです。したがって、問題が発生した場合に備えて必要なものをすべてバックアップしてください。

次に、次のようにtune2fs -lファイルシステムから正しいブロック数を取得します。

tune2fs -l /dev/mapper/zoneminder--vg-root | grep "Block "
Block count:          NNNNNNNNN
Block size:           XXXX

これらの2つの数を掛けてファイルシステムの正確なサイズを取得し、1024で割って2進数キロバイトを取得し、1024で割って2進数メガバイトを取得します。丸めエラーを回避するには、1つを追加してください。

expr NNNNNNNNN \* XXXX / 1024 / 1024 + 1
SSSSSS

今LVを縮小します。

lvreduce -L SSSSSS /dev/mapper/zoneminder--vg-root

これで、Zoneminder VGに十分な空き容量が必要です。完全に使用されていないことをpvs確認するには、以下を使用してください。/dev/sda3

pvs出力でPFree値がPSizeと等しくない場合は、/dev/sda3ルートLVの一部がそのPVにまだ存在するため、その部分を別の場所に移動する必要があります。pvmoveこれは簡単に行うことができます。今完全に無料であれば、/dev/sda3このステップをスキップできます。

pvmove /dev/sda3

これは、本質的に「sda3すべてのLVデータを同じVGに属する別のPVに移動して空になる」ことを意味します。

pvmove新しい場所に移動したいデータをミラーリングし、古い場所から「ミラーを削除する」ように動作します。したがって、pvmoveシステムのクラッシュによってダウンタイムが発生しても、結果は致命的ではありません。もともとあったpvmove場所で続行するには、議論なしに実行してください。

今、sda3PVは完全に空でなければなりません。 VGから削除します。

vgreduce zoneminder-vg /dev/sda3

この時は/dev/sda3独立して完全無料のLVM PVになります。必要に応じてPVIDを消去できます。

pvremove /dev/sda3

これで、/dev/sda3任意の方法でパーティションを自由に再利用できます。 (パーティションを上書きするタスクを実行したい場合は、このpvremoveコマンドは必ずしも必要ではありません。)

ルートLVを100GiBに拡張するには、次の手順に従います。

lvextend -L 100G /dev/mapper/zoneminder--vg-root
resize2fs /dev/mapper/zoneminder--vg-root

これで終わりました。

ここでは、「ファイルシステムのマウント解除」または「システムの再起動」とは言いませんでした。必要ありません。

おすすめ記事