<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Amarjargal</title>
    <description>The latest articles on DEV Community by Amarjargal (@amarjargal).</description>
    <link>https://dev.to/amarjargal</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F984766%2Fe04ec35a-f860-460c-8aa8-57b7b3f87058.jpeg</url>
      <title>DEV Community: Amarjargal</title>
      <link>https://dev.to/amarjargal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/amarjargal"/>
    <language>en</language>
    <item>
      <title>Testing ublk on Ubuntu 22.04</title>
      <dc:creator>Amarjargal</dc:creator>
      <pubDate>Mon, 16 Jan 2023 06:45:25 +0000</pubDate>
      <link>https://dev.to/amarjargal/testing-ublk-on-ubuntu-2204-9pe</link>
      <guid>https://dev.to/amarjargal/testing-ublk-on-ubuntu-2204-9pe</guid>
      <description>&lt;p&gt;ublk is a generic framework for implementing block device logic in the userspace. It's developed by our mentor Ming Lei. &lt;a href="https://lwn.net/Articles/903855/" rel="noopener noreferrer"&gt;Here&lt;/a&gt; is an article that described the workings and future possibilities of ublk. Reading all about its possibilities, I'm super excited to work with this project.&lt;/p&gt;

&lt;p&gt;ublk is comprised of two parts: kernel &lt;a href="https://www.kernel.org/doc/Documentation/block/ublk.rst" rel="noopener noreferrer"&gt;ublk driver&lt;/a&gt; which is newly introduced to the Linux kernel since version 6.0 and userspace daemon (&lt;a href="https://github.com/ming1/ubdsrv" rel="noopener noreferrer"&gt;ublksrv&lt;/a&gt;).  &lt;/p&gt;

&lt;p&gt;When testing ublk driver on a Fedora 37 VM, it worked out of the box. But those who want to use it on Ubuntu, for now, will have to update their kernel to version 6.0 or up and configure it to enable ublk driver. I have Ubuntu 22.04 Jammmy Jellyfish and kernel 5.15. So the first step is to configure and build the kernel.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Configure and build the Linux kernel
&lt;/h3&gt;

&lt;p&gt;Download the latest stable kernel from &lt;a href="https://www.kernel.org/" rel="noopener noreferrer"&gt;kernel.org&lt;/a&gt;. The latest kernel as of this writing was 6.1.4.&lt;/p&gt;

&lt;p&gt;Extract it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tar xvf linux-6.1.4.tar.xz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Go to the extracted directory and copy the current kernel's configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd linux-6.1.4
cp -v /boot/config-$(uname -r) .config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The new kernel will have many new config options. To keep the old configuration and also to configure the new options to their default values, run the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;make olddefconfig
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Configure ublk_drv by running the GUI menuconfig, navigating to &lt;code&gt;Device drivers -&amp;gt; Block devices&lt;/code&gt; and add &lt;code&gt;M&lt;/code&gt; to the &lt;code&gt;Userspace block driver (Experimental)&lt;/code&gt; to make it a loadable module. Click Save and Exit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;make menuconfig
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fegv4tyzqr304mspclrun.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fegv4tyzqr304mspclrun.png" alt="Image description" width="718" height="859"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Disable the conflicting security certificates. Without disabling them, the make will fail with error. This might not be the best solution, but the easiest one and serves my purpose.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;scripts/config --disable SYSTEM_TRUSTED_KEYS
scripts/config --disable SYSTEM_REVOCATION_KEYS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Build and install. Use -j option to speed up the build process as it takes a lot of time. &lt;code&gt;nproc&lt;/code&gt; will return the number of cores you can use.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;make -j16
make modules
sudo make modules_install
sudo make install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update grub bootloader:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo update-grub
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reboot&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Build and install liburing
&lt;/h3&gt;

&lt;p&gt;libiring is library for the new Linux asynchronous IO interface called io_uring. This is the interface ublk uses and will require version 2.2 or up. &lt;/p&gt;

&lt;p&gt;You can install liburing with apt as shown below, but it was not the latest version.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install liburing2 liburing-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Therefore, I just built it from the cloned source.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git clone https://github.com/axboe/liburing
$ cd liburing
$ ./configure
$ make
$ sudo make install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Build ubdsrv (userspace daemon)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/ming1/ubdsrv.git
autoreconf -i
./configure
make
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Try ublk
&lt;/h3&gt;

