Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2023
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. # grab image
  2. wget https://dl.fedoraproject.org/pub/alt/risc-v/disk_images/Fedora-Developer-37-20221130.n.0.SiFive.Unmatched/Fedora-Developer-37-20221130.n.0-nvme.raw.img.xz
  3.  
  4. # unpack
  5. xz -d Fedora-Developer-37-20221130.n.0-nvme.raw.img.xz
  6.  
  7. # create resized image (128G):
  8. modprobe nbd max_part=8
  9. dd if=/dev/zero of=fed64gc_37.raw.img bs=1 count=0 seek=128G
  10. qemu-nbd -f raw --connect=/dev/nbd1 ./Fedora-Developer-37-20221130.n.0-nvme.raw.img
  11. qemu-nbd -f raw --connect=/dev/nbd2 ./fed64gc_37.raw.img
  12. echo -e "p\nq" | fdisk /dev/nbd1 # list partitions
  13. fdisk /dev/nbd2 # create partitions similar to nbd1
  14. # g (create empty gpt disk label)
  15. # n <cr> <cr> +700M (create first partition)
  16. # n <cr> <cr> <cr> (create second partition)
  17. # w (save and exit)
  18. mkfs.ext4 /dev/nbd2p1
  19. mkfs.ext4 /dev/nbd2p2
  20. mkdir foo bar
  21. mount /dev/nbd1p1 foo
  22. mount /dev/nbd2p1 bar
  23. cp foo/initramfs* . # grab initrd
  24. cp foo/vmlinuz* . # grab kernel (appears gzip compressed Image, a.k.a. Image.gz)
  25. rsync -a foo/ bar/
  26. umount foo
  27. umount bar
  28. blkid /dev/nbd2p* # grab UUID of "/boot" and "/" partitions (*not* PARTUUID!)
  29. mount /dev/nbd1p2 foo
  30. mount /dev/nbd2p2 bar
  31. rsync -a foo/ bar/
  32. umount foo
  33. vi bar/etc/fstab # replace UUIDs of "/boot" and "/" with above
  34. umount bar
  35. rmdir foo bar
  36. qemu-nbd --disconnect /dev/nbd1
  37. qemu-nbd --disconnect /dev/nbd2
  38. modprobe -r nbd
  39.  
  40. # create virtual machine:
  41. mv vmlinuz-6.0.10-300.0.riscv64.fc37.riscv64 Image-6.0.10-300.0.riscv64.fc37.riscv64.gz
  42. gunzip Image-6.0.10-300.0.riscv64.fc37.riscv64.gz
  43. mv initramfs-* /var/lib/libvirt/images/fv64gc/
  44. mv Image-* /var/lib/libvirt/images/fv64gc/
  45. mv fed64gc_37.raw.img /var/lib/libvirt/images/fv64gc/
  46. # edit fv64gc.xml to update initramfs, Image, and the root partition UUID on cmdline
  47. virsh define fv64gc.xml
  48.  
  49. # add "systemd.unit=multi-user.target enforcing=0" to cmdline on first boot;
  50. # run `systemctl set-default multi-user.target; restorecon -Rp /` on first login!!!
  51. # then restore cmdline to its original form...
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement