---
# System prepended metadata

title: Untitled

---

### Mount NVME as loopback device on ubuntu 2210

#### Initial setup
- Clean install of ubuntu 2210 with two hard drives 



#### Setup loopback nvme device 

Check block devices

```bash
xcepta@ubuntu2210-arm:~$ lsblk
NAME                      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0                       7:0    0    59M  1 loop /snap/core20/1627
loop1                       7:1    0  41.5M  1 loop /snap/snapd/17339
loop2                       7:2    0 131.3M  1 loop /snap/lxd/23687
sr0                        11:0    1  1024M  0 rom
nvme0n1                   259:0    0    20G  0 disk
├─nvme0n1p1               259:1    0   953M  0 part /boot/efi
├─nvme0n1p2               259:2    0   1.8G  0 part /boot
└─nvme0n1p3               259:3    0  17.3G  0 part
  └─ubuntu--vg-ubuntu--lv 253:0    0    10G  0 lvm  /
nvme0n2                   259:4    0    10G  0 disk
```

Check Volume Groups

```bash
root@ubuntu2210-arm:/home/xcepta# vgdisplay
  --- Volume group ---
  VG Name               vg0
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <10.00 GiB
  PE Size               4.00 MiB
  Total PE              2559
  Alloc PE / Size       0 / 0
  Free  PE / Size       2559 / <10.00 GiB
  VG UUID               DOBev8-doGP-3wA4-LqTj-Zc9M-AK6P-zod4np

  --- Volume group ---
  VG Name               ubuntu-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <17.32 GiB
  PE Size               4.00 MiB
  Total PE              4433
  Alloc PE / Size       2560 / 10.00 GiB
  Free  PE / Size       1873 / <7.32 GiB
  VG UUID               h2CzeJ-AkVS-w5qt-7v1n-YlUQ-1qPX-DyYdIo
```

Check Logical Volumes

```bash
root@ubuntu2210-arm:/home/xcepta# lvdisplay
  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/ubuntu-lv
  LV Name                ubuntu-lv
  VG Name                ubuntu-vg
  LV UUID                63a9au-xni9-SWgy-aWm7-OfvD-ptbh-BZjX7d
  LV Write Access        read/write
  LV Creation host, time ubuntu-server, 2023-03-29 20:54:19 +0000
  LV Status              available
  # open                 1
  LV Size                10.00 GiB
  Current LE             2560
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
```

Create new logical volume in volume group `vg0`

```bash
root@ubuntu2210-arm:/home/xcepta# lvcreate -l 100%FREE vg0
  Logical volume "lvol0" created.
```

Check logical volumes 

```bash
root@ubuntu2210-arm:/home/xcepta# lvdisplay
  --- Logical volume ---
  LV Path                /dev/vg0/lvol0
  LV Name                lvol0
  VG Name                vg0
  LV UUID                Yqm64V-odBf-TTJ8-q8Ps-WocB-daQK-CgJV26
  LV Write Access        read/write
  LV Creation host, time ubuntu2210-arm, 2023-03-29 21:07:32 +0000
  LV Status              available
  # open                 0
  LV Size                <10.00 GiB
  Current LE             2559
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/ubuntu-lv
  LV Name                ubuntu-lv
  VG Name                ubuntu-vg
  LV UUID                63a9au-xni9-SWgy-aWm7-OfvD-ptbh-BZjX7d
  LV Write Access        read/write
  LV Creation host, time ubuntu-server, 2023-03-29 20:54:19 +0000
  LV Status              available
  # open                 1
  LV Size                10.00 GiB
  Current LE             2560
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
```

Check block devices

```bash
root@ubuntu2210-arm:/home/xcepta# lsblk
NAME                      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0                       7:0    0    59M  1 loop /snap/core20/1627
loop1                       7:1    0  41.5M  1 loop /snap/snapd/17339
loop2                       7:2    0 131.3M  1 loop /snap/lxd/23687
sr0                        11:0    1  1024M  0 rom
nvme0n1                   259:0    0    20G  0 disk
├─nvme0n1p1               259:1    0   953M  0 part /boot/efi
├─nvme0n1p2               259:2    0   1.8G  0 part /boot
└─nvme0n1p3               259:3    0  17.3G  0 part
  └─ubuntu--vg-ubuntu--lv 253:0    0    10G  0 lvm  /
nvme0n2                   259:4    0    10G  0 disk
└─vg0-lvol0               253:1    0    10G  0 lvm
```

Setup loopback device

```bash
root@ubuntu2210-arm:/home/xcepta# losetup /dev/loop10 /dev/vg0/lvol0
```

#### Create filesystem and mount device

Create filesystem

```bash
root@ubuntu2210-arm:/home/xcepta# mkfs.xfs /dev/loop10
meta-data=/dev/loop10            isize=512    agcount=4, agsize=655104 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1    bigtime=1 inobtcount=1
data     =                       bsize=4096   blocks=2620416, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=16384, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
```

Create mount point

```bash
root@ubuntu2210-arm:/home/xcepta# mkdir /mnt/loop_mount
```

Mount device 
```bash
root@ubuntu2210-arm:/home/xcepta# mount /dev/loop10 /mnt/loop_mount
```

Check mountpoints 

```bash
root@ubuntu2210-arm:/home/xcepta# lsblk
NAME                      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0                       7:0    0    59M  1 loop /snap/core20/1627
loop1                       7:1    0  41.5M  1 loop /snap/snapd/17339
loop2                       7:2    0 131.3M  1 loop /snap/lxd/23687
loop10                      7:10   0    10G  0 loop /mnt/loop_mount
sr0                        11:0    1  1024M  0 rom
nvme0n1                   259:0    0    20G  0 disk
├─nvme0n1p1               259:1    0   953M  0 part /boot/efi
├─nvme0n1p2               259:2    0   1.8G  0 part /boot
└─nvme0n1p3               259:3    0  17.3G  0 part
  └─ubuntu--vg-ubuntu--lv 253:0    0    10G  0 lvm  /
nvme0n2                   259:4    0    10G  0 disk
└─vg0-lvol0               253:1    0    10G  0 lvm
```