&lt;p&gt;First, load &lt;code&gt;ublk_drv&lt;/code&gt; as a module. After it's loaded, a device called &lt;code&gt;/dev/ublk_control&lt;/code&gt; is created. Userspace daemon will communicate with this device.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo modprobe ublk_drv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I tried ublk by following the Quick start tutorial on ubdsrv's &lt;a href="https://github.com/ming1/ubdsrv" rel="noopener noreferrer"&gt;source page&lt;/a&gt;. For now, ublk commands need root permission to run.&lt;/p&gt;

&lt;h4&gt;
  
  
  null disk
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo ublk add -t null
dev id 0: nr_hw_queues 1 queue_depth 128 block size 512 dev_capacity 524288000
    max rq size 524288 daemon pid 235918 flags 0x2 state LIVE
    queue 0: tid 235919 affinity(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 )
    target {"dev_size":268435456000,"name":"null","type":0}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the above command executed, ublk block device &lt;code&gt;ublkb0&lt;/code&gt; and a char device &lt;code&gt;ublkc0&lt;/code&gt; is added by the ublk driver in /dev/&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ls /dev/ublk
ublkb0        ublkc0        ublk-control 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  loop device
&lt;/h4&gt;

&lt;p&gt;A raw disk image created with &lt;code&gt;qemu-img&lt;/code&gt; is used.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ qemu-img create -f raw foo.img 4G
$ sudo ublk add -t loop -f foo.img 
[sudo] password for amar: ublk
dev id 1: nr_hw_queues 1 queue_depth 128 block size 4096 dev_capacity 8388608
    max rq size 524288 daemon pid 329999 flags 0x2 state LIVE
    queue 0: tid 330000 affinity(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 )
    target {"backing_file":"foo.img","dev_size":4294967296,"direct_io":1,"name":"loop","type":1}
$ ls /dev/ublk
ublkb0        ublkb1        ublkc0        ublkc1        ublk-control
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can format the block device &lt;code&gt;/dev/ublkb1&lt;/code&gt; with xfs, mount it and can do anything you want with it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo mkfs.xfs /dev/ublkb0 
meta-data=/dev/ublkb0            isize=512    agcount=4, agsize=262144 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1    bigtime=0 inobtcount=0
data     =                       bsize=4096   blocks=1048576, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
Discarding blocks...Done.
$ sudo mount /dev/ublkb0 /mnt/tmp/
$ sudo mkdir /mnt/tmp/test
$ ls /mnt/tmp/
test
$ sudo umount /mnt/tmp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  qcow2 disk
&lt;/h3&gt;

&lt;p&gt;qcow2 support is still experimental, but I was able to add the Fedora disk image created in my previous blog &lt;a href="https://dev.to/amarjargal/running-fedora-37-on-qemu-x8664-machine-133b"&gt;post&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo ublk add -t qcow2 -f ../fedora/fedora37.qcow2 
dev id 2: nr_hw_queues 1 queue_depth 128 block size 512 dev_capacity 62914560
    max rq size 524288 daemon pid 243562 flags 0x2 state LIVE
    queue 0: tid 243564 affinity(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 )
    target {"backing_file":"../fedora/fedora37.qcow2","cluster_bits":16,"dev_size":32212254720,"header_length":112,"l1_size":60,"name":"qcow2","refcount_order":4,"refcount_table_clusters":1,"type":2,"version":3}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;ublkb2p1&lt;/code&gt;, &lt;code&gt;ublkb2p2&lt;/code&gt; and &lt;code&gt;ublkb2p3&lt;/code&gt; are added for each partition of the disk. Then we can mount the main partition and access the filesystem.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ls /dev/ublk
ublkb0        ublkb1        ublkb2        ublkb2p1      ublkb2p2      ublkb2p3      ublkc0        ublkc1        ublkc2        ublk-control
$ sudo mount /dev/ublkb2p3 /mnt/tmp/
$ ls /mnt/tmp/
afs  bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
$ sudo umount /mnt/tmp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;List all the devices:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo ublk list 
dev id 0: nr_hw_queues 1 queue_depth 128 block size 512 dev_capacity 524288000
    max rq size 524288 dae$ sudo umount /mnt/tmpmon pid 235918 flags 0x2 state LIVE
    queue 0: tid 235919 affinity(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 )
    target {"dev_size":268435456000,"name":"null","type":0}
