<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Ubuntu Cloud Image on Uniguri&#39;s Blog</title>
    <link>/tags/ubuntu-cloud-image/</link>
    <description>Recent content in Ubuntu Cloud Image on Uniguri&#39;s Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Thu, 20 Mar 2025 10:21:37 +0000</lastBuildDate><atom:link href="/tags/ubuntu-cloud-image/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Create Simple Build VM Using Ubuntu Cloud</title>
      <link>/posts/recording/create-simple-build-vm-using-ubuntu-cloud/</link>
      <pubDate>Thu, 20 Mar 2025 10:21:37 +0000</pubDate>
      
      <guid>/posts/recording/create-simple-build-vm-using-ubuntu-cloud/</guid>
      <description>&lt;hr&gt;
&lt;h2 id=&#34;overview&#34;&gt;Overview&lt;/h2&gt;
&lt;p&gt;I had to build a kernel and an image for trying &lt;a href=&#34;https://github.com/Crusaders-of-Rust/corCTF-2022-public-challenge-archive/tree/master/pwn/corjail&#34;&gt;CorJail&lt;/a&gt;.
But the building was not completed in my environment (WSL2 on Windows 11).
I think I will be comfortable if I have a linux VM for a building linux kernel, file system image, and etc.&lt;/p&gt;
&lt;h2 id=&#34;step&#34;&gt;Step&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Select Ubuntu version and download its image on &lt;a href=&#34;https://cloud-images.ubuntu.com/&#34;&gt;here&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Install &lt;code&gt;cloud-init&lt;/code&gt;, &lt;code&gt;cloud-utils&lt;/code&gt; and &lt;code&gt;qemu-system&lt;/code&gt;
&lt;ol&gt;
&lt;li&gt;You can install them by &lt;code&gt;sudo apt install -y cloud-init cloud-utils qemu-system&lt;/code&gt; on Debian/Ubuntu.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;Generate a RSA key using &lt;code&gt;ssh-keygen -t rsa&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Set up config file and create seed.img
&lt;ol&gt;
&lt;li&gt;To create config files, see config files section&lt;/li&gt;
&lt;li&gt;Create seed.img via &lt;code&gt;cloud-localds seed.img user-data.yaml metadata.yaml&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;Set shared foldder and run qemu&lt;/li&gt;
&lt;li&gt;In guest OS, add &lt;code&gt;shared /shared 9p trans=virtio,version=9p2000.L,access=any 0 0&lt;/code&gt; to &lt;code&gt;/etc/fstab&lt;/code&gt;
&lt;ol&gt;
&lt;li&gt;After addition type &lt;code&gt;sudo systemctl daemon-reload &amp;amp;&amp;amp; sudo systemctl restart local-fs.target &amp;amp;&amp;amp; sudo mount -a&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Then if you need more space for a qemu drive, use &lt;code&gt;qemu-img resize&lt;/code&gt;.&lt;/p&gt;</description>
      <content>&lt;hr&gt;
&lt;h2 id=&#34;overview&#34;&gt;Overview&lt;/h2&gt;
&lt;p&gt;I had to build a kernel and an image for trying &lt;a href=&#34;https://github.com/Crusaders-of-Rust/corCTF-2022-public-challenge-archive/tree/master/pwn/corjail&#34;&gt;CorJail&lt;/a&gt;.
But the building was not completed in my environment (WSL2 on Windows 11).
I think I will be comfortable if I have a linux VM for a building linux kernel, file system image, and etc.&lt;/p&gt;
&lt;h2 id=&#34;step&#34;&gt;Step&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Select Ubuntu version and download its image on &lt;a href=&#34;https://cloud-images.ubuntu.com/&#34;&gt;here&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Install &lt;code&gt;cloud-init&lt;/code&gt;, &lt;code&gt;cloud-utils&lt;/code&gt; and &lt;code&gt;qemu-system&lt;/code&gt;
&lt;ol&gt;
&lt;li&gt;You can install them by &lt;code&gt;sudo apt install -y cloud-init cloud-utils qemu-system&lt;/code&gt; on Debian/Ubuntu.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;Generate a RSA key using &lt;code&gt;ssh-keygen -t rsa&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Set up config file and create seed.img
&lt;ol&gt;
&lt;li&gt;To create config files, see config files section&lt;/li&gt;
&lt;li&gt;Create seed.img via &lt;code&gt;cloud-localds seed.img user-data.yaml metadata.yaml&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;Set shared foldder and run qemu&lt;/li&gt;
&lt;li&gt;In guest OS, add &lt;code&gt;shared /shared 9p trans=virtio,version=9p2000.L,access=any 0 0&lt;/code&gt; to &lt;code&gt;/etc/fstab&lt;/code&gt;
&lt;ol&gt;
&lt;li&gt;After addition type &lt;code&gt;sudo systemctl daemon-reload &amp;amp;&amp;amp; sudo systemctl restart local-fs.target &amp;amp;&amp;amp; sudo mount -a&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Then if you need more space for a qemu drive, use &lt;code&gt;qemu-img resize&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;config-flies&#34;&gt;Config flies&lt;/h3&gt;



  &lt;div class=&#34;collapsable-code&#34;&gt;
    &lt;input id=&#34;697213458&#34; type=&#34;checkbox&#34;  /&gt;
    &lt;label for=&#34;697213458&#34;&gt;
      &lt;span class=&#34;collapsable-code__language&#34;&gt;yaml&lt;/span&gt;
      &lt;span class=&#34;collapsable-code__title&#34;&gt;metadata.yml&lt;/span&gt;
      &lt;span class=&#34;collapsable-code__toggle&#34; data-label-expand=&#34;Show&#34; data-label-collapse=&#34;Hide&#34;&gt;&lt;/span&gt;
    &lt;/label&gt;
    &lt;pre class=&#34;language-yaml&#34; &gt;&lt;code&gt;
