Good morning,
I'm having a problem with creating and using a loop device interface, in particular using internal partition.
I'm using Yocto to create an image. I've already done this on a separate machine, and I moved to proxmox machine recently reproducing the same steps.
I'm using a Ubuntu 22.04 container. VE 8.1.4. Evething updated.
My steps are as follows:
I created my image using dd
Since by deafult Proxmox does not create loop device interface I manually created the /dev/loop0
Than I attach the .img to the device, and I check if image is correctly associated.
Everything seems ok as for now
Than I launched the script the vendor provide to create the extended .img ready to flash on SD.
It correctly create a partition, that is showed on fdisk -l command (showed below).
The script fails on the formatting step:
The partition appears to exist, but in reality write commands don't seem to find it.
I've read a few threads here on the site where it seems like the kernel isn't being updated with the new partition table. But that's not the case, and I've already tried every piece of advice I could find and none of it seems to work.
Thanks for any help,
Bests
UPDATE 1
Further investigation show kernel module seems missing.
On my prev ubuntu machine modprobe show the module as built-in.
On container the modprobe command:
On the host instead:
UPDATE 2
I now noticed that when I create a partition like /dev/loop0p1, this shows up in the host machine, as it should, but is not reflected in the container. This is the piece I am missing. I could not map the partition in the container conf, since it does not exist when container is started.
I'm having a problem with creating and using a loop device interface, in particular using internal partition.
I'm using Yocto to create an image. I've already done this on a separate machine, and I moved to proxmox machine recently reproducing the same steps.
I'm using a Ubuntu 22.04 container. VE 8.1.4. Evething updated.
My steps are as follows:
I created my image using dd
Bash:
dd if=/dev/zero of=image.img bs=1M count=15000
Since by deafult Proxmox does not create loop device interface I manually created the /dev/loop0
Bash:
sudo mknod -m 0660 /dev/loop0 b 7 8
Than I attach the .img to the device, and I check if image is correctly associated.
Everything seems ok as for now
Bash:
sudo losetup -Pf image.img
losetup -a | grep image.img
Than I launched the script the vendor provide to create the extended .img ready to flash on SD.
It correctly create a partition, that is showed on fdisk -l command (showed below).
Bash:
sfdisk --force -uS ${node} &> /dev/null << EOF
${PART1_START},${PART1_SIZE},83
EOF
fdisk -l
Creating new partitions
16384
15155200
Disk /dev/loop0: 14.65 GiB, 15728640000 bytes, 30720000 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: 0x6cc5f676
Device Boot Start End Sectors Size Id Type
/dev/loop0p1 16384 15171583 15155200 7.2G 83 Linux
The script fails on the formatting step:
Bash:
mkfs.ext4 ${node}${part}1 -L rootfs
Formatting partitions
mke2fs 1.46.5 (30-Dec-2021)
The file /dev/loop0p1 does not exist and no size was specified.
The partition appears to exist, but in reality write commands don't seem to find it.
I've read a few threads here on the site where it seems like the kernel isn't being updated with the new partition table. But that's not the case, and I've already tried every piece of advice I could find and none of it seems to work.
Thanks for any help,
Bests
UPDATE 1
Further investigation show kernel module seems missing.
On my prev ubuntu machine modprobe show the module as built-in.
On container the modprobe command:
Bash:
sudo modprobe loop
modprobe: FATAL: Module loop not found in directory /lib/modules/6.5.11-8-pve
On the host instead:
Bash:
root@yocto:/etc/pve/lxc# modinfo loop
name: loop
filename: (builtin)
alias: devname:loop-control
alias: char-major-10-237
alias: block-major-7-*
license: GPL
file: drivers/block/loop
parm: max_loop:Maximum number of loop devices
parm: max_part:Maximum number of partitions per loop device (int)
parm: hw_queue_depth:Queue depth for each hardware queue. Default: 128
UPDATE 2
I now noticed that when I create a partition like /dev/loop0p1, this shows up in the host machine, as it should, but is not reflected in the container. This is the piece I am missing. I could not map the partition in the container conf, since it does not exist when container is started.
Last edited: