打开主菜单

Wiki-Orange Pi β

更改

Orange Pi Zero 2W

添加2,599字节, 2023年9月20日 (三) 15:33
禁止自动扩容TF卡中rootfs分区容量的方法
<ol style="list-style-type: decimal;">
<li><p>首先在'''<span style="color:#FF0000">Ubuntu电脑</span>'''(Windows不行)中将开发板的linux镜像烧录到TF卡中,'''<span style="color:#FF0000">然后重新拔插下TF卡</span>'''</p></li>
<li><p>然后Ubuntu电脑一般会自动挂载TF卡的分区,如果自动挂载正常,使用ls命令可以看到下面的输出</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>test@test:~$ '''ls /media/test/opi_root/'''</p>
<p>bin &nbsp;&nbsp; boot &nbsp;&nbsp; dev &nbsp;&nbsp; etc &nbsp;&nbsp; home &nbsp;&nbsp; lib &nbsp;&nbsp; lost+found &nbsp;&nbsp; media &nbsp;&nbsp; mnt &nbsp;&nbsp; opt &nbsp;&nbsp; proc &nbsp;&nbsp; root &nbsp;&nbsp; run <br> sbin &nbsp;&nbsp; selinux &nbsp;&nbsp; srv &nbsp;&nbsp; sys &nbsp;&nbsp; tmp &nbsp;&nbsp; usr &nbsp;&nbsp; var</p>|}</li>
<li><p>然后在Ubuntu电脑中将当前用户切换成root用户</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>test@test:~$ '''sudo -i'''</p>
<p>[sudo] test 的密码:</p>
<p>root@test:~'''<span style="color:#FF0000">#</span>'''</p>|}</li>
<li><p>然后进入TF卡中的linux系统的root目录下新建一个名为'''.no_rootfs_resize'''的文件</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>root@test:~# '''cd /media/test/opi_root/'''</p>
<p>root@test:/media/test/opi_root/# '''cd root'''</p>
<p>root@test:/media/test/opi_root/root# '''touch .no_rootfs_resize'''</p>
<p>root@test:/media/test/opi_root/root# '''ls .no_rootfs*'''</p>
<p>'''.no_rootfs_resize'''</p>|}</li>
<li><p>然后就可以卸载TF卡,再拔出TF卡插到开发板中启动,linux系统启动时,当检测到'''/root'''目录下有'''.no_rootfs_resize'''这个文件就不会再自动扩容rootfs了</p></li>
<li><p>禁止rootfs自动扩容后进入Linux系统可以看到rootfs分区的总容量只有4GB(这里测试的是桌面版本的镜像),远小于TF卡的实际容量,说明禁止rootfs自动扩容成功</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>orangepi@orangepi:~$ '''df -h'''</p>
<pspan style="margin-right: 80px;">Filesystem </span><span style="margin-right: 50px;">Size </span><span style="margin-right: 30px;">Used </span><span style="margin-right: 30px;">Avail </span><span style="margin-right: 50px;">Use% Mounted on</pspan><br><pspan style="margin-right: 110px;">udev </span><span style="margin-right: 60px;">925M </span><span style="margin-right: 50px;">0 </span><span style="margin-right: 70px;">925M </span><span style="margin-right: 90px;">0% /dev</pspan><br><pspan style="margin-right: 100px;">tmpfs </span><span style="margin-right: 50px;">199M </span><span style="margin-right: 30px;">3.2M </span><span style="margin-right: 70px;">196M </span><span style="margin-right: 90px;">2% /run</pspan><br><pspan style="margin-right: 25px;color:#FF0000">'''/dev/mmcblk0p1 '''</span><span style="margin-right: 50px;color:#FF0000">'''4.0G '''</span><span style="margin-right: 35px;color:#FF0000">'''3.2G '''</span><span style="margin-right: 80px;color:#FF0000">'''686M '''</span><span style="margin-right: 90px;color:#FF0000">'''83% /'''</pspan><br>|}</li><li><p>如果需要重新扩容TF卡中rootfs分区的容量,只需要执行下面的命令,然后重新启动开发板的Linux系统即可</p></li></ol> '''注意,请在root用户下执行下面的命令。'''
{| class="wikitable" style="background-color:#ffffdc;width:800px;"
|-
|
<big>'''注意,请在<span style="color:#FF0000">root</span>用户下执行下面的命令。'''</big>
|}
{| class="wikitable" style="width:800px;"
|-
|
root@orangepi:~# '''rm /root/.no_rootfs_resize'''
root@orangepi:~# '''sudo reboot'''
|}
重启后再次进入开发板的Linux系统就可以看到rootfs分区已经扩展为TF卡的实际容量了
{| class="wikitable" style="width:800px;"|-|<p>root@orangepi:~# $ '''df -h'''</p> <span style="margin-right: 80px;">Filesystem </span><span style="margin-right: 50px;">Size </span><span style="margin-right: 30px;">Used </span><span style="margin-right: 30px;">Avail </span><span style="margin-right: 50px;">Use% Mounted on</span><br><span style="margin-right: 110px;">udev</span><span style="margin-right: 60px;">925M </span><span style="margin-right: 50px;">0</span><span style="margin-right: 70px;">925M </span><span style="margin-right: 90px;">0% /dev</span><br><span style="margin-right: 100px;">tmpfs </span><span style="margin-right: 50px;">199M </span><span style="margin-right: 30px;">3.2M </span><span style="margin-right: 70px;">196M </span><span style="margin-right: 90px;">2% /run</span><br><span style="margin-right: 25px;color:#FF0000">'''/dev/mmcblk0p1'''</span><span style="margin-right: 50px;color:#FF0000">'''15G'''</span><span style="margin-right: 35px;color:#FF0000">'''3.2G '''</span><span style="margin-right: 80px;color:#FF0000">'''12G '''</span><span style="margin-right: 90px;color:#FF0000">'''23% /'''</span><br>|}</li></ol><span id="手动扩容tf卡中rootfs分区容量的方法"></span>
udev 925M 0 925M 0% /dev
 
tmpfs 199M 3.2M 196M 2% /run
 
'''/dev/mmcblk0p1 15G 3.2G 12G 23% /'''
 
<span id="手动扩容tf卡中rootfs分区容量的方法"></span>
=== 手动扩容TF卡中rootfs分区容量的方法 ===
8,460
个编辑