instance-id: &amp;lt;instance-name&amp;gt;
local-hostname: &amp;lt;host-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;





  &lt;div class=&#34;collapsable-code&#34;&gt;
    &lt;input id=&#34;139842576&#34; type=&#34;checkbox&#34;  /&gt;
    &lt;label for=&#34;139842576&#34;&gt;
      &lt;span class=&#34;collapsable-code__language&#34;&gt;yaml&lt;/span&gt;
      &lt;span class=&#34;collapsable-code__title&#34;&gt;user-data.yml&lt;/span&gt;
      &lt;span class=&#34;collapsable-code__toggle&#34; data-label-expand=&#34;Show&#34; data-label-collapse=&#34;Hide&#34;&gt;&lt;/span&gt;
    &lt;/label&gt;
    &lt;pre class=&#34;language-yaml&#34; &gt;&lt;code&gt;
#cloud-config
user: &amp;lt;user-id&amp;gt;
password: &amp;lt;password&amp;gt;
chpasswd: {expire: False}
ssh_pwauth: True
ssh_authorized_keys: &amp;lt;rsa-pub&amp;gt; &amp;lt;username@domain&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;


&lt;h3 id=&#34;run-qemu&#34;&gt;Run QEMU&lt;/h3&gt;



  &lt;div class=&#34;collapsable-code&#34;&gt;
    &lt;input id=&#34;376954128&#34; type=&#34;checkbox&#34;  /&gt;
    &lt;label for=&#34;376954128&#34;&gt;
      &lt;span class=&#34;collapsable-code__language&#34;&gt;bash&lt;/span&gt;
      &lt;span class=&#34;collapsable-code__title&#34;&gt;run.sh&lt;/span&gt;
      &lt;span class=&#34;collapsable-code__toggle&#34; data-label-expand=&#34;Show&#34; data-label-collapse=&#34;Hide&#34;&gt;&lt;/span&gt;
    &lt;/label&gt;
    &lt;pre class=&#34;language-bash&#34; &gt;&lt;code&gt;
#!/bin/bash

SCRIPT_DIR=$(dirname &amp;#34;$(realpath &amp;#34;${BASH_SOURCE[0]}&amp;#34;)&amp;#34;)

qemu-system-x86_64  \
  -enable-kvm \
  -m 16G \
  -smp 8 \
  -nographic \
  -device virtio-net-pci,netdev=net0 \
  -netdev user,id=net0,hostfwd=tcp::2222-:22 \
  -drive if=virtio,format=qcow2,file=&amp;#34;$SCRIPT_DIR/&amp;lt;your-cloud-image-path&amp;gt;&amp;#34; \
  -drive if=virtio,format=raw,file=&amp;#34;$SCRIPT_DIR/&amp;lt;your-seed-image-path&amp;gt;&amp;#34; \
  -virtfs local,path=&amp;#34;$SCRIPT_DIR/&amp;lt;your-shared-directory-path&amp;gt;&amp;#34;,mount_tag=shared,security_model=none \
&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;


&lt;h2 id=&#34;reference&#34;&gt;Reference&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://cloud-images.ubuntu.com/&#34;&gt;https://cloud-images.ubuntu.com/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://powersj.io/posts/ubuntu-qemu-cli/&#34;&gt;https://powersj.io/posts/ubuntu-qemu-cli/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
    </item>
    
  </channel>
</rss>
