Page 1 of 1
ZXNext vhd editing
Posted: Wed Aug 09, 2023 1:58 pm
by Thedad
Hi,
A low-level issue which I wonder if anybody has an answer to.
In the ZXNext Core, I load the OS/Data from a .vhd file. Pretty common AFAIK.
I want to upgrade the core with the latest version ZXNext OS, so does anybody have any decent/easy way of mounting a .vhd in Linux as there are a bunch of instructions lying about on how to do it, but would welcome any recommendations here.
TIA.
Re: ZXNext vhd editing
Posted: Wed Aug 09, 2023 3:47 pm
by JamesH
Long story short,
Also, I believe all modern DEs are able to handle partitioned disk images out of the box, but I assume you want to do it on the MiSTer itself to avoid copying large image files (works with any Linux system with any supported partition/filesystem).
Updated 2023-08-13 to reflect important remarks from pgimeno.
In other words:
- Set up loopback devices reflecting image partitions:
Code: Select all
/media/fat/games/ZXNext# losetup --show -Pf boot.vhd
- If necessary (or if you get distracted ), double check that everything was detected properly (you can this any time):
Code: Select all
/media/fat/games/ZXNext# losetup -a
/dev/loop0: 0 /media/fat/linux/bluetooth
/dev/loop1: 0 boot.vhd
/dev/loop8: 0
- Just mount it and do whatever you like (NOTE: you mount partition device loop1p1, not the entire loop device)
Code: Select all
/media/fat/games/ZXNext# mount /dev/loop1p1 /mnt/
/media/fat/games/ZXNext# ls /mnt/
demos dot games nextzxos sys TBBLUE.TBU tools
docs extras machines rpi TBBLUE.FW tmp
- PROFIT. But NEVER start the core when the image partition is mounted!!!
- When done, unmount the partition:
Code: Select all
/media/fat/games/ZXNext# umount /mnt/
- And do not forget to release allocated loop device:
Code: Select all
/media/fat/games/ZXNext# losetup -a
/dev/loop0: 0 /media/fat/linux/bluetooth
/dev/loop1: 0 boot.vhd
/dev/loop8: 0
/media/fat/games/ZXNext# losetup -d /dev/loop1
There are technically correct, but completely obsolete guides on those internetz, suggesting to calculate partition(s) offset(s) and explicitly specify it when calling losetup. That's no longer necessary for many years.
Re: ZXNext vhd editing
Posted: Fri Aug 11, 2023 2:32 pm
by pgimeno
JamesH wrote: ↑Wed Aug 09, 2023 3:47 pm Double check that everything was detected properly (and you need to know the assigned device anyway):
That's what the --show flag is for. Passing --show to losetup in the first step would void the need for the second step.
Oh, and very important, don't forget to unmount the partition before booting the core, or you risk serious corruption!
Re: ZXNext vhd editing
Posted: Thu Sep 21, 2023 9:53 am
by Thedad
JamesH wrote: ↑Wed Aug 09, 2023 3:47 pm
Long story short,
Also, I believe all modern DEs are able to handle partitioned disk images out of the box, but I assume you want to do it on the MiSTer itself to avoid copying large image files (works with any Linux system with any supported partition/filesystem).
Updated 2023-08-13 to reflect important remarks from pgimeno.
In other words:
- Set up loopback devices reflecting image partitions:
Code: Select all
/media/fat/games/ZXNext# losetup --show -Pf boot.vhd
- If necessary (or if you get distracted ), double check that everything was detected properly (you can this any time):
Code: Select all
/media/fat/games/ZXNext# losetup -a
/dev/loop0: 0 /media/fat/linux/bluetooth
/dev/loop1: 0 boot.vhd
/dev/loop8: 0
- Just mount it and do whatever you like (NOTE: you mount partition device loop1p1, not the entire loop device)
Code: Select all
/media/fat/games/ZXNext# mount /dev/loop1p1 /mnt/
/media/fat/games/ZXNext# ls /mnt/
demos dot games nextzxos sys TBBLUE.TBU tools
docs extras machines rpi TBBLUE.FW tmp
- PROFIT. But NEVER start the core when the image partition is mounted!!!
- When done, unmount the partition:
Code: Select all
/media/fat/games/ZXNext# umount /mnt/
- And do not forget to release allocated loop device:
Code: Select all
/media/fat/games/ZXNext# losetup -a
/dev/loop0: 0 /media/fat/linux/bluetooth
/dev/loop1: 0 boot.vhd
/dev/loop8: 0
/media/fat/games/ZXNext# losetup -d /dev/loop1
There are technically correct, but completely obsolete guides on those internetz, suggesting to calculate partition(s) offset(s) and explicitly specify it when calling losetup. That's no longer necessary for many years.
Completely forgot to respond. Thanks for that. Very useful and something I thought was possible, I'm just too busy atm.