更改

跳转至: 导航搜索

Orange Pi Zero 2W

添加1,635字节, 2023年9月20日 (三) 15:40
手动扩容TF卡中rootfs分区容量的方法
=== 手动扩容TF卡中rootfs分区容量的方法 ===
{| class="wikitable" style="background-color:#ffffdc;width:800px;" |-| <big>'''如果TF卡的总容量很大,比如为128GB,不想Linux系统rootfs分区使用TF卡所有的容量,只想分配一部分容量,比如16GB,给Linux系统使用,然后TF卡的剩余容量就可以用作其他用途。那么可以使用此小节介绍的内容来手动扩容TF中rootfs分区的容量。'''</big>|}
<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></ol>
<!-- -->
<ol start="5" style="list-style-type: decimal;">
<li><p>然后在Ubuntu电脑中安装下gparted这个软件</p>
{| class="wikitable" style="width:800px;" |-| <p>test@test:~$ '''sudo apt install -y gparted'''</p>|}</li>
<li><p>然后打开gparted</p>
{| class="wikitable" style="width:800px;" |-| <p>test@test:~$ '''sudo gparted'''</p>|}</li>
<li><p>打开gparted后在右上角可以选择TF卡,然后就可以看到TF卡容量的使用情况。下图显示的是烧录完Linux桌面版系统后TF卡的情况,可以看到,虽然TF卡的总容量是16GB的(在GParted中显示为14.84GiB),但是rootfs分区(/dev/sdc1)实际只分配了4.05GiB,还剩下10.79GiB未分配</p>
<p>[[File:media/image87.png]]</p></li>
<p>[[File:media/image97.png]]</p></li>
<li><p>然后就可以把TF卡拔下来,再插到开发板中启动,进入开发板的Linux系统中后如果使用'''df -h'''命令可以看到rootfs分区的大小和前面设置的大小一致的话就说明手动扩容成功</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>root@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">'''7.7G '''</span><span style="margin-right: 35px;color:#FF0000">'''3.2G '''</span><span style="margin-right: 80px;color:#FF0000">'''4.4G '''</span><span style="margin-right: 90px;color:#FF0000">'''42% /'''</pspan><br>|}</li></ol>
<span id="缩小tf卡中rootfs分区容量的方法"></span>
 
=== 缩小TF卡中rootfs分区容量的方法 ===
8,460
个编辑

导航菜单