rootfsのLVM2スナップショットを削除できません。

rootfsのLVM2スナップショットを削除できません。

私のサーバーをDebian JessieからDebian Stretchにアップグレードする前に、rootfs()のLVM2スナップショットを作成しました/

さまざまなツールに基づいて、現在私のストレージの外観は次のとおりです。/dev/intraid/rootこれは私の元のrootfs、/dev/intraid/root-snapshotスナップショットです:

$ sudo lvdisplay
  --- Logical volume ---
  LV Path                /dev/intraid/root
  LV Name                root
  VG Name                intraid
  LV UUID                0d5hwZ-07Lv-3Yxb-cff3-95za-Rrcx-9y6eQv
  LV Write Access        read/write
  LV Creation host, time newsrv, 2015-05-26 09:32:04 +0800
  LV snapshot status     source of
                         root-snapshot [active]
  LV Status              available
  # open                 1
  LV Size                3.18 TiB
  Current LE             834465
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Logical volume ---
  LV Path                /dev/intraid/root-snapshot
  LV Name                root-snapshot
  VG Name                intraid
  LV UUID                A9sjTI-gcV8-WTLi-wZ0I-J7O6-4hdc-AQSxZj
  LV Write Access        read/write
  LV Creation host, time newsrv, 2018-05-04 19:25:12 +0800
  LV snapshot status     active destination for root
  LV Status              available
  # open                 1
  LV Size                3.18 TiB
  Current LE             834465
  COW-table size         180.00 GiB
  COW-table LE           46080
  Allocated to snapshot  57.08%
  Snapshot chunk size    4.00 KiB
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3


$ lsblk -t
sdf                                      0   4096       0    4096     512    1 cfq       128  128    0B
├─sdf1                                   0   4096       0    4096     512    1 cfq       128  128    0B
├─sdf2                                   0   4096       0    4096     512    1 cfq       128  128    0B
│ └─md0                                  0   4096       0    4096     512    1           128  128    0B
│   ├─intraid-root-real                  0   4096       0    4096     512    1           128  128    0B
│   │ ├─intraid-root                     0   4096       0    4096     512    1           128  128    0B
│   │ └─intraid-root--snapshot           0   4096       0    4096     512    1           128  128    0B
│   └─intraid-root--snapshot-cow         0   4096       0    4096     512    1           128  128    0B
│     └─intraid-root--snapshot           0   4096       0    4096     512    1           128  128    0B
└─sdf3                                   0   4096       0    4096     512    1 cfq       128  128    0B
sdg                                      0   4096       0    4096     512    1 cfq       128  128    0B
├─sdg1                                   0   4096       0    4096     512    1 cfq       128  128    0B
├─sdg2                                   0   4096       0    4096     512    1 cfq       128  128    0B
│ └─md0                                  0   4096       0    4096     512    1           128  128    0B
│   ├─intraid-root-real                  0   4096       0    4096     512    1           128  128    0B
│   │ ├─intraid-root                     0   4096       0    4096     512    1           128  128    0B
│   │ └─intraid-root--snapshot           0   4096       0    4096     512    1           128  128    0B
│   └─intraid-root--snapshot-cow         0   4096       0    4096     512    1           128  128    0B
│     └─intraid-root--snapshot           0   4096       0    4096     512    1           128  128    0B
└─sdg3                                   0   4096       0    4096     512    1 cfq       128  128    0B

$ sudo blkid
/dev/sdf1: UUID="C622-1FAD" TYPE="vfat" PARTUUID="3d63a1ce-dd19-4396-9f9c-7894a4e9b256"
/dev/sdf2: UUID="3eb2349d-df83-c9a5-7151-9bdcb40449f8" UUID_SUB="b04a81da-8279-8ade-130d-65478f415085" LABEL="newsrv:0" TYPE="linux_raid_member" PARTUUID="607b2070-1de3-4e58-89f4-401d3144d52c"
/dev/sdf3: UUID="9b8fb3d2-4bb3-4a48-8b26-23af503b9d28" TYPE="swap" PARTUUID="8778cdc1-1fd8-4af0-b7a0-9dbca0d137fa"
/dev/sdg1: UUID="C623-571D" TYPE="vfat" PARTUUID="56f5dc2f-0562-4590-a54d-8c705dfef79f"
/dev/sdg2: UUID="3eb2349d-df83-c9a5-7151-9bdcb40449f8" UUID_SUB="8370e4ce-6b8b-5cdf-1043-60e748758898" LABEL="newsrv:0" TYPE="linux_raid_member" PARTUUID="ee82035a-6e8a-4bb8-9828-336ee85d3afd"
/dev/sdg3: UUID="a3062d00-d91b-490d-b366-7cfbfb42c09d" TYPE="swap" PARTUUID="fb6b3047-bfd4-4502-97ba-1a58197e75f4"
/dev/md0: UUID="44gLpv-engQ-I0KW-VJ0e-2Q6Z-OCeI-m0HSWq" TYPE="LVM2_member"
/dev/mapper/intraid-root: UUID="a96458d1-87d6-4cf6-a004-7b8ceb3ae31f" TYPE="xfs"
/dev/mapper/intraid-root--snapshot: UUID="a96458d1-87d6-4cf6-a004-7b8ceb3ae31f" TYPE="xfs"

