1.分区
1.dd if=/dev/zero of=loop.img bs=1M count=200
2.losetup -a 当前正在使用的loop设备
losetup -f 可用的loop设备
losetup -d /dev/loop0 可删除设备
[root@oc7067507274 ~]# losetup -f
/dev/loop0
3.losetup /dev/loop0 /root/loop.img
[root@oc7067507274 ~]# losetup /dev/loop0 /root/loop.img
[root@oc7067507274 ~]# losetup -a
/dev/loop0: [64770]:11927883 (/root/loop.img)
4.
Disk /dev/loop0: 209 MB, 209715200 bytes, 409600 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 label type: dos
Disk identifier: 0x0c19f915
Device Boot Start End Blocks Id System
/dev/loop0p1 2048 206847 102400 8e Linux LVM
/dev/loop0p2 206848 391167 92160 8e Linux LVM
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
5.
[root@oc7067507274 ~]# partprobe /dev/loop0
[root@oc7067507274 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 200M 0 loop
├─loop0p1 259:3 0 100M 0 loop
└─loop0p2 259:4 0 90M 0 loop
nvme0n1 259:0 0 238.5G 0 disk
├─nvme0n1p1 259:1 0 1000M 0 part /boot
└─nvme0n1p2 259:2 0 237.5G 0 part
└─luks-a8057c53-b197-4918-a975-0656396b0c43 253:0 0 237.5G 0 crypt
├─vg_oc3573808223-lv_swap 253:1 0 12G 0 lvm [SWAP]
└─vg_oc3573808223-lv_root 253:2 0 225.5G 0 lvm /
2.pvcreate
6.[root@oc7067507274 ~]# pvcreate /dev/loop0p1 /dev/loop0p2
Physical volume "/dev/loop0p1" successfully created.
Physical volume "/dev/loop0p2" successfully created.