<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>UI 網站 &#187; LXC</title>
	<atom:link href="http://ui.idv.tw/wordpress/?feed=rss2&#038;tag=lxc" rel="self" type="application/rss+xml" />
	<link>https://ui.idv.tw/wordpress</link>
	<description>個人雜亂筆記用</description>
	<lastBuildDate>Wed, 15 Oct 2025 10:08:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>LXC:將特權 LXC 轉換為 非特權 LXC 並開機使用-只可以用在 zfs</title>
		<link>https://ui.idv.tw/wordpress/?p=1625</link>
		<comments>https://ui.idv.tw/wordpress/?p=1625#comments</comments>
		<pubDate>Tue, 13 May 2025 01:12:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[未分類]]></category>
		<category><![CDATA[LXC]]></category>

		<guid isPermaLink="false">https://ui.idv.tw/wordpress/?p=1625</guid>
		<description><![CDATA[https://pvecli.xuan2host.com/proxmox-privileged-to-unprivileged-lxc/ #!/bin/bash ## ## Warning: do not use this unless you understand and agree with what it does ## ## Based on: https://forum.proxmox.com/threads/convert-privileged-to-unprivileged-container.31066/#post-261883 ## ## NOT HANDLED ## * multiple disks ## * if there are backup/snapshot references in the &#8230; <a href="https://ui.idv.tw/wordpress/?p=1625">繼續閱讀 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>https://pvecli.xuan2host.com/proxmox-privileged-to-unprivileged-lxc/</p>
<p>#!/bin/bash<br />
##<br />
## Warning: do not use this unless you understand and agree with what it does<br />
##<br />
## Based on: https://forum.proxmox.com/threads/convert-privileged-to-unprivileged-container.31066/#post-261883<br />
##<br />
## NOT HANDLED<br />
## * multiple disks<br />
## * if there are backup/snapshot references in the lxc/$vmid.conf the unprivileged:1 will be added to the end of the file and in a backup config not in the active config, that can break the first boot<br />
## * setuid and setgid permissions are not retained</p>
<p># CONFIGURE THIS (the pool on which subvol-NNN-disk-0&#8242;s exist):<br />
vol=rpool/data<br />
vmid=$1<br />
TODAY=$(date +"%Y%m%d")<br />
if [ "$vmid" == "" ];<br />
then<br />
        echo "Usage is: $0 vmid";<br />
        exit 1<br />
fi</p>
<p>echo "stopping vm $vmid"<br />
pct stop $vmid</p>
<p>echo "taking snapshot"<br />
zfs snapshot $vol/subvol-$vmid-disk-1@mkunpriv-$TODAY</p>
<p>echo "chowning files, sockets and pipes"<br />
find /$vol/subvol-$vmid-disk-0/ -type f -or -type s -or -type p | while read S; do U="$(ls -ln "${S}" | awk &#8216;{print$3}&#8217;)"; G="$(ls -ln "${S}" | awk &#8216;{print$4}&#8217;)"; F=100000; chown "${F:0: -${#U}}${U}:${F:0: -${#G}}${G}" "${S}"; done</p>
<p>echo "chowning symlinks"<br />
find /$vol/subvol-$vmid-disk-0/ -type l | while read S; do U="$(ls -ln "${S}" | awk &#8216;{print$3}&#8217;)"; G="$(ls -ln "${S}" | awk &#8216;{print$4}&#8217;)"; F=100000; chown -h "${F:0: -${#U}}${U}:${F:0: -${#G}}${G}" "${S}"; done</p>
<p>echo "chowning directores"<br />
find /$vol/subvol-$vmid-disk-0/ -type d | while read S; do U="$(ls -lnd "${S}" | awk &#8216;{print$3}&#8217;)"; G="$(ls -lnd "${S}" | awk &#8216;{print$4}&#8217;)"; F=100000; chown "${F:0: -${#U}}${U}:${F:0: -${#G}}${G}" "${S}"; done</p>
<p>echo "fixing postfix if necessary"<br />
[ -e /$vol/subvol-$vmid-disk-1/var/spool/postfix/dev/-random ] &#038;&#038; rm -ri /$vol/subvol-$vmid-disk-1/var/spool/postfix/dev/-random<br />
[ -e /$vol/subvol-$vmid-disk-1/var/spool/postfix/dev/-urandom ] &#038;&#038; rm -ri /$vol/subvol-$vmid-disk-1/var/spool/postfix/dev/-urandom</p>
<p>echo "setting suid on sudo"<br />
[ -e /$vol/subvol-$vmid-disk-1/usr/bin/sudo ] &#038;&#038; chmod u+s /$vol/subvol-$vmid-disk-1/usr/bin/sudo</p>
<p>echo "enabling unprivileged setting on vm config"<br />
echo -e "\nunprivileged: 1&#8243; >> /etc/pve/lxc/$vmid.conf</p>
<p>echo "starting vm $vmid"<br />
pct start $vmid</p>
]]></content:encoded>
			<wfw:commentRss>https://ui.idv.tw/wordpress/?feed=rss2&#038;p=1625</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