dev id 1: nr_hw_queues 1 queue_depth 128 block size 4096 dev_capacity 8388608
    max rq size 524288 daemon pid 329999 flags 0x2 state LIVE
    queue 0: tid 330000 affinity(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 )
    target {"backing_file":"foo.img","dev_size":4294967296,"direct_io":1,"name":"loop","type":1}
dev id 2: nr_hw_queues 1 queue_depth 128 block size 512 dev_capacity 62914560
    max rq size 524288 daemon pid 243562 flags 0x2 state LIVE
    queue 0: tid 243564 affinity(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 )
    target {"backing_file":"../fedora/fedora37.qcow2","cluster_bits":16,"dev_size":32212254720,"header_length":112,"l1_size":60,"name":"qcow2","refcount_order":4,"refcount_table_clusters":1,"type":2,"version":3}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remove all devices:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ublk del -a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>discuss</category>
    </item>
    <item>
      <title>QEMU Storage Daemon</title>
      <dc:creator>Amarjargal</dc:creator>
      <pubDate>Fri, 06 Jan 2023 17:34:57 +0000</pubDate>
      <link>https://dev.to/amarjargal/qemu-storage-daemon-nm9</link>
      <guid>https://dev.to/amarjargal/qemu-storage-daemon-nm9</guid>
      <description>&lt;p&gt;&lt;a href="https://www.qemu.org/docs/master/tools/qemu-storage-daemon.html"&gt;qemu-storage-daemon&lt;/a&gt; is a tool that provides disk image functionality for a VM without running the VM itself. It can export disk images, run block job operations, and perform other disk-related operations. This &lt;a href="https://lwn.net/Articles/911281/"&gt;article&lt;/a&gt; was very helpful to get a better understanding of the QEMU storage daemon.&lt;/p&gt;

&lt;p&gt;Here, I used two of the export methods for qsd to access the Fedora disk image that was created in the previous blog post.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Fuse export
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.kernel.org/doc/html/latest/filesystems/fuse.html"&gt;FUSE&lt;/a&gt; (Filesystem in Userspace) is an interface for userspace programs to export a filesystem to the Linux kernel.&lt;/p&gt;

&lt;p&gt;There is a really nice tutorial on FUSE export on the &lt;a href="https://www.qemu.org/2021/08/22/fuse-blkexport/"&gt;QEMU website&lt;/a&gt; which I followed through.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;First of all, install some dependencies:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;libfuse3-3 libfuse3-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Then configure qemu with &lt;code&gt;--enable-fuse&lt;/code&gt; option and build it again.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./configure &lt;span class="nt"&gt;--enable-fuse&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Also, uncomment &lt;code&gt;user_allow_other&lt;/code&gt; in &lt;code&gt;/etc/fuse.conf&lt;/code&gt;. By default, only user who exported the image will have an access to it. Enabling &lt;code&gt;user_allow_other&lt;/code&gt; option here will allow non-root users to be able to use &lt;code&gt;allow_other&lt;/code&gt; mount option which enables users other than the owner to be able to access the mounted fuse image.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create a file that will be a mount point where the filesystem will be mounted on. It's also possible to mount the image on itself.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch mount-point
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Export:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;qemu-storage-daemon &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--blockdev&lt;/span&gt; node-name&lt;span class="o"&gt;=&lt;/span&gt;prot-node,driver&lt;span class="o"&gt;=&lt;/span&gt;file, 
&lt;span class="nv"&gt;filename&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;fedora37.qcow2   &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--blockdev&lt;/span&gt; node-name&lt;span class="o"&gt;=&lt;/span&gt;fmt-node,driver&lt;span class="o"&gt;=&lt;/span&gt;qcow2,file&lt;span class="o"&gt;=&lt;/span&gt;prot-node   
   &lt;span class="nt"&gt;--export&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;fuse,id&lt;span class="o"&gt;=&lt;/span&gt;exp0,node-name&lt;span class="o"&gt;=&lt;/span&gt;fmt-node, 
&lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;mount-point,writable&lt;span class="o"&gt;=&lt;/span&gt;on  
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;After the above command is executed, the mount-point will appear as a raw VM disk. Then, we'll be able to use tools like &lt;code&gt;parted&lt;/code&gt;, &lt;code&gt;kpartx&lt;/code&gt;, &lt;code&gt;file&lt;/code&gt;,&lt;code&gt;mount&lt;/code&gt; as they can't parse qcow2 images and can only work with raw images.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;qemu-img info mount-point
image: mount-point
file format: raw
virtual size: 30 GiB &lt;span class="o"&gt;(&lt;/span&gt;32212254720 bytes&lt;span class="o"&gt;)&lt;/span&gt;
disk size: 1.58 GiB
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;List the partition table:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;parted mount-point p
WARNING: You are not superuser.  Watch out &lt;span class="k"&gt;for &lt;/span&gt;permissions.
Model:  &lt;span class="o"&gt;(&lt;/span&gt;file&lt;span class="o"&gt;)&lt;/span&gt;
Disk /home/amar/projects/outreachy/qemu/fedora/mount-point: 32.2GB
Sector size &lt;span class="o"&gt;(&lt;/span&gt;logical/physical&lt;span class="o"&gt;)&lt;/span&gt;: 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  2097kB  1049kB               primary  bios_grub
 2      2097kB  1076MB  1074MB  xfs          primary
 3      1076MB  32.2GB  31.1GB  xfs          primary
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add device mappings over partitions:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;kpartx &lt;span class="nt"&gt;-av&lt;/span&gt; mount-point 
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;sudo&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; password &lt;span class="k"&gt;for &lt;/span&gt;amar: 
add map loop31p1 &lt;span class="o"&gt;(&lt;/span&gt;253:6&lt;span class="o"&gt;)&lt;/span&gt;: 0 2048 linear 7:31 2048
add map loop31p2 &lt;span class="o"&gt;(&lt;/span&gt;253:7&lt;span class="o"&gt;)&lt;/span&gt;: 0 2097152 linear 7:31 4096
add map loop31p3 &lt;span class="o"&gt;(&lt;/span&gt;253:8&lt;span class="o"&gt;)&lt;/span&gt;: 0 60810752 linear 7:31 2101248
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Mount the main partition:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;mount /dev/mapper/loop31p3 /mnt/tmp/
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; /mnt/tmp/
afs  boot  etc   lib    media  opt   root  sbin  sys  usr
bin  dev   home  lib64  mnt    proc  run   srv   tmp  var
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Unmount the partition after done using it.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;umount /mnt/tmp
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Stop qsd by just hitting &lt;code&gt;Ctrl+C&lt;/code&gt; or if it's running in the background, just kill the process.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  2. NBD export
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/NetworkBlockDevice/nbd/blob/master/doc/proto.md"&gt;NBD&lt;/a&gt; (Network Block Device) is a simple protocol that allows users to export a block device to a client over a network. &lt;a href="https://medium.com/@aysadx/linux-nbd-introduction-to-linux-network-block-devices-143365f1901b"&gt;Here&lt;/a&gt; is a nice introduction of NBD as suggested by my mentors.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;First, load NBD module:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo modprobe nbd
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Export the image file over NBD. With the below settings, NBD server will start running on localhost port 10809.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;qemu-storage-daemon     &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--blockdev&lt;/span&gt; node-name&lt;span class="o"&gt;=&lt;/span&gt;prot-node,driver&lt;span class="o"&gt;=&lt;/span&gt;file,
&lt;span class="nv"&gt;filename&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;fedora37.qcow2     &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--blockdev&lt;/span&gt; node-name&lt;span class="o"&gt;=&lt;/span&gt;fmt-node,driver&lt;span class="o"&gt;=&lt;/span&gt;qcow2,
&lt;span class="nv"&gt;file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;prot-node     &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--nbd-server&lt;/span&gt; addr.type&lt;span class="o"&gt;=&lt;/span&gt;inet,addr.host&lt;span class="o"&gt;=&lt;/span&gt;localhost,
addr.port&lt;span class="o"&gt;=&lt;/span&gt;10809     &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--export&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;nbd,id&lt;span class="o"&gt;=&lt;/span&gt;exp0,node-name&lt;span class="o"&gt;=&lt;/span&gt;fmt-node,
&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;guest-disk,writable&lt;span class="o"&gt;=&lt;/span&gt;on
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Mount the NBD exported device as a local device /dev/nbd0 by starting the &lt;code&gt;nbd-client&lt;/code&gt;. For &lt;code&gt;-N&lt;/code&gt; or &lt;code&gt;-name&lt;/code&gt; option, use the name provided in the export command above. If this option is not supplied, &lt;code&gt;nbd-client&lt;/code&gt; will complain about oldstyle negotiation.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;nbd-client localhost 10809 /dev/nbd0 &lt;span class="nt"&gt;-N&lt;/span&gt; guest-disk
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;sudo&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; password &lt;span class="k"&gt;for &lt;/span&gt;amar: 
Negotiation: ..size &lt;span class="o"&gt;=&lt;/span&gt; 30720MB
Connected /dev/nbd0
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Block devices for each partition of the original image will be automatically created.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ls /dev/nbd0&amp;lt;tab&amp;gt;
nbd0    nbd0p1  nbd0p2  nbd0p3
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Mount the main partition&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;mount /dev/nbd0p3 /mnt/tmp/
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; /mnt/tmp/
afs  boot  etc   lib    media  opt   root  sbin  sys  usr
bin  dev   home  lib64  mnt    proc  run   srv   tmp  var
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;After finished, unmount and disconnect. Proper clean-up is important because if not done correctly, the next export will not work.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;umount /mnt/tmp
nbd-client -d /dev/nbd0
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>qemu</category>
      <category>qsd</category>
    </item>
    <item>
      <title>Running Fedora 37 on QEMU x86_64 machine</title>
      <dc:creator>Amarjargal</dc:creator>
      <pubDate>Fri, 06 Jan 2023 17:33:43 +0000</pubDate>
      <link>https://dev.to/amarjargal/running-fedora-37-on-qemu-x8664-machine-133b</link>
      <guid>https://dev.to/amarjargal/running-fedora-37-on-qemu-x8664-machine-133b</guid>
      <description>&lt;p&gt;In my previous post, I played with QEMU by installing Debian on an emulated arm machine. It was challenging and I ended up spending a lot of time for it. But I think it was a good exercise nevertheless.&lt;/p&gt;