$ mount
/dev/mapper/intraid-root on / type xfs (rw,relatime,attr2,inode64,noquota)
/dev/mapper/intraid-root on /srv/matlab_chroot/usr/local/MATLAB type xfs (rw,relatime,attr2,inode64,noquota)
/dev/mapper/intraid-root on /srv/matlab_chroot/shared_home type xfs (rw,relatime,attr2,inode64,noquota)
/dev/sdf1 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)
/dev/mapper/intraid-root on /srv/matlab_chroot/mnt/nethome-new type xfs (rw,relatime,attr2,inode64,noquota)

$ sudo lsof /dev/mapper/intraid-root--snapshot
COMMAND      PID USER   FD   TYPE DEVICE      SIZE/OFF NODE NAME
grub-moun 218357 root    3r   BLK  253,3 0x32ee7fe0000 2115 /dev/mapper/../dm-3

$ sudo lsof /dev/intraid/root-snapshot
COMMAND      PID USER   FD   TYPE DEVICE      SIZE/OFF NODE NAME
grub-moun 218357 root    3r   BLK  253,3 0x32ee7fe0000 2115 /dev/intraid/../dm-3

$ sudo lsof /dev/mapper/intraid-root--snapshot-cow

$ sudo lsof /dev/mapper/intraid-root-real

$ findmnt
TARGET                                SOURCE                           FSTYPE          OPTIONS
/                                     /dev/mapper/intraid-root         xfs             rw,relatime,attr2,inode64,noquota
├─/srv/matlab_chroot/usr/local/MATLAB /dev/mapper/intraid-root[/usr/local/MATLAB]
│                                                                      xfs             rw,relatime,attr2,inode64,noquota
├─/srv/matlab_chroot/shared_home      /dev/mapper/intraid-root[/home]  xfs             rw,relatime,attr2,inode64,noquota
├─/srv/matlab_chroot/mnt/nethome-new  /dev/mapper/intraid-root[/mnt/nethome-new]

スナップショットはの出力に基づいてインストールされませんmount

ただし、スナップショットを削除しようとすると、次のメッセージが表示されます。

$ sudo lvremove -f intraid/root-snapshot
  Logical volume intraid/root-snapshot in use.

あきらめるにはどうすればいいですか?

ベストアンサー1

コマンドmount出力が明らかに切り捨てられました。残念ながら、質問に関連する内容を切り出したようです。

プロセス218357がまだスナップショットにアクセスしているようです。一部のコマンド名で判断すると、grub-mountFUSEおよびGRUB用のドライバを使用してファイルシステムにアクセスするため、「RAWディスクデバイス」でLVデバイスに直接アクセスします。

同じ理由で、通常のマウントほど目立たない。先ほどインストールしましたが、次のよう/dev/sda1grub-mountなります。

# grub-mount /dev/sda1 /mnt
# mount
[...other mount points omitted...]
grub-mount on /mnt type fuse.grub-mount (rw,nosuid,nodev,relatime,user_id=0,group_id=0)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)

grub-mountedファイルシステムはtypeとして表示され、このfuse.grub-mount行は実際にマウントされたディスクデバイスを表しません。fusectl on /sys/fs/fuse/connectionsFUSE ベースのマウント項目を使用する場合は、2 番目のマウント項目が常に存在します。これはFUSEインターフェースの一部です。

grub-mountしたがって、スナップショットデバイスを開いたままにしているように見えるので、最初に見つけて削除します。マウント解除後に最初に試したコマンドを使用して、スナップショットを正常に削除できます。

おすすめ記事