<?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>GParted &#8211; 编码无悔 /  Intent &amp; Focused</title>
	<atom:link href="https://www.codelast.com/tag/gparted/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.codelast.com</link>
	<description>最优化之路</description>
	<lastBuildDate>Mon, 18 Oct 2021 18:29:28 +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>[原创] 扩展VirtualBox虚拟机的磁盘空间(vdi文件)</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e6%89%a9%e5%b1%95virtualbox%e8%99%9a%e6%8b%9f%e6%9c%ba%e7%9a%84%e7%a3%81%e7%9b%98%e7%a9%ba%e9%97%b4vdi%e6%96%87%e4%bb%b6/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e6%89%a9%e5%b1%95virtualbox%e8%99%9a%e6%8b%9f%e6%9c%ba%e7%9a%84%e7%a3%81%e7%9b%98%e7%a9%ba%e9%97%b4vdi%e6%96%87%e4%bb%b6/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Mon, 18 Oct 2021 18:14:03 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[GParted]]></category>
		<category><![CDATA[vdi]]></category>
		<category><![CDATA[VirtualBox]]></category>
		<category><![CDATA[扩展空间]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=13346</guid>

					<description><![CDATA[<p>宿主机：Ubuntu 16.04 LTS<br />
虚拟机：Windows 10</p>
<p>VirtualBox虚拟机文件有很多种格式，我的是vdi格式，对应的磁盘空间是37GB（Win10系统里只有一个C盘），由于虚拟机里的空间不够用了，想把它扩展成45GB，并且在数据不丢失的情况下仍然保持&#8220;只有一个C盘&#8221;的状态。<br />
下面是操作方法。<br />
<span id="more-13346"></span><br />
<span style="color:#ff0000;">➤</span> 扩大vdi空间<br />
在宿主机的命令行执行命令：</p>
<blockquote>
<div>
		[codelast@ win10.new]$ <span style="color:#0000ff;">sudo VBoxManage modifyhd win10.vdi --resize 46080</span></div>
<div>
		0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%</div>
</blockquote>
<div>
	其中，46080 的单位是MB。这样，vdi 文件对应的虚拟机的磁盘空间就被扩展成了 45GB，但是从 37GB&#160;&#8594; 45GB，多出来的 8GB <span style="color:#ff0000;">仍然是不可用的</span>。<br />
	<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 />
	我们可以进入虚拟机的系统验证这一点。在虚拟机里用快捷键 Win+R 打开运行命令对话框，输入&#160;<span style="color:#0000ff;">diskmgmt.msc</span> 并回车，会打开Windows的&#8220;磁盘管理&#8221;软件，在里面我们会看到：<br />
	<a href="https://www.codelast.com/" rel="noopener" target="_blank"><img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2021/10/enlarge_virtualbox_vdi_space_01.png" style="width: 750px; height: 569px;" /></a><br />
	<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 />
	可见那8GB是&#8220;未分配&#8221;状态，如果要把它合并到原先的37GB里，并且不破坏已安装好的Win10的话，需要用GParted软件来合并扩展空间（如果你不需要合并在一起，只需要把新增的8GB创建成另一个分区，那么就简单得多，不需要用本文的方法）。
<p>	首先到<a href="https://gparted.org/" rel="noopener" target="_blank"><span style="background-color:#faebd7;">GParted官网</span></a>下载GParted ISO镜像文件（gparted-xxx.iso）。</p></div>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e6%89%a9%e5%b1%95virtualbox%e8%99%9a%e6%8b%9f%e6%9c%ba%e7%9a%84%e7%a3%81%e7%9b%98%e7%a9%ba%e9%97%b4vdi%e6%96%87%e4%bb%b6/" class="read-more">Read More </a>]]></description>
										<content:encoded><![CDATA[<p>宿主机：Ubuntu 16.04 LTS<br />
虚拟机：Windows 10</p>
<p>VirtualBox虚拟机文件有很多种格式，我的是vdi格式，对应的磁盘空间是37GB（Win10系统里只有一个C盘），由于虚拟机里的空间不够用了，想把它扩展成45GB，并且在数据不丢失的情况下仍然保持&ldquo;只有一个C盘&rdquo;的状态。<br />
下面是操作方法。<br />
<span id="more-13346"></span><br />
<span style="color:#ff0000;">➤</span> 扩大vdi空间<br />
在宿主机的命令行执行命令：</p>
<blockquote>
<div>
		[codelast@ win10.new]$ <span style="color:#0000ff;">sudo VBoxManage modifyhd win10.vdi --resize 46080</span></div>
<div>
		0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%</div>
</blockquote>
<div>
	其中，46080 的单位是MB。这样，vdi 文件对应的虚拟机的磁盘空间就被扩展成了 45GB，但是从 37GB&nbsp;&rarr; 45GB，多出来的 8GB <span style="color:#ff0000;">仍然是不可用的</span>。<br />
	<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 />
	我们可以进入虚拟机的系统验证这一点。在虚拟机里用快捷键 Win+R 打开运行命令对话框，输入&nbsp;<span style="color:#0000ff;">diskmgmt.msc</span> 并回车，会打开Windows的&ldquo;磁盘管理&rdquo;软件，在里面我们会看到：<br />
	<a href="https://www.codelast.com/" rel="noopener" target="_blank"><img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2021/10/enlarge_virtualbox_vdi_space_01.png" style="width: 750px; height: 569px;" /></a><br />
	<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 />
	可见那8GB是&ldquo;未分配&rdquo;状态，如果要把它合并到原先的37GB里，并且不破坏已安装好的Win10的话，需要用GParted软件来合并扩展空间（如果你不需要合并在一起，只需要把新增的8GB创建成另一个分区，那么就简单得多，不需要用本文的方法）。</p>
<p>	首先到<a href="https://gparted.org/" rel="noopener" target="_blank"><span style="background-color:#faebd7;">GParted官网</span></a>下载GParted ISO镜像文件（gparted-xxx.iso）。<br />
	<span style="color:#ff0000;">➤</span> 把GParted ISO以光盘的形式挂载到虚拟机系统上<br />
	打开VirtualBox，在该虚拟机的&ldquo;存储&rdquo;设置页面上，你会看到一个 *.vdi&nbsp;的虚拟机文件，对应的就是虚拟机里看到的磁盘：<br />
	<a href="https://www.codelast.com/" rel="noopener" target="_blank"><img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2021/10/enlarge_virtualbox_vdi_space_02.png" style="width: 670px; height: 573px;" /></a><br />
	<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 />
	点击&ldquo;控制器: SATA&rdquo;右侧的光盘加号按钮，弹出下面的对话框：<br />
	<a href="https://www.codelast.com/" rel="noopener" target="_blank"><img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2021/10/enlarge_virtualbox_vdi_space_03.png" style="width: 640px; height: 388px;" /></a><br />
	点击左上方的&ldquo;注册&rdquo;按钮选择本地磁盘上的GParted ISO文件，会像上图一样显示在列表中。<br />
	继续点击&ldquo;选择&rdquo;按钮，会看到ISO已经成功挂载了：<br />
	<a href="https://www.codelast.com/" rel="noopener" target="_blank"><img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2021/10/enlarge_virtualbox_vdi_space_04.png" style="width: 670px; height: 573px;" /></a><br />
	<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;重启虚拟机进入GParted软件<br />
	在虚拟机的&ldquo;系统&rdquo;设置页面上，把&ldquo;光驱&rdquo;调整成启动顺序的第一项：<br />
	<a href="https://www.codelast.com/" rel="noopener" target="_blank"><img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2021/10/enlarge_virtualbox_vdi_space_05.png" style="width: 670px; height: 573px;" /></a><br />
	这样开机才能先打开GParted，而不是进入安装过的那个Windows系统。<br />
	<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 />
	设置好后重启虚拟机，可以成功进入GParted：<br />
	<a href="https://www.codelast.com/" rel="noopener" target="_blank"><img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2021/10/enlarge_virtualbox_vdi_space_06.jpg" style="width: 670px; height: 573px;" /></a><br />
	回车进入列表的第一项。<br />
	<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;使用GParted调整分区大小<br />
	打开GParted，在其界面上可看到 8GB&nbsp;的未分配空间：<br />
	<a href="https://www.codelast.com/" rel="noopener" target="_blank"><img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2021/10/enlarge_virtualbox_vdi_space_07.png" style="width: 770px; height: 517px;" /></a><br />
	<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 />
	选中 /dev/sda1&nbsp;那个需要扩大的分区，点击工具栏的&ldquo;Resize/Move&rdquo;按钮，会弹出一个对话框：<br />
	<a href="https://www.codelast.com/" rel="noopener" target="_blank"><img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2021/10/enlarge_virtualbox_vdi_space_08.png" style="width: 773px; height: 518px;" /></a><br />
	你不需要输入具体的数值，只需要用鼠标拖拽绿色方框的右边，把它拉到最右，就可以把空间扩到最大。<br />
	<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 />
	点击&ldquo;Resize/Move&rdquo;按钮会看到空间已经被扩大了：<br />
	<a href="https://www.codelast.com/" rel="noopener" target="_blank"><img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2021/10/enlarge_virtualbox_vdi_space_09.png" style="width: 772px; height: 517px;" /></a><br />
	但是注意：现在只是临时状态，必须要点击工具栏上的&ldquo;应用&rdquo;按钮，才能真正让扩大分区的操作开始执行：<br />
	<a href="https://www.codelast.com/" rel="noopener" target="_blank"><img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2021/10/enlarge_virtualbox_vdi_space_10.png" style="width: 771px; height: 517px;" /></a><br />
	待操作完成后，Windows C盘就成功地从37GB变成了45GB，并且C盘上原来的数据不会丢失。</p>
<p>	<span style="color: rgb(255, 0, 0);">➤</span>&nbsp;验证结果<br />
	在虚拟机设置中，把光驱从启动项中移除（防止再次进入GParted），再重启虚拟机，查看Windows系统的C盘大小，就会发现成功了：<br />
	<a href="https://www.codelast.com/" rel="noopener" target="_blank"><img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2021/10/enlarge_virtualbox_vdi_space_11.png" style="width: 264px; height: 74px;" /></a><br />
	<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>
<p>
	&nbsp;</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e6%89%a9%e5%b1%95virtualbox%e8%99%9a%e6%8b%9f%e6%9c%ba%e7%9a%84%e7%a3%81%e7%9b%98%e7%a9%ba%e9%97%b4vdi%e6%96%87%e4%bb%b6/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<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>