&lt;p&gt;However, as my mentors suggested, it's much better to use the same QEMU target architecture as your host. Therefore, here I'll describe the steps I followed to run Fedora 37 on QEMU x86_64 machine.&lt;/p&gt;

&lt;p&gt;But first, here's a little bit about KVM.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is KVM and how does it relate to QEMU?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.linux-kvm.org/page/Main_Page" rel="noopener noreferrer"&gt;KVM&lt;/a&gt; (Kernel-based Virtual Machine) is an open source full virtualization solution for Linux on x86 machine with virtualization hardware extension (Intel VT or AMD-V). To see if the virtualization extension exists, run the following to look for &lt;code&gt;svm&lt;/code&gt; (for AMD-V) or &lt;code&gt;vmx&lt;/code&gt; (for Intel VT) flags.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grep -E 'svm|vmx' /proc/cpuinfo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On my computer, the result contains &lt;code&gt;svm&lt;/code&gt; which means I have a AMD-V.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsx267qd9pwm0lezx9yr7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsx267qd9pwm0lezx9yr7.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To see if KVM is enabled, run the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuj4ch5hbr2ziyolmaaw2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuj4ch5hbr2ziyolmaaw2.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hypervisor is a software that provides the virtualization to the underlying hardware; it creates and runs Virtual Machines. &lt;a href="https://developer.ibm.com/tutorials/l-hypervisor/" rel="noopener noreferrer"&gt;This IBM tutorial&lt;/a&gt; was a great read to understand about virtualization and hypervisors. KVM is a type 1 (bare metal) hypervisor which means that it has a direct access to the hardware resources.&lt;/p&gt;

&lt;p&gt;Whereas, QEMU is a type 2 hypervisor which means it runs on top of the host OS. QEMU is also tightly integrated with KVM. If KVM is enabled on the host, and guest and host OS have the same architecture, QEMU can have KVM to translate some of the instructions (CPU and memory calls) making it much faster. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6vc50msoy3fbyjfem8xg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6vc50msoy3fbyjfem8xg.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Source: &lt;a href="https://www.researchgate.net/profile/Tolga-Soyata/publication/281177318/figure/fig1/AS:284451906048014@1444830027668/Comparison-of-Xen-KVM-and-QEMU.png" rel="noopener noreferrer"&gt;Researchgate&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Libvirt
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://wiki.libvirt.org/page/FAQ" rel="noopener noreferrer"&gt;Libvirt&lt;/a&gt; is collection of software that provides a convenient way to manage virtual machines and other virtualization functionality. &lt;br&gt;
Tools such as &lt;code&gt;virt-builder&lt;/code&gt;, &lt;code&gt;virt-install&lt;/code&gt; and &lt;code&gt;virt-manager&lt;/code&gt; that are based on &lt;code&gt;libvirt&lt;/code&gt; make building and installing virtual machines much easier.&lt;/p&gt;
&lt;h4&gt;
  
  
  Virt-builder
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://libguestfs.org/virt-builder.1.html#description" rel="noopener noreferrer"&gt;&lt;code&gt;Virt-builder&lt;/code&gt;&lt;/a&gt; is a tool a tool that quickly builds virtual machine images. It's part of &lt;a href="https://www.libguestfs.org/" rel="noopener noreferrer"&gt;&lt;code&gt;libguestfs&lt;/code&gt;&lt;/a&gt; which is a set of tools to build, access, modify virtual machine disk images and more.&lt;/p&gt;

