<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:wfw="http://wellformedweb.org/CommentAPI/">
<channel>
<title>dwt&#039;s life - lxc</title>
<link>https://dwt.life/tag/lxc/</link>
<atom:link href="https://dwt.life/feed/tag/lxc/" rel="self" type="application/rss+xml" />
<language>zh-CN</language>
<description></description>
<lastBuildDate>Sun, 09 Apr 2023 18:29:00 +0800</lastBuildDate>
<pubDate>Sun, 09 Apr 2023 18:29:00 +0800</pubDate>
<item>
<title>LXD 创建LVM以及手动指定IP （centos安装）</title>
<link>https://dwt.life/archives/326/</link>
<guid>https://dwt.life/archives/326/</guid>
<pubDate>Sun, 09 Apr 2023 18:29:00 +0800</pubDate>
<dc:creator>Ricky</dc:creator>
<description><![CDATA[Centos安装参考，zfs可以不用运行，因为使用的lvm，需要把lvm的操作提前进行：# Install snapdyum install yum-plugin-copr epel-relea...]]></description>
<content:encoded xml:lang="zh-CN"><![CDATA[
<p>Centos安装参考，zfs可以不用运行，因为使用的lvm，需要把lvm的操作提前进行：</p><pre><code class="lang-shell"># Install snapd
yum install yum-plugin-copr epel-release -y
yum copr enable ngompa/snapcore-el7 -y
yum install snapd -y
service snapd start
systemctl enable --now snapd.socket

# Install ZFS (skip if you don&#039;t want it)
yum install http://download.zfsonlinux.org/epel/zfs-release.el7_4.noarch.rpm
yum-config-manager --disable zfs
yum-config-manager --enable zfs-kmod
yum install zfs

# Configure the kernel
grubby --args=&quot;user_namespace.enable=1&quot; --update-kernel=&quot;$(grubby --default-kernel)&quot;
grubby --args=&quot;namespace.unpriv_enable=1&quot; --update-kernel=&quot;$(grubby --default-kernel)&quot;
echo &quot;user.max_user_namespaces=3883&quot; &gt; /etc/sysctl.d/99-userns.conf
reboot

# Install the LXD snap
snap install lxd

# source一下环境变量，因为刚安装还没生效
source /etc/profile

# Configure LXD
lxd init

# Launch containers
lxc launch ubuntu:16.04 c1
</code></pre><h3>关于超售部分：</h3><blockquote>超售主要需要增加内存，一般是使用swap，swap参考：<a href="https://zhuanlan.zhihu.com/p/399986218">https://zhuanlan.zhihu.com/p/399986218</a><br>需要 <code>cat /proc/cmdline| grep swap</code> 查看swapaccount是否存在且为1<br><a href="https://blog.csdn.net/qq_27037443/article/details/100050978">https://blog.csdn.net/qq_27037443/article/details/100050978</a></blockquote><p>开启步骤<br>开启 memory and swap on system 使用 GNU GRUB (GNU GRand Unified Bootloader)，步骤如下:</p><p>使用具有 sudo 权限的用户登录你的系统。<br>编辑 <code>/etc/default/grub</code> 文件。<br>设置 GRUB_CMDLINE_LINUX 的值如下：<br>GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"</p><p>保存并关闭文件。<br>更新 GRUB。<br><code>sudo update-grub &amp;&amp; reboot</code></p><p>需要把磁盘先进行分区，可以不用mkfs，直接fdisk /dev/nvme1n1，n p 1 回车回车 wq即可</p><h3>大于2T的磁盘需要parted改成gpt</h3><pre><code>parted /dev/nvme1n1
mklabel GPT
mkpart primary 0% 100%
quit
partprobe</code></pre><p>然后安装：<br><code>sudo yum install lvm2 device-mapper-persistent-data</code></p><p>1、先创建pv</p><pre><code>pvcreate /dev/nvme1n1p1</code></pre><p>2、创建vg</p><pre><code>vgcreate lxd_vg /dev/nvme1n1p1</code></pre><p>3、lxd增加存储</p><pre><code>lxc storage add lxd_pool lvm source=lxd_vg</code></pre><p>4、检查添加成功没</p><pre><code>lxc storage ls</code></pre><p>5、此时可以控制容量了</p><pre><code>lxc config device override instance-name root size=4GB</code></pre><p>5、手动指定IP</p><pre><code>lxc network attach lxdbr0 a eth0 eth0
lxc config device set a eth0 ipv4.address 192.168.122.10</code></pre><p>任何device的修改都需要restart容器<br>测试</p><pre><code>dd if=/dev/zero of=/data01/test.dbf bs=8k count=200000 conv=fdatasync</code></pre><p>6、IPv6设置<br><code>lxc network set lxdbr0 ipv6.address=2a12:aaaa:aaaa::1/64 ipv6.nat=false</code></p><p>7、其他限制</p><pre><code>lxc config set a limits.cpu 1
lxc config set a limits.memory 512MB
lxc config set a limits.cpu.allowance 30%</code></pre><p><img src="https://pic.peo.pw/a/2023/04/09/6432938eed508.png" alt="2852662508.png" title="2852662508.png"></p><p>参考：<br><a href="https://discuss.linuxcontainers.org/t/lxd-on-centos-7/1250">https://discuss.linuxcontainers.org/t/lxd-on-centos-7/1250</a><br><a href="https://discuss.linuxcontainers.org/t/using-static-ips-with-lxd/1291/5">https://discuss.linuxcontainers.org/t/using-static-ips-with-lxd/1291/5</a><br><a href="https://discuss.linuxcontainers.org/t/how-to-set-root-device-size-when-creating-new-instance/15911/2">https://discuss.linuxcontainers.org/t/how-to-set-root-device-size-when-creating-new-instance/15911/2</a></p>
]]></content:encoded>
<slash:comments>0</slash:comments>
<comments>https://dwt.life/archives/326/#comments</comments>
<wfw:commentRss>https://dwt.life/feed/tag/lxc/</wfw:commentRss>
</item>
<item>
<title>LXD 强行删除默认存储</title>
<link>https://dwt.life/archives/254/</link>
<guid>https://dwt.life/archives/254/</guid>
<pubDate>Thu, 07 Jul 2022 21:56:07 +0800</pubDate>
<dc:creator>Ricky</dc:creator>
<description><![CDATA[printf &#039;config: {}\ndevices: {}&#039; | lxc profile edit defaultlxc storage delete defaultht...]]></description>
<content:encoded xml:lang="zh-CN"><![CDATA[
<p><code>printf &#039;config: {}\ndevices: {}&#039; | lxc profile edit default</code><br><code>lxc storage delete default</code><br><a href="https://stackoverflow.com/questions/42678979/how-to-remove-default-lxd-storage">https://stackoverflow.com/questions/42678979/how-to-remove-default-lxd-storage</a></p>
]]></content:encoded>
<slash:comments>0</slash:comments>
<comments>https://dwt.life/archives/254/#comments</comments>
<wfw:commentRss>https://dwt.life/feed/tag/lxc/</wfw:commentRss>
</item>
</channel>
</rss>