[CLOSED] How to work with file .img containing multiple partitions?

Enomis

New Member
Apr 12, 2024
4
0
1
Hello everyone,

I must preface this by saying I only have basic knowledge on how virtualization tools work, and I'm trying Proxmox for the first time.

After setting up some virtual machines, I now want to create one to perform restore of a my_file.img image file. So, I tried to follow this guide https://forum.proxmox.com/threads/how-to-work-with-img.52986/ and successfully managed to do everything, including "add the new unused disk as attached disk" and set the "Boot order", but booting the created VM (207) does nothing, like you can see in this image:

Screenshot 2024-04-14 at 00.50.56.png

Analyzing the .img file I managed to discover that it's not just a single partition but contains more partitions, thanks to the commands:

Bash:
losetup -fP my_file.img
fdisk -l

where I found:

Code:
Device       Boot  Start      End  Sectors  Size Id Type
/dev/loop0p1 *      2048   526335   524288  256M  c W95 FAT32 (LBA)
/dev/loop0p2      526336 49143576 48617241 23.2G 83 Linux

From that command i've seen also some info about disk created form .img file and attacched to VM 207

Code:
Device                                 Boot  Start      End  Sectors  Size Id Type
/dev/mapper/pve-vm--207--disk--0-part1 *      2048   526335   524288  256M  c W95 FAT32 (LBA)
/dev/mapper/pve-vm--207--disk--0-part2      526336 49143576 48617241 23.2G 83 Linux

Is this the problem? Does anyone have suggestions?
 
Are you sure the OS on the img was installed with BIOS and not with UEFI? According to the screenshot you got a SeaBIOS VM, so it won't boot from an ESP. For that you might want to try Q35 and OVMF.
 
Last edited:
Are you sure the OS on the img was installed with BIOS and not with UEFI? According to the screenshot you got a SeaBIOS VM, so it won't boot from an ESP. For that you might want to try Q35 and OVMF.

Hello Dunin and thanks for reply.

To be honest, I don't know: it's an backup image created from an Ubuntu server installation using the script pyshrink (https://polargeek.com/network-backup-your-raspberry-pi/).

I tried to set the Bios to OVM (EFI) and add an EFI Disk as per the image,

Screenshot 2024-04-14 at 13.31.22.png


but at boot I find this error: BdsDxe: failed to load Boot0001 "UEFI QEMU HARDDISK QM00005", and searching I found this thread https://forum.proxmox.com/threads/cant-boot-my-vm-anymore-disk-not-found.125936/, and performed verification with gdisk -l /dev/pve/vm-207-disk-0, which is my "SATA".
I also tried to run the gdisk "w" option, but the output of the previous command did not change, confirming that the disk is:

Code:
Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          526335   256.0 MiB   0700  Microsoft basic data
   2          526336        49143576   23.2 GiB    8300  Linux filesystem


Trying to go into the bios while I'm with OVM (EFI), I don't see the possibility to select my "SATA" in the boot order, but from the command qm config 207 in theory I see that actually sata0 is the first in the boot order

Code:
bios: ovmf
boot: order=sata0;net0
cores: 4
efidisk0: local-lvm:vm-207-disk-1,efitype=4m,pre-enrolled-keys=1,size=4M
memory: 1024
meta: creation-qemu=8.1.5,ctime=1713041087
net0: virtio=BC:24:11:53:5D:4F,bridge=vmbr0
numa: 0
ostype: l26
sata0: local-lvm:vm-207-disk-0,discard=on,size=54716M,ssd=1
scsihw: virtio-scsi-pci
smbios1: uuid=53ce79ad-6f1f-49b5-bb1a-34a1b2d76e80
sockets: 1
vmgenid: 8d302a57-a98a-41f3-8c98-f06468678de6

I've also tried gdisk /dev/pve/vm-207-disk-1 (I think it's useless), and nothing changes.


Certainly my lack of knowledge is making me miss some necessary pieces.
 
This is likely an UEFI based installation based on the presence of the FAT32 partition:
https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_A_Feb14.pdf#G17.1345080

We know that UEFI implementation in QEMU/PVE has known compatibility issue with IDE. Whether its the same for SATA, I dont know. I rarely use it.
I would suggest changing disk to SCSI, along with the boot order.
I would also suggest not running destructive commands on the image, ie gdisk, unless you have a good backup.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
To be honest, I don't know: it's an backup image created from an Ubuntu server installation using the script pyshrink
Don't know anything about the script, but just to be clear was the Ubuntu server running on a Raspberry pi or an amd86/64 system?
 
Good question. In case it was a Pi, you can give up and better create a new x86 from scratch.
 
There is also another apparent anomaly in the OPs disk size(s):
Code:
Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          526335   256.0 MiB   0700  Microsoft basic data
   2          526336        49143576   23.2 GiB    8300  Linux filesystem
So roughly 23.5 GiB total. But:
Code:
sata0: local-lvm:vm-207-disk-0,discard=on,size=54716M,ssd=1

I'm not sure what's at play here. Maybe its just some lvm provisioning stuff.
 
Last edited:
Hello everyone and thank you for your answers.

First of all, I confirm that I have backup copies, hence I ran the `gdisk` commands, but I would like to thanks @bbgeek17 for highlighting it.
As advised, I tried to create a SCSI disk, and therefore setting it as primary in the boot loader, but unfortunately nothing has changed. I also tried to switch BIOS from OVMF (UEFI) to SeaBIOS, and also in this case nothing has changed.

Regarding @gfngfn256 's question: it is an Ubuntu Server that I had installed on an SD for Raspberry PI, and I apologize for not mentioning it from the beginning, but I didn't think it was important. As for seeing a size of 54716M, instead of 23.5 GiB, I can say that during the disk setup, from the interface I was the one who expanded the dimensions, so I think that’s the reason.

At this point it seems to me that it is more convenient for me to carry out a new clean installation of Ubuntu Server on a new VM? Are there any recommendations or tutorials/guides you could suggest, or can I take any one by searching on Google?
 
Last edited:
and I apologize for not mentioning it from the beginning, but I didn't think it was important.
No need to apologize. But unfortunately the Raspberry Pi uses an ARM architecture as vs the AMD86/64 of PVE - so no this isn't going to work.

At this point it seems to me that it is more convenient for me to carry out a new clean installation of Ubuntu Server on a new VM? Are there any recommendations or tutorials/guides you could suggest, or can I take any one by searching on Google?
I don't know what you used your Ubuntu server on the Pi for (desktop or not etc.) - but what I would do in your position is find the Ubuntu version/image you were originally using on the Pi - and get the ISO for that version in an amd86/64 architecture. This way you'll probably be (a) perfectly comfortable with the environment, & (b) probably most compatible with your original setup/data.
After you've spun up the new VM & got it working, just attach the old drive (image) to the VM, (making sure this isn't the boot drive for the VM), and retrieve all your data from that second partition. Once you're finished, you can detach that drive from the VM.
 
Last edited:
Also keep in mind that software compiled for ARM won't run on a x86 VM. So all programs should still be installed from scratch and then you only try to reuse the actual data and config files.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!