&lt;p&gt;First, install &lt;code&gt;libguestfs&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install libguestfs-tools
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The following will list all the virtual machine images you can create:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;virt-builder --list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Build Fedora image. The size specified with &lt;code&gt;-size 30G&lt;/code&gt; will not be the actual size of the image. It just means that the newly created image can be expanded up to 30G.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;virt-builder  \
    --ssh-inject=root:file:/home/amar/.ssh/id_rsa.pub  \ 
    --root-password=password:vm_root_password   \
    --output=fedora37.qcow2 --format=qcow2   \
    --selinux-relabel --size 30G fedora-37
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Virt-install and Virt-manager
&lt;/h4&gt;

&lt;p&gt;Create a VM using the disk image created above with &lt;code&gt;virt-builder&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;virt-install 
    --connect qemu:///system --name f37-vm–import \
    --ram 2048 --vcpus 2 --cpu host   \
    --disk bus=virtio,path=fedora37.qcow2   \ 
    --network network=default,model=virtio  \
    --os-variant fedora37
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or use &lt;a href="https://virt-manager.org/" rel="noopener noreferrer"&gt;&lt;code&gt;virt-manager&lt;/code&gt;&lt;/a&gt; which is a GUI tool that allows you to create a VM with one-click.&lt;/p&gt;

&lt;p&gt;However, when I try to use &lt;code&gt;virt-install&lt;/code&gt; or &lt;code&gt;virt-manager&lt;/code&gt;, I got the following error even though virtualization hardware is present and enabled.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ERROR    Host does not support any virtualization options&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Direct install
&lt;/h3&gt;

&lt;p&gt;I had a network problem when I tried direct install with &lt;code&gt;qemu-system-x86_64&lt;/code&gt;. Therefore, first install slirp, configure and build QEMU again with &lt;code&gt;--enable-slirp&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install libslirp-dev
../configure --enable-slirp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then directly run VM with QEMU:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;qemu-system-x86_64 -smp 2 -m 1G -M q35,accel=kvm   \
    -drive file=fedora37.qcow2,format=qcow2,if=virtio  \   
    -nic user,model=virtio
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the VM runs, login using the root password set when building the disk image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flww9xsrk7ir7bnrlneb7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flww9xsrk7ir7bnrlneb7.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>qemu</category>
      <category>libvirt</category>
      <category>fedora</category>
      <category>kvm</category>
    </item>
    <item>
      <title>Running Debian on a QEMU emulated arm machine</title>
      <dc:creator>Amarjargal</dc:creator>
      <pubDate>Mon, 12 Dec 2022 05:21:20 +0000</pubDate>
      <link>https://dev.to/amarjargal/running-debian-on-an-emulated-arm-machine-2i04</link>
      <guid>https://dev.to/amarjargal/running-debian-on-an-emulated-arm-machine-2i04</guid>
      <description>&lt;p&gt;Here are the steps I followed to play with QEMU to get myself acquainted with it. My host is Ubuntu 20.04.1.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Building QEMU
&lt;/h2&gt;

&lt;p&gt;There are several ways to download and build QEMU. You can install the pre-packaged version on Ubuntu with &lt;code&gt;apt&lt;/code&gt; or download and build the latest release from the &lt;a href="https://www.qemu.org/download/" rel="noopener noreferrer"&gt;QEMU website&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;But to have the latest release and stay up to date, you can clone the git repository which is the way I'm doing.&lt;/p&gt;

