{"componentChunkName":"component---src-templates-post-template-js","path":"/diyos-30daysos-qemu-nographic-en","result":{"data":{"markdownRemark":{"id":"dd0accd4-f7b5-5e15-9ee6-e9876d3cd8c3","html":"<blockquote>\n<p>This page has been machine-translated from the <a href=\"/diyos-30daysos-qemu-nographic\">original page</a>.</p>\n</blockquote>\n<p>This article summarizes QEMU’s nographic option for running a DIY OS in the CUI.</p>\n<p>The binary used here is the do-nothing boot image created on day 1 of 30-Day OS.</p>\n<p>One difference from the 30-Day OS book is that I use NASM, a general-purpose assembler, instead of the author’s custom tools.</p>\n<h2 id=\"running-qemu-in-the-cui\" style=\"position:relative;\"><a href=\"#running-qemu-in-the-cui\" aria-label=\"running qemu in the cui permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Running QEMU in the CUI</h2>\n<p>To start with the conclusion, I was able to run the boot image in QEMU’s CUI with the following command:</p>\n<p>@@BT@@@@BT@@@bash\nqemu-system-x86_64 -drive file=boot.img,format=raw -nographic\n@@BT@@@@BT@@</p>\n<p>I think this is probably the minimum set of options needed to run a binary in QEMU’s CUI.</p>\n<p>The meaning of each option is as follows:</p>\n<p>@@BT@@@@BT@@\n-drive:<br>\nAn option for using a file as a drive image\nTakes [file=file] as a required argument</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">[file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]\n[,cache=writethrough|writeback|none|directsync|unsafe][,format=f]\n[,snapshot=on|off][,rerror=ignore|stop|report]\n[,werror=ignore|stop|report|enospc][,id=name][,aio=threads|native]\n[,readonly=on|off][,copy-on-read=on|off]\n[,discard=ignore|unmap][,detect-zeroes=on|off|unmap]\n[[,bps=b]|[[,bps_rd=r][,bps_wr=w]]]\n[[,iops=i]|[[,iops_rd=r][,iops_wr=w]]]\n[[,bps_max=bm]|[[,bps_rd_max=rm][,bps_wr_max=wm]]]\n[[,iops_max=im]|[[,iops_rd_max=irm][,iops_wr_max=iwm]]]\n[[,iops_size=is]]\n[[,group=g]]</code></pre></div>\n<p>-nographic：\nDisable the GUI and redirect serial I/O to the console\n@@BT@@@@BT@@</p>\n<p>As noted above, the @@BT@@-drive@@BT@@ option is used to specify the boot image (@@BT@@boot.img@@BT@@) created with NASM as a drive image.</p>\n<p>@@BT@@file@@BT@@ and @@BT@@format@@BT@@ are arguments for the @@BT@@-drive@@BT@@ option.</p>\n<p>@@BT@@@@BT@@@bash\n-drive file=boot.img,format=raw\n@@BT@@@@BT@@</p>\n<p>The only required argument for @@BT@@-drive@@BT@@ is [file=file], but here I also specify format=raw.</p>\n<p>Even without format=raw, you can start QEMU in the CUI, but it will print the following warning:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">WARNING:\nImage format was not specified for '/haribote/boot.img' and probing guessed raw.Specify the 'raw' format explicitly to remove the restrictions.</code></pre></div>\n<p>Next is the @@BT@@-nographic@@BT@@ option. This is the option for starting QEMU in the CUI.\nAs the help says, it redirects serial I/O (data communicated between devices) to the console.</p>\n<h2 id=\"stopping-qemu-in-the-cui\" style=\"position:relative;\"><a href=\"#stopping-qemu-in-the-cui\" aria-label=\"stopping qemu in the cui permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Stopping QEMU in the CUI</h2>\n<p>Once QEMU has started in the CUI, return to the original console.\nTo return to the console, enter the following keys in sequence:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">Ctrl + A\nX</code></pre></div>\n<p>After pressing @@BT@@Ctrl + A@@BT@@, release the keys and then press @@BT@@X@@BT@@.\nThis will stop QEMU.</p>","fields":{"slug":"/diyos-30daysos-qemu-nographic-en","tagSlugs":["/tag/自作os/","/tag/30-日os/","/tag/qemu-en/","/tag/notes-en/","/tag/english/"]},"frontmatter":{"date":"2021-01-09","description":"An introduction to QEMU's nographic option for running a DIY OS in the CUI.","tags":["自作OS","30日OS","QEMU (en)","Notes (en)","English"],"title":"How to Use QEMU's nographic Option to Run a 30-Day OS Boot Image in the CUI","socialImage":{"publicURL":"/static/dc4d8b7f8795f3c3d3489d9957d155f2/no-image.png"}}}},"pageContext":{"slug":"/diyos-30daysos-qemu-nographic-en"}},"staticQueryHashes":["251939775","401334301","825871152"]}