<?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>TF卡 &#8211; 编码无悔 /  Intent &amp; Focused</title>
	<atom:link href="https://www.codelast.com/tag/tf%e5%8d%a1/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.codelast.com</link>
	<description>最优化之路</description>
	<lastBuildDate>Mon, 27 Apr 2020 17:52:53 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>[原创] 在Ubuntu上使用GParted来调整树莓派TF卡的分区大小</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8ubuntu%e4%b8%8a%e4%bd%bf%e7%94%a8gparted%e6%9d%a5%e8%b0%83%e6%95%b4%e6%a0%91%e8%8e%93%e6%b4%betf%e5%8d%a1%e7%9a%84%e5%88%86%e5%8c%ba%e5%a4%a7%e5%b0%8f/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8ubuntu%e4%b8%8a%e4%bd%bf%e7%94%a8gparted%e6%9d%a5%e8%b0%83%e6%95%b4%e6%a0%91%e8%8e%93%e6%b4%betf%e5%8d%a1%e7%9a%84%e5%88%86%e5%8c%ba%e5%a4%a7%e5%b0%8f/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Tue, 18 Jul 2017 17:59:48 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Raspberry Pi/树莓派]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[GParted]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[resize partition]]></category>
		<category><![CDATA[TF卡]]></category>
		<category><![CDATA[树莓派]]></category>
		<category><![CDATA[调整分区大小]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=9536</guid>

					<description><![CDATA[<p>
OS：Ubuntu 14.04 LTS</p>
<p>树莓派的操作系统存储在一张TF卡中，如果我们要备份它，只需要简单地在Ubuntu上使用如下命令即可：</p>
<pre style="margin-top: 0px; margin-bottom: 0px; font-stretch: normal; font-size: 0.9333em; line-height: 1.5em; font-family: Consolas, &#34;Lucida Console&#34;, &#34;DejaVu Sans Mono&#34;, Monaco, &#34;Courier New&#34;, monospace; background: rgb(255, 255, 255);">
sudo dd <span style="color: rgb(255, 120, 0);">if</span>=/dev/sdb of=<span style="color: rgb(255, 120, 0);">~</span>/raspberry_pi_os_backup</pre>
<p>其中，/dev/sdb 是我的TF卡的设备名称。这样我们就可以把TF卡备份到 raspberry_pi_os_backup 这个文件中了。<br />
<span id="more-9536"></span><br />
如果我们想把该备份恢复到一张新的TF卡上，也只需要在Ubuntu上使用如下命令：</p>
<pre style="margin-top: 0px; margin-bottom: 0px; font-stretch: normal; font-size: 0.9333em; line-height: 1.5em; font-family: Consolas, &#34;Lucida Console&#34;, &#34;DejaVu Sans Mono&#34;, Monaco, &#34;Courier New&#34;, monospace; background: rgb(255, 255, 255);">
sudo dd <span style="color: rgb(255, 120, 0);">if</span>=<span style="color: rgb(255, 120, 0);">~</span>/raspberry_pi_os_backup of=/dev/sdb</pre>
<p>其中，/dev/sdb 是我的新TF卡的设备名称。这样就可以把备份的OS写到新TF卡中了。</p>
<p>谁都知道重新安装OS并配置好各种软件的工作量实在是太大了，而上面的方法为我们提供了一个快速复制现有的树莓派系统的途径，因此特别实用。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
但是，这样做有一个问题：假设原系统是装在8G的TF卡上，而新TF卡是16G的，那么，你用上面的方法操作完之后，再把新卡插回同一个树莓派上，再用 <span style="color:#0000ff;">df -h</span> 来查看TF卡容量信息，可能会发现它竟然只有 8G！剩下的8G不知怎么就被&#8220;吃掉&#8221;了。</p>
<p>要解决这个&#8220;诡异&#8221;的问题，其实有一个非常方便的办法，就是在Ubuntu上使用GParted软件来调整TF卡的分区容量。二话不说下面我们就直接开始。<br />
<span style="background-color:#00ff00;">『1』</span>安装GParted软件<br />
一行命令搞定：</p>
<blockquote>
<p>
		sudo apt-get install gparted</p>
</blockquote>
<p><span style="background-color:#00ff00;">『2』</span>准备工作<br />
把新TF卡用USB适配器插到台式机上，打开GParted软件，在软件右上方的下拉框中选择你的TF卡对应的存储设备（我这里是 /dev/sdb），你会看到类似于下面这样的界面：<br />
<a href="https://www.codelast.com" target="_blank" rel="noopener noreferrer"><img decoding="async" alt="gparted resize tf card" src="https://www.codelast.com/wp-content/uploads/2017/07/gparted_resize_tf_card_1.png" style="text-align: center; width: 775px; height: 528px;" /></a><br />
在这里，我的新TF卡是16G的，而备份的树莓派OS是从8G的TF卡备份出来的，所以正如前面所说，有8G被&#8220;吃掉&#8221;了，从GParted里可以清晰地看到那被&#8220;吃掉&#8221;的8G空间，显示成了&#8220;未分配&#8221;空间。我们正是要把这部分空间，和它之前的 /dev/sdb2 分区合并成一个分区，或者说把 /dev/sdb2 分区扩大成整个TF卡的可用空间那么大。<br />
在进一步操作GParted之前，我们需要确保TF卡上的几个分区是&#8220;卸载&#8221;的状态，因为挂载的状态是无法进行后续操作的。<br />
卸载方法是：在除了&#8220;未分配&#8221;之外的其他所有分区上，鼠标右键点击，在弹出的菜单里，只要能看到&#8220;<span style="color:#0000ff;">卸载</span>&#8221;菜单项的，都点击&#8220;卸载&#8221;，这样就OK了。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8ubuntu%e4%b8%8a%e4%bd%bf%e7%94%a8gparted%e6%9d%a5%e8%b0%83%e6%95%b4%e6%a0%91%e8%8e%93%e6%b4%betf%e5%8d%a1%e7%9a%84%e5%88%86%e5%8c%ba%e5%a4%a7%e5%b0%8f/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>
OS：Ubuntu 14.04 LTS</p>
<p>树莓派的操作系统存储在一张TF卡中，如果我们要备份它，只需要简单地在Ubuntu上使用如下命令即可：</p>
<pre style="margin-top: 0px; margin-bottom: 0px; font-stretch: normal; font-size: 0.9333em; line-height: 1.5em; font-family: Consolas, &quot;Lucida Console&quot;, &quot;DejaVu Sans Mono&quot;, Monaco, &quot;Courier New&quot;, monospace; background: rgb(255, 255, 255);">
sudo dd <span style="color: rgb(255, 120, 0);">if</span>=/dev/sdb of=<span style="color: rgb(255, 120, 0);">~</span>/raspberry_pi_os_backup</pre>
<p>其中，/dev/sdb 是我的TF卡的设备名称。这样我们就可以把TF卡备份到 raspberry_pi_os_backup 这个文件中了。<br />
<span id="more-9536"></span><br />
如果我们想把该备份恢复到一张新的TF卡上，也只需要在Ubuntu上使用如下命令：</p>
<pre style="margin-top: 0px; margin-bottom: 0px; font-stretch: normal; font-size: 0.9333em; line-height: 1.5em; font-family: Consolas, &quot;Lucida Console&quot;, &quot;DejaVu Sans Mono&quot;, Monaco, &quot;Courier New&quot;, monospace; background: rgb(255, 255, 255);">
sudo dd <span style="color: rgb(255, 120, 0);">if</span>=<span style="color: rgb(255, 120, 0);">~</span>/raspberry_pi_os_backup of=/dev/sdb</pre>
<p>其中，/dev/sdb 是我的新TF卡的设备名称。这样就可以把备份的OS写到新TF卡中了。</p>
<p>谁都知道重新安装OS并配置好各种软件的工作量实在是太大了，而上面的方法为我们提供了一个快速复制现有的树莓派系统的途径，因此特别实用。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
但是，这样做有一个问题：假设原系统是装在8G的TF卡上，而新TF卡是16G的，那么，你用上面的方法操作完之后，再把新卡插回同一个树莓派上，再用 <span style="color:#0000ff;">df -h</span> 来查看TF卡容量信息，可能会发现它竟然只有 8G！剩下的8G不知怎么就被&ldquo;吃掉&rdquo;了。</p>
<p>要解决这个&ldquo;诡异&rdquo;的问题，其实有一个非常方便的办法，就是在Ubuntu上使用GParted软件来调整TF卡的分区容量。二话不说下面我们就直接开始。<br />
<span style="background-color:#00ff00;">『1』</span>安装GParted软件<br />
一行命令搞定：</p>
<blockquote>
<p>
		sudo apt-get install gparted</p>
</blockquote>
<p><span style="background-color:#00ff00;">『2』</span>准备工作<br />
把新TF卡用USB适配器插到台式机上，打开GParted软件，在软件右上方的下拉框中选择你的TF卡对应的存储设备（我这里是 /dev/sdb），你会看到类似于下面这样的界面：<br />
<a href="https://www.codelast.com" target="_blank" rel="noopener noreferrer"><img decoding="async" alt="gparted resize tf card" src="https://www.codelast.com/wp-content/uploads/2017/07/gparted_resize_tf_card_1.png" style="text-align: center; width: 775px; height: 528px;" /></a><br />
在这里，我的新TF卡是16G的，而备份的树莓派OS是从8G的TF卡备份出来的，所以正如前面所说，有8G被&ldquo;吃掉&rdquo;了，从GParted里可以清晰地看到那被&ldquo;吃掉&rdquo;的8G空间，显示成了&ldquo;未分配&rdquo;空间。我们正是要把这部分空间，和它之前的 /dev/sdb2 分区合并成一个分区，或者说把 /dev/sdb2 分区扩大成整个TF卡的可用空间那么大。<br />
在进一步操作GParted之前，我们需要确保TF卡上的几个分区是&ldquo;卸载&rdquo;的状态，因为挂载的状态是无法进行后续操作的。<br />
卸载方法是：在除了&ldquo;未分配&rdquo;之外的其他所有分区上，鼠标右键点击，在弹出的菜单里，只要能看到&ldquo;<span style="color:#0000ff;">卸载</span>&rdquo;菜单项的，都点击&ldquo;卸载&rdquo;，这样就OK了。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a></p>
<div>
	<span style="background-color:#00ff00;">『3』</span>调整分区大小<br />
	右键点击 /dev/sdb2 那个分区，在弹出菜单中选择&ldquo;<span style="color:#0000ff;">更改大小/移动</span>&rdquo;，会弹出下面的对话框：<br />
	<a href="https://www.codelast.com" target="_blank" rel="noopener noreferrer"><img decoding="async" alt="gparted resize tf card" src="https://www.codelast.com/wp-content/uploads/2017/07/gparted_resize_tf_card_2.png" style="text-align: center; width: 554px; height: 315px;" /></a></p>
<p>	通过拉动上方白框里的右箭头，我们就可以调整这个分区的大小了。我把它拉到了最右边，使得这个分区使用全部的可用空间：<br />
	<a href="https://www.codelast.com" target="_blank" rel="noopener noreferrer"><img decoding="async" alt="gparted resize tf card" src="https://www.codelast.com/wp-content/uploads/2017/07/gparted_resize_tf_card_3.png" style="text-align: center; width: 554px; height: 315px;" /></a><br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	之后点击右下方的&ldquo;调整大小/移动&rdquo;按钮，就会回到GParted主界面了：<br />
	<a href="https://www.codelast.com" target="_blank" rel="noopener noreferrer"><img decoding="async" alt="gparted resize tf card" src="https://www.codelast.com/wp-content/uploads/2017/07/gparted_resize_tf_card_4.png" style="text-align: center; width: 775px; height: 528px;" /></a><br />
	此时可以看到，/dev/sdb2 的大小已经扩展到了全部可用空间，之前的&ldquo;未分配&rdquo;空间消失了。<br />
	但是请注意：<span style="color:#ff0000;">此时分区调整实际上还没有生效</span>，左下角的&ldquo;<span style="color:#0000ff;">1个操作待进行</span>&rdquo;提示了这一点。我们需要点击GParted主界面上方的<span style="color:#0000ff;">勾号</span>（<span style="color:#008000;"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2714.png" alt="✔" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span>）来执行操作。<br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="background-color:#00ff00;">『4』</span>完成操作<br />
	开始执行操作后，一般来说，你应该会看到下面这样的界面：<br />
	<a href="https://www.codelast.com" target="_blank" rel="noopener noreferrer"><img decoding="async" alt="gparted resize tf card" src="https://www.codelast.com/wp-content/uploads/2017/07/gparted_resize_tf_card_5.png" style="text-align: center; width: 700px; height: 317px;" /></a><br />
	但是，GParted也有可能立即报错，告诉你无法执行，此时，如果你右键点击 /dev/sdb2 并在菜单中选择&ldquo;信息&rdquo;，在弹出的对话框中，可能会看到类似于下面这样的信息：</div>
<blockquote>
<div>
		e2label: No such file or directory while trying to open /dev/sdb2</div>
<div>
		Couldn&#39;t find valid filesystem superblock.</div>
<div>
		&nbsp;</div>
<div>
		tune2fs 1.42.9 (4-Feb-2014)</div>
<div>
		&nbsp;</div>
<div>
		tune2fs: No such file or directory while trying to open /dev/sdb2</div>
<div>
		Couldn&#39;t find valid filesystem superblock.</div>
<div>
		&nbsp;</div>
<div>
		Couldn&#39;t find valid filesystem superblock.</div>
<div>
		&nbsp;</div>
<div>
		dumpe2fs 1.42.9 (4-Feb-2014)</div>
<div>
		dumpe2fs: No such file or directory while trying to open /dev/sdb2</div>
<div>
		&nbsp;</div>
<div>
		无法读取此文件系统上的内容!</div>
<div>
		因为此操作可能不可用。</div>
<div>
		原因可能是缺少某个软件包。</div>
<div>
		支持 ext4 文件系统需要下列软件包：e2fsprogs v1.41+。</div>
</blockquote>
<div>
	出现这个错误的话，可能是由于操作不对造成的，并非像错误提示里写的那样缺少软件包（我的Ubuntu上就一个都不缺）&mdash;&mdash;貌似刚把备份的OS恢复到TF卡上，需要重新插拔一次，才能用GParted调整分区大小。<br />
	你可以尝试着把TF卡从Ubuntu台式机上拔掉，然后再重新插入USB接口上，重做一遍试试。<br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	如果一切可以正常进行下去，应该是类似于下面这样的界面：<br />
	<a href="https://www.codelast.com" target="_blank" rel="noopener noreferrer"><img decoding="async" alt="gparted resize tf card" src="https://www.codelast.com/wp-content/uploads/2017/07/gparted_resize_tf_card_6.png" style="text-align: center; width: 724px; height: 567px;" /></a></p>
<p>	全部完成之后：<br />
	<a href="https://www.codelast.com" target="_blank" rel="noopener noreferrer"><img decoding="async" alt="gparted resize tf card" src="https://www.codelast.com/wp-content/uploads/2017/07/gparted_resize_tf_card_7.png" style="text-align: center; width: 724px; height: 567px;" /></a></p>
<p>	此时，再回到GParted主界面，就会看到 /dev/sdb2 已经被成功地调整成了14G大小，并且左下方的&ldquo;<span style="color:#0000ff;">0个操作待进行</span>&rdquo;表明我们真的执行完了调整分区大小的操作：<br />
	<img decoding="async" alt="gparted resize tf card" src="https://www.codelast.com/wp-content/uploads/2017/07/gparted_resize_tf_card_8.png" style="text-align: center; width: 775px; height: 528px;" /><br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="background-color:#00ff00;">『5』</span>在树莓派上验证新卡分区调整结果<br />
	把调整过分区的新TF卡插到树莓派上，成功进入系统！<br />
	再看一下剩余空间：</p>
<blockquote>
<div>
			[root@alarmpi ~]# df -h ./</div>
<div>
			Filesystem &nbsp; &nbsp; &nbsp;Size &nbsp;Used Avail Use% Mounted on</div>
<div>
			/dev/root &nbsp; &nbsp; &nbsp; &nbsp;14G &nbsp;5.1G &nbsp;8.0G &nbsp;39% /</div>
</blockquote>
<p>	搞定。</p>
<p>	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
	转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
	感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
		<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8ubuntu%e4%b8%8a%e4%bd%bf%e7%94%a8gparted%e6%9d%a5%e8%b0%83%e6%95%b4%e6%a0%91%e8%8e%93%e6%b4%betf%e5%8d%a1%e7%9a%84%e5%88%86%e5%8c%ba%e5%a4%a7%e5%b0%8f/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
