Linux服务器如何识别移动硬盘?
<svg xmlns="http://www.w3.org/2000/svg" style="display: none"><path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0)"></path>
</svg>
<h2>序言</h2>
<blockquote>
<p>通常我们使用的移动硬盘或U盘一般都是ntfs或fat32的文件系统,常跟服务器打交道的小伙伴,会经常遇到把移动硬盘或U盘上的数据拷贝到Linux服务器上。绝大多数Linux发行版内核支持fat32文件系统,因此我们直接mount即可挂载;然而对于ntfs格式的设备,Linux系统并不支持直接挂载,需要安装ntfs-3g包</p>
</blockquote>
<p>今天我们学习下服务器如何挂载fat32及ntfs文件系统设备的挂载</p>
<h2>一、服务器挂载FAT32移动硬盘(U盘)步骤:</h2>
<p><strong>1)将U盘插入USB接口,检查是否插好</strong></p>
<p><strong>2)找到U盘所在设备,比如我的就是/dev/sdb1</strong></p>
<pre><code class="prism language-bash"><span class="token punctuation">[</span>root@qll251 ~<span class="token punctuation">]</span><span class="token comment"># fdisk -l | grep FAT32</span>
/dev/sdb1 * 56 640 3580928 c W95 FAT32 <span class="token punctuation">(</span>LBA<span class="token punctuation">)</span>
</code></pre>
<p><strong>3)创建挂载点,比如/fat32</strong></p>
<pre><code class="prism language-bash"><span class="token punctuation">[</span>root@qll251 ~<span class="token punctuation">]</span><span class="token comment"># mkdir /fat32</span>
**``<span class="token variable"><span class="token variable">`</span>
4)挂载设备**
<span class="token variable">`</span></span>``bash
<span class="token punctuation">[</span>root@qll251 ~<span class="token punctuation">]</span><span class="token comment"># mount -t vfat /dev/sdb1 /fat32</span>
</code></pre>
<p><strong>5)挂载成功后,我们可以在/fat32下识别到U盘中的内容</strong></p>
<p><strong>6)卸载U盘</strong></p>
<pre><code class="prism language-bash"><span class="token punctuation">[</span>root@qll251 ~<span class="token punctuation">]</span><span class="token comment"># umount /fat32</span>
umount: /fat32: device is busy
<span class="token punctuation">[</span>root@qll251 ~<span class="token punctuation">]</span><span class="token comment"># rm -rf /fat32</span>
</code></pre>
<h2>二、Linux服务器挂载NTFS移动硬盘步骤:</h2>
<p><strong>1)安装ntfs-3g</strong></p>
<p>ntfs-3g有两种安装方式,一种是使用yum进行安装,一种是使用源码包进行编译安装。</p>
<p>以下两种安装方式,您可按需选择。</p>
<p>如果您对yum源的的搭建不太熟悉,参考:</p>
<ol>
<li>yum方式安装ntfs-3g</li>
</ol>
<pre><code class="prism language-bash"><span class="token punctuation">[</span>root@qll251 ~<span class="token punctuation">]</span><span class="token comment"># yum -y install ntfs-3g </span>
</code></pre>
<ol start="2">
<li>源码包方式安装ntfs-3g</li>
</ol>
<pre><code class="prism language-bash"><span class="token comment"># 我们从官网上 下载ntfs-3g源码包;</span>
<span class="token punctuation">[</span>root@qll251 ~<span class="token punctuation">]</span><span class="token comment"># wget https://tuxera.com/opensource/ntfs-3g_ntfsprogs-2017.3.23.tgz</span>
<span class="token comment"># 当然如果您的服务器没有互联网环境,参考:</span>
</code></pre>
<pre><code class="prism language-bash"><span class="token punctuation">[</span>root@qll251 ~<span class="token punctuation">]</span><span class="token comment"># yum -y install gcc # 安装gcc编译器</span>
<span class="token punctuation">[</span>root@qll251 ~<span class="token punctuation">]</span><span class="token comment"># tar -zxvf ntfs-3g_ntfsprogs-2017.3.23.tgz</span>
<span class="token punctuation">[</span>root@qll251 ~<span class="token punctuation">]</span><span class="token comment"># cd ntfs-3g_ntfsprogs-2017.3.23/</span>
<span class="token punctuation">[</span>root@qll251 ntfs-3g_ntfsprogs-2017.3.23<span class="token punctuation">]</span><span class="token comment"># ./configure && make && make install</span>
</code></pre>
<p><strong>2)找到移动硬盘所在设备,比如我的就是/dev/sdc1</strong></p>
<pre><code class="prism language-bash"><span class="token punctuation">[</span>root@qll251 ~<span class="token punctuation">]</span><span class="token comment"># fdisk -l | grep NTFS</span>
/dev/sdc1 * 1 244 1955776+ 7 HPFS/NTFS
</code></pre>
<p><strong>3)创建挂载点并挂载</strong></p>
<pre><code class="prism language-bash"><span class="token punctuation">[</span>root@qll251 ~<span class="token punctuation">]</span><span class="token comment"># mkdir /ntfs</span>
<span class="token punctuation">[</span>root@qll251 ~<span class="token punctuation">]</span><span class="token comment"># mount -t ntfs-3g /dev/sdc1 /ntfs</span>
</code></pre>
<p><strong>4)卸载移动硬盘</strong></p>
<pre><code class="prism language-bash"><span class="token punctuation">[</span>root@qll251 ~<span class="token punctuation">]</span><span class="token comment"># umount /ntfs</span>
<span class="token punctuation">[</span>root@qll251 ~<span class="token punctuation">]</span><span class="token comment"># rm -rf /ntfs</span>
</code></pre>
<h2>三、常用mount案例</h2>
<p>最后给大家列举下企业中常用的mount案例</p>
<ul>
<li>mount /dev/sr0 /mnt:挂载光盘至/mnt目录</li>
<li>mount /dev/sdb1 /data:挂载sdb1分区至/data目录</li>
<li>mount -t vfat /dev/sdb1 /fat32:挂载U盘至/fat32目录</li>
<li>mount -t ntfs-3g /dev/sdc1 /ntfs:挂载ntfs移动硬盘至/ntfs目录</li>
<li>mount -t iso9660 -o loop centos8.iso /mnt:挂载centos8镜像文件至/mnt目录</li>
<li>mount -t nfs 192.168.1.251:/data /mnt:挂载远端nfs服务器的/data目录至本地/mnt目录</li>
<li>mount -o remount, rw /:单用户模式下,重新以读写模式挂载根</li>
</ul>
<p>更多帮助信息请参阅 :mount --help 或者 man mount</p>
<p>更多IT技术,请微信搜索公众号<code>秦露露</code>或者扫描下方二维码关注</p>
<p><img src="https://img-blog.csdnimg.cn/20200216162812292.gif"></p>
</div>
<div id="MySignature" role="contentinfo">
十年磨一剑<br><br>
来源:https://www.cnblogs.com/qinlulu/p/12317313.html
頁:
[1]