&lt;p&gt;Install the required additional packages as instructed &lt;a href="https://wiki.qemu.org/Hosts/Linux" rel="noopener noreferrer"&gt;here&lt;/a&gt;. I also installed the recommended additional packaged as well.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo apt-get install git libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev ninja-build&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Clone the source code:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git clone git://git.qemu-project.org/qemu.git&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Initialize and update the submodules.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd qemu
git submodule init
git submodule update --recursive
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a new build directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir build
cd build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Configure and build. If you want to build for a specific target(s) only which is faster, just add a &lt;code&gt;--target-list&lt;/code&gt; option. Run &lt;code&gt;../configure --help&lt;/code&gt; to see the list of available targets and other configuration options.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;../configure
../configure --target-list=arm-softmmu
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Build and if necessary, test which takes a lot of time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;make
make check
make install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Installing Debian
&lt;/h2&gt;

&lt;p&gt;Download the arm disk image from &lt;a href="https://www.debian.org/devel/debian-installer/" rel="noopener noreferrer"&gt;Debian&lt;/a&gt; or using &lt;code&gt;wget&lt;/code&gt; from the server as shown below. It's the current version of Debian that will run on ARM machines. At the time of this post, the current version was codenamed &lt;code&gt;bullseye&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wget http://ftp.debian.org/debian/dists/stable/main/installer-arm64/current/images/netboot/mini.iso
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Download also the &lt;code&gt;vmlinux&lt;/code&gt; kernel and &lt;code&gt;initrd.gz&lt;/code&gt; initramfs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wget http://ftp.debian.org/debian/dists/stable/main/installer-arm64/current/images/netboot/debian-installer/arm64/initrd.gz
wget http://ftp.debian.org/dget http://ftp.debian.org/debian/dists/stable/main/installer-arm64/current/images/netboot/mini.iebian/dists/stable/main/installer-arm64/current/images/netboot/debian-installer/arm64/linux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are 3 different arm ports available: arm64, armhf and armel which are explained &lt;a href="https://www.debian.org/ports/arm/#:~:text=The%20newer%20ARM%20hard%2Dfloat,%2Dbit%20ARM%2Dpowered%20devices." rel="noopener noreferrer"&gt;here&lt;/a&gt; in detail. Basically, armel (arm EABI) is for older architecture versions (4T, 5T and 6), armhf (arm hard float) is for floating point support and arm64 for 64-bit ARMv8 architecture which I'll use. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;qemu-system-&lt;/code&gt; executables built in the previous step are for simulating different machines. &lt;code&gt;qemu-system-aarch64&lt;/code&gt; will simulate arm64 machine.&lt;br&gt;
The version used here is as shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ qemu-system-aarch64 --version
QEMU emulator version 7.1.93 (v7.2.0-rc3)
Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developersurl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a hard disk image for our system by running &lt;code&gt;qemu-img&lt;/code&gt; command. &lt;code&gt;qcow2&lt;/code&gt; (QEMU copy on write) is a disk image file format native to the QEMU.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;qemu-img create -f qcow2 debian-arm.sda.qcow2 5G&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Start the installation process:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;../qemu/build/qemu-system-aarch64 -M virt -cpu cortex-a53 -m 1G -kernel ./linux -initrd ./initrd.gz -hda debian-arm.sda.qcow2 -append "console=ttyAMA0" -drive file=./mini.iso,id=cdrom,if=none,media=cdrom -device virtio-scsi-device -device scsi-cd,drive=cdrom -nographic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After a few seconds, the kernel boots and Debian installer will start. You can just jump through the screens to configure your language, location, locale, keymap etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ob4f57id1ao13vtuky1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ob4f57id1ao13vtuky1.png" alt="Image description" width="719" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But I encountered a network set-up problem and therefore couldn't access the Debian archive mirror. I'll look into it and post again.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fttwwgafybxg3aa2hb5da.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fttwwgafybxg3aa2hb5da.png" alt="Image description" width="719" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftupmys8gkmx92elq86nb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftupmys8gkmx92elq86nb.png" alt="Image description" width="722" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Small tip: I didn't know how to exit the installer. Going back and choosing "Aborting the installer" option only reboot and restarted the installer. Instead you can choose "Execute a shell" and then type &lt;code&gt;poweroff&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Update
&lt;/h3&gt;

&lt;p&gt;After a bit of research, it looks like setting up network on Debian is tricky. It could be a missing &lt;a href="https://wiki.debian.org/Firmware" rel="noopener noreferrer"&gt;device driver/firmware&lt;/a&gt; since most of the firmware images are non-free, they are not included in the official Debian installation images. Unofficial images including non-free firmware are available, but there were none available for arm. &lt;/p&gt;

