This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| riscv-qemu-debian [2025/02/03 11:50] admin | riscv-qemu-debian [2025/06/14 15:07] (current) me | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | Here are the simple steps: | ||
| - | |||
| - | Pre-Step | ||
| Install QEMU on your system. | Install QEMU on your system. | ||
| Line 18: | Line 15: | ||
|  |  | ||
|  |  | ||
| - |  | + |  | 
| - |  | + |  | 
| - |  | + |  | 
| The readme contains the QEMU command that you can use to start virtual environment. | The readme contains the QEMU command that you can use to start virtual environment. | ||
| Line 39: | Line 36: | ||
| You can actually download those two files and place them anywhere you want on your local computer. | You can actually download those two files and place them anywhere you want on your local computer. | ||
| - | RISC-V-Assembly-Language-Programming/ | + | RISC-V-Assembly-Language-Programming/ | 
| Make sure that when you download each file that you download the RAW file. GitHub does a weird thing and will download them as odd text files if you don't use the RAW option. | Make sure that when you download each file that you download the RAW file. GitHub does a weird thing and will download them as odd text files if you don't use the RAW option. | ||
| Line 50: | Line 47: | ||
| Note: There cannot be any spaces after the line-continuation-character (\). | Note: There cannot be any spaces after the line-continuation-character (\). | ||
| - | I've broken the command up over lines so you can see each argument which is passed to the QEMU executable?  Did you know there is a separate EXE for each QEMU platform (riscv64, x86_64, etc.)? | + | I've broken the command up over lines so you can see each argument which is passed to the QEMU executable. There is a separate EXE for each QEMU platform (riscv64, x86_64, etc.) | 
| - | BAT | + | |
| qemu-system-riscv64 -machine ' | qemu-system-riscv64 -machine ' | ||
| Line 67: | Line 64: | ||
| Once you start the virtual environment login using : | Once you start the virtual environment login using : | ||
| - | root (username) and root (pwd) | + | root(username) and root (pwd) | 
| Now you can install the build_essential packages so you can write assembly and link. | Now you can install the build_essential packages so you can write assembly and link. | ||
| Line 81: | Line 78: | ||
| $ ld --version | $ ld --version | ||
| + | |||
| + | -------------------------------------------------------------------------------------------------------- | ||
| + | |||
| + | ====Mounting Raw and qcow2 Images==== | ||
| + | Posted on 15 July 2016 by Albert de Vera | ||
| + | |||
| + | Mounting Raw and qcow2 images in order to inspect and use them doesn’t have to be difficult. After searching the internet, we found a couple of recommendations on how to do it. Here is what we did ourselves on an Ubuntu 16.04 Linux host. | ||
| + | Mounting The Raw Image | ||
| + | |||
| + | Associate the raw image with a loop device: | ||
| + | |||
| + | losetup /dev/loop0 image.raw | ||
| + | |||
| + | Map the partitions to loop devices: | ||
| + | |||
| + | kpartx -a /dev/loop0 | ||
| + | |||
| + | You should be able to mount the partitions now: | ||
| + | |||
| + | mount / | ||
| + | |||
| + | where /mnt/t01 is a previously-existing mount point or directory. | ||
| + | |||
| + | For LVM partitions, determine the volume group name and activate it: | ||
| + | |||
| + | vgscan | ||
| + | vgchange -ay vg_volgroupname | ||
| + | |||
| + | Mount the desired logical volume: | ||
| + | |||
| + | mount / | ||
| + | |||
| + | where /mnt/t02 is another pre-existing mount point or directory. | ||
| + | Unmounting The Raw Image | ||
| + | |||
| + | Unmount the previously mounted partitions: | ||
| + | |||
| + | umount /dev/t02 | ||
| + | umount /dev/t01 | ||
| + | |||
| + | Deactivate the volume group: | ||
| + | |||
| + | vgchange -an vg_volgroupname | ||
| + | |||
| + | Undo the mapping of the partitions to the loop devices: | ||
| + | |||
| + | kpartx -d /dev/loop0 | ||
| + | |||
| + | Destroy the loop: | ||
| + | |||
| + | losetup -d /dev/loop0 | ||
| + | |||
| + | Mounting The qcow2 Image | ||
| + | |||
| + | Here, we shall use the QEMU Network Block Device Driver for the purposes of mounting the qcow2 image. | ||
| + | |||
| + | First, load the nbd driver. | ||
| + | |||
| + | modprobe nbd max_part=63 | ||
| + | |||
| + | Connect nbd to the image using qemu-nbd: | ||
| + | |||
| + | qemu-nbd -c /dev/nbd0 disk1.qcow2 | ||
| + | |||
| + | Using fdisk, check the existing partitions. Mount the regular Linux partitions as is: | ||
| + | |||
| + | mount /dev/nbd0p1 /mnt/t01 | ||
| + | |||
| + | For LVM partitions, associate a loopback device to the LVM partition: | ||
| + | |||
| + | losetup /dev/loop0 /dev/nbd0p2 | ||
| + | |||
| + | See the LVM partitions under / | ||
| + | |||
| + | ls -l /dev/mapper | ||
| + | |||
| + | You should also be able to display the logical partitions using lvdisplay and the volume groups with vgdisplay. Use vgchange as above to activate the volume group. | ||
| + | |||
| + | Mount the regular LVM partitions as usual: | ||
| + | |||
| + | mount / | ||
| + | |||
| + | Unmounting the qcow2 Image | ||
| + | |||
| + | Unmount the partitions from the qcow2 image: | ||
| + | |||
| + | umount /mnt/t02 | ||
| + | umount /mnt/t01 | ||
| + | |||
| + | Deactivate the volume group: | ||
| + | |||
| + | vgchange -an vg_volgroupname | ||
| + | |||
| + | Remove the loopback device: | ||
| + | |||
| + | losetup -d /dev/loop0 | ||
| + | |||
| + | Disconnect the nbd device: | ||
| + | |||
| + | qemu-nbd -d /dev/nbd0 | ||
| + | |||
| + | Finally, remove the nbd kernel module: | ||
| + | |||
| + | rmmod nbd | ||
| + | |||
| + | We have successfully used the above procedures in mounting and unmounting raw and qcow2 images used in Linux KVM. | ||
| + | |||
| + | The procedures described above have been adapted for this article from these URLs: | ||
| + | |||
| + | https:// | ||
| + | http:// | ||
| + | |||
| + | https:// | ||