<?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>debian - 十步回眸一笑 - 个人技术笔记</title>
	<atom:link href="https://www.hishd.top/archives/tag/debian/feed" rel="self" type="application/rss+xml" />
	<link>https://www.hishd.top</link>
	<description></description>
	<lastBuildDate>Sun, 01 Jun 2025 08:50:37 +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>Debian 设置、添加、挂载新分区</title>
		<link>https://www.hishd.top/archives/341</link>
					<comments>https://www.hishd.top/archives/341#respond</comments>
		
		<dc:creator><![CDATA[DB.Russell]]></dc:creator>
		<pubDate>Sun, 01 Jun 2025 08:50:36 +0000</pubDate>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[linux]]></category>
		<guid isPermaLink="false">https://www.hishd.top/?p=341</guid>

					<description><![CDATA[假如我们的vps需要添加一个硬盘来存放数据，我们该如何使用命令的方式添加和挂载新的硬盘呢？ 首先，我们先查看系 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>假如我们的vps需要添加一个硬盘来存放数据，我们该如何使用命令的方式添加和挂载新的硬盘呢？</p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:100%">
<p>首先，我们先查看系统的硬盘是否已经识别</p>



<pre class="wp-block-code"><code>fdisk -l</code></pre>



<figure class="wp-block-image size-full is-resized"><img fetchpriority="high" decoding="async" width="488" height="276" src="https://photo.hishd.top/2025/06/20250601080958663.png" alt="" class="wp-image-343" style="width:532px;height:auto"/></figure>



<p>从上图可以看到，系统目前识别到了两块硬盘。一块是1TB的，一块是100GB的</p>



<pre class="wp-block-code"><code>lsblk </code></pre>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="328" height="92" src="https://photo.hishd.top/2025/06/20250601081353871.png" alt="" class="wp-image-344" style="width:456px;height:auto"/></figure>



<p>可以看到有 ”sdb“ 就是那1TB硬盘的<mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">磁盘名称</mark></p>
</div>
</div>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:100%">
<p>接下来我们就要拿起刀来切分区了</p>



<pre class="wp-block-code"><code>fdisk /dev/sdb  #这里的"sdb"需要根据个人实际的磁盘名称设置，别搞错了哟！</code></pre>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="649" height="428" src="https://photo.hishd.top/2025/06/20250601081528218.png" alt="" class="wp-image-345" style="width:688px;height:auto"/></figure>



<p>我们通过指令 <kbd>n</kbd> 来新建分区，如果无需其他具体的分区划分的话这里一路回车默认就可以了。</p>



<p>最后输入 <kbd>w</kbd> 来写入分区改动即可，最后输入 <kbd>q</kbd> 就可以退出 fdisk</p>
</div>
</div>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:100%">
<p>设置新分区</p>



<p>在划分好分区后，我们需要对分区进行格式化和挂载才可以使用。</p>



<pre class="wp-block-code"><code>mkfs -t ext4 /dev/sdb1 </code></pre>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="614" height="219" src="https://photo.hishd.top/2025/06/20250601082320579.png" alt="" class="wp-image-346" style="width:670px;height:auto"/></figure>



<p>格式化时如果不知道具体的分区名称可以通过 <kbd>lsblk</kbd> 来查看，千万别格式化错了哟！</p>
</div>
</div>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:100%">
<p>挂载分区、设置开机自动挂载</p>



<p>对于Linux来说，挂载相当于给分区设置一个盘号（例如： C盘、D盘这种）。我们要先确定这个挂载的目录，我这1T的数据盘主要作用就是用来存放数据的，所以我给起名为”<mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">data</mark>“，文件夹目录就放在根目录下。</p>



<pre class="wp-block-code"><code>cd /  #进入Linux根目录
mkdir data  #创建 data 文件夹
mount /dev/sdb1 /data  #将sdb1分区挂载为data文件夹</code></pre>



<p>如此便可以使用了，可以通过 <kbd>lsblk</kbd> 查看一下</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="329" height="126" src="https://photo.hishd.top/2025/06/20250601083540445.png" alt="" class="wp-image-347" style="width:400px;height:auto"/></figure>



<p>到这还没结束，由于目前的挂载只是临时挂载。我们需要把挂载写入到启动 <kbd>/etc/fstab</kbd> 中，这样子就可以实现自动了。</p>



<pre class="wp-block-code"><code>vi /etc/fstab  #编辑文件</code></pre>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="738" height="267" src="https://photo.hishd.top/2025/06/20250601084057966.png" alt="" class="wp-image-349" style="width:791px;height:auto"/></figure>



<p>在文件末尾添加一行类似于以下内容的挂载信息：<kbd>/dev/sdb1 /www ext4 defaults 0 0</kbd></p>



<p>第一列为磁盘分区路径，第二列为挂载目录，第三列为文件系统类型</p>



<p>后两列分别表示dump备份标志和fsck检查顺序，一般设置为0即可。</p>



<p>最后保存文件，重启系统</p>
</div>
</div>



<p>如此下来，每次系统启动都可以自动挂载磁盘分区了。</p>



<p>END</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.hishd.top/archives/341/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Debian 无损扩展根目录</title>
		<link>https://www.hishd.top/archives/328</link>
					<comments>https://www.hishd.top/archives/328#respond</comments>
		
		<dc:creator><![CDATA[DB.Russell]]></dc:creator>
		<pubDate>Thu, 29 May 2025 17:03:12 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[linux]]></category>
		<guid isPermaLink="false">https://www.hishd.top/?p=328</guid>

					<description><![CDATA[前几天，vps突发磁盘空间不足导致瘫痪，在购买了空间后发现需要自己手动增加系统空间所以就有了这篇文章。 LVM [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>前几天，vps突发磁盘空间不足导致瘫痪，在购买了空间后发现需要自己手动增加系统空间所以就有了这篇文章。</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>LVM（Logical Volume Manager）是Linux下一种用于管理存储设备，它提供了对存储设备进行灵活管理的能力。LVM的主要原理和结构如下：</p>



<ol class="wp-block-list">
<li><strong>物理卷（Physical Volumes）</strong> ：物理卷是LVM中的最底层，它可以是硬盘驱动器的整个物理设备，也可以是分区。LVM会将这些物理卷抽象为逻辑卷组。</li>



<li><strong>逻辑卷组（Volume Group）</strong> ：逻辑卷组是由一个或多个物理卷组成的逻辑单元，它为逻辑卷的创建提供了基础。逻辑卷组内的物理卷可以是同一硬盘上的不同分区，也可以是不同硬盘上的分区。逻辑卷组可以动态地扩展和收缩。</li>



<li><strong>逻辑卷（Logical Volume）</strong> ：逻辑卷是在逻辑卷组上创建的，它相当于传统分区的替代品。逻辑卷可以像物理分区一样被格式化并挂载到文件系统上使用。逻辑卷的大小可以根据需要进行动态调整，而无需重新分区或格式化磁盘。</li>
</ol>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="820" height="703" src="https://photo.hishd.top/2025/05/20250529163343215.png" alt="" class="wp-image-329" style="width:490px;height:auto"/></figure>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<pre class="wp-block-code"><code>lsblk</code></pre>



<p>输入命令获取系统磁盘分区情况，大致如下图。可以看到 /sdb 增加了5G空间并未使用</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="457" height="201" src="https://photo.hishd.top/2025/05/20250529163444306.png" alt="" class="wp-image-330"/></figure>



<ul class="wp-block-list">
<li>接下来进入根分区进行扩容</li>
</ul>



<pre class="wp-block-code"><code>fdisk /dev/sdb  #我这里扩容的是sdb，看清楚你需要扩容是哪个磁盘
</code></pre>



<ul class="wp-block-list">
<li>输入 “p” 打印sdb分区信息</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="455" height="200" src="https://photo.hishd.top/2025/05/20250529164824794.png" alt="" class="wp-image-332" style="width:455px;height:auto"/></figure>



<ul class="wp-block-list">
<li>输入 “n” 创建新分区</li>
</ul>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="667" height="171" src="https://photo.hishd.top/2025/05/20250529164918268.png" alt="" class="wp-image-333"/></figure>



<ul class="wp-block-list">
<li>输入 “t” 设置分区号和分区类型</li>
</ul>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="387" height="95" src="https://photo.hishd.top/2025/05/20250529165105394.png" alt="" class="wp-image-334"/></figure>



<ul class="wp-block-list">
<li>最后输入 “w” 保存修改</li>
</ul>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="302" height="62" src="https://photo.hishd.top/2025/05/20250529165147432.png" alt="" class="wp-image-335"/></figure>



<p>接着输入 “q” 退出即可</p>



<ul class="wp-block-list">
<li>接着合并lvm分区</li>
</ul>



<pre class="wp-block-code"><code>pvcreate /dev/sdb2  #创建物理卷(确认你自己的盘号，如果重启过可能盘号会变)
vgextend debian-vg /dev/sdb2  #加入卷组(需使用vgdisplay查看VG Name)
lvextend -l +100%FREE /dev/debian-vg/root  #将空间全部划分到根分区
resize2fs /dev/debian-vg/root  #刷新文件系统</code></pre>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="394" height="39" src="https://photo.hishd.top/2025/05/20250529165718919.png" alt="" class="wp-image-336" style="width:495px;height:auto"/></figure>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="833" height="80" src="https://photo.hishd.top/2025/05/20250529165747921.png" alt="" class="wp-image-337" style="width:840px;height:auto"/></figure>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="588" height="93" src="https://photo.hishd.top/2025/05/20250529165806707.png" alt="" class="wp-image-338" style="width:620px;height:auto"/></figure>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>至此lvm分区已经扩容合并一起了</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="460" height="232" src="https://photo.hishd.top/2025/05/20250529165854384.png" alt="" class="wp-image-339"/></figure>



<p>其中从操作中可以看出，我们并没有对原分区进行操作，仅仅是对多出来的空间划分一个新的分区再合并到lvm中，这种操作极具灵活性</p>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.hishd.top/archives/328/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