&lt;p&gt;Therefore I decided to use the DVD image that doesn't require network during the installation. I loosely followed the instructions this &lt;a href="https://www.willhaley.com/blog/debian-arm-qemu/" rel="noopener noreferrer"&gt;blog&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Again, download the necessary files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  curl -O http://ftp.us.debian.org/debian/dists/stable/main/installer-arm64/current/images/cdrom/initrd.gz
  curl -O http://ftp.us.debian.org/debian/dists/stable/main/installer-arm64/current/images/cdrom/vmlinuz
  curl -O -L https://cdimage.debian.org/debian-cd/current/arm64/iso-dvd/debian-11.6.0-arm64-DVD-1.iso
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Boot the VM to install Debian.&lt;br&gt;
debian-arm.sda.qcow2&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;qemu-system-aarch64 -m 4G -machine type=virt -cpu cortex-a53 -initrd "./initrd.gz" \
  -kernel "./vmlinuz" -append "console=ttyAMA0" \
  -drive file="./debian-11.6.0-arm64-DVD-1.iso", id=cdrom,if=none,media=cdrom \
    -device virtio-scsi-device \
    -device scsi-cd,drive=cdrom \
  -drive file="./debian-arm.sda.qcow2", id=hd,if=none,media=disk \
    -device virtio-scsi-device \
    -device scsi-hd,drive=hd \
  -nographic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The network setup will fail again, but you can choose &lt;code&gt;Do not configure the network at this time&lt;/code&gt; and the installation will run smoothly after that. &lt;/p&gt;

&lt;p&gt;When prompted about the bootloader, you can just choose &lt;code&gt;Continue&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq5cwozsjgxtir08vhmhr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq5cwozsjgxtir08vhmhr.png" alt="Image description" width="716" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After installation finishes, don't click on the &lt;code&gt;Continue&lt;/code&gt; because it'll start the installer all over again. Rather, choose &lt;code&gt;Go back&lt;/code&gt;, &lt;code&gt;Execute a shell&lt;/code&gt; and then type &lt;code&gt;poweroff&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffjeg3hbxohcu3fqfhc5d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffjeg3hbxohcu3fqfhc5d.png" alt="Image description" width="722" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>First week of my internship with QEMU through Outreachy</title>
      <dc:creator>Amarjargal</dc:creator>
      <pubDate>Mon, 12 Dec 2022 05:17:35 +0000</pubDate>
      <link>https://dev.to/amarjargal/first-week-3blg</link>
      <guid>https://dev.to/amarjargal/first-week-3blg</guid>
      <description>&lt;p&gt;This is the first week of my internship with QEMU through Outreachy.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Outreachy?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.outreachy.org/" rel="noopener noreferrer"&gt;Outreachy&lt;/a&gt; is an amazing opportunity for those who are underrepresented in the tech industry to work on open source and open science projects under the guidance of experienced mentors. I think most of the applicants are female and are students, but really it's open for everyone who feel disadvantaged to enter the industry.  &lt;/p&gt;

&lt;p&gt;For myself, I'm a mother of two little boys and I've been putting my career on hold ever since I became a mother. When I wanted to get back to the industry, I needed a little more flexibility which is difficult to get accommodated in the traditional style workplaces in my home country. Therefore I'm so grateful for Outreachy for providing me this opportunity to work remotely on such an interesting project as QEMU.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is QEMU?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.qemu.org/" rel="noopener noreferrer"&gt;QEMU&lt;/a&gt; is an open source machine emulator. It can emulate plethora of architectures ranging from x86, ARM, PowerPC, you name it, it probably can emulate. It can emulate full system such as a &lt;a href="https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/821821485/QEMU+Supported+Platforms" rel="noopener noreferrer"&gt;Xilinx development board&lt;/a&gt; or a Raspberry PI.&lt;/p&gt;

&lt;p&gt;For the duration of the internship I'll work on a project "&lt;a href="https://www.outreachy.org/outreachy-december-2022-internship-round/communities/qemu/#extend-qemu-storage-daemon-supporting-the-new-linu" rel="noopener noreferrer"&gt;Extend QEMU Storage Daemon, supporting the new Linux's userspace block driver (ublk) framework&lt;/a&gt;". &lt;/p&gt;

&lt;p&gt;I hope to update here frequently about what I learned and share the knowledge with others who are new to QEMU the same as me.&lt;/p&gt;

</description>
      <category>softwareengineering</category>
      <category>learning</category>
      <category>books</category>
    </item>
  </channel>
</rss>
