新聞中心
Linux Mount 是一種非常常用的命令,它是用來將磁盤掛載到操作系統(tǒng)上的。在使用 Linux Mount 掛載本地磁盤時非常簡單,但是在掛載遠程磁盤時可能會稍微有些困難。本篇文章將會幫助您了解如何正確地使用 Linux Mount 掛載遠程磁盤。

一、遠程掛載
在開始之前,您需要了解什么是遠程掛載。一般情況下,我們都是將磁盤直接掛載到本地操作系統(tǒng)上,但是如果您的磁盤在另一臺機器上,您可以使用遠程掛載的方式將其掛載到本地上。遠程掛載可以讓我們在兩臺機器之間分享文件,而且具有很高的靈活性。
二、配置 SSH
在進行遠程掛載之前,您需要配置好 SSH。這是因為在掛載遠程磁盤時,Linux 需要使用 SSH 協(xié)議進行通信。如果您還沒有安裝 SSH,可以通過以下命令安裝:
“`shell
sudo apt-get install openssh-server
“`
如果您已經(jīng)安裝了 SSH,則需要確保它已經(jīng)啟動。您可以用以下命令檢查 SSH 是否正在運行:
“`shell
sudo systemctl status ssh
“`
如果 SSH 未啟動,則可以使用以下命令啟動它:
“`shell
sudo systemctl start ssh
“`
三、安裝 sshfs
安裝 SSH 后,您需要在本地系統(tǒng)上安裝 SSHFS。SSHFS 是一個應(yīng)用程序,它可以將 SSH 文件系統(tǒng)掛載到本地系統(tǒng)上。您可以使用以下命令在 Ubuntu 系統(tǒng)上安裝 SSHFS:
“`shell
sudo apt-get install sshfs
“`
四、創(chuàng)建掛載點
在進行遠程掛載之前,您需要在本地系統(tǒng)上創(chuàng)建一個掛載點。掛載點是本地系統(tǒng)上一個文件夾,它將用來存儲遠程磁盤上的文件。您可以使用以下命令創(chuàng)建一個掛載點:
“`shell
sudo mkdir /mnt/remote-disk
“`
五、掛載遠程磁盤
現(xiàn)在,您已經(jīng)完成了所有的前置工作。接下來,您需要將遠程磁盤掛載到本地系統(tǒng)上:
“`shell
sshfs @: /mnt/remote-disk
“`
其中, 是您登錄遠程系統(tǒng)時使用的用戶名, 是遠程系統(tǒng)的 IP 地址, 是遠程系統(tǒng)上需要掛載的文件夾路徑,/mnt/remote-disk 是您在本地系統(tǒng)上創(chuàng)建的掛載點。
例如,如果我們要將 192.168.1.100 機器上的 /home/user/Documents 文件夾掛載到本地的 /mnt/remote-disk 文件夾上。那么,我們可以使用以下命令進行掛載:
“`shell
sshfs user@192.168.1.100:/home/user/Documents /mnt/remote-disk
“`
現(xiàn)在,您已經(jīng)成功掛載了遠程磁盤。您可以通過訪問 /mnt/remote-disk 文件夾,查看遠程文件夾中的文件了。當(dāng)您完成時間,可以使用以下命令取消掛載:
“`shell
fusermount -u /mnt/remote-disk
“`
六、自動掛載
如果您反復(fù)需要掛載磁盤到本地系統(tǒng)上,那么每次都要手動進行這些操作肯定很麻煩。幸運的是,您可以使用一些技巧來自動掛載遠程磁盤。例如,您可以將掛載命令添加到 /etc/fstab 文件中,以便系統(tǒng)啟動時自動掛載。
“`shell
user@192.168.1.100:/home/user/Documents /mnt/remote-disk fuse.sshfs defaults,user,IdentityFile=/path/to/ssh/key 0 0
“`
請注意,您需要將設(shè)置您自己的 SSH 秘鑰。
七、
相關(guān)問題拓展閱讀:
- linux下如何掛載硬盤?
- LINUX里用mount怎么掛在硬盤,比如E盤~mount /media/然后呢?!
linux下如何掛載硬盤?
1.插入新硬盤,啟動Linux服務(wù)器,使用fdisk -l 查看硬盤
#fdisk -l
Disk /dev/sdb: 1000.2 GB, bytes
2.格式化硬盤
#mkfs -t ext4 /dev/sdb
3.掛載硬盤
#mount 硬盤地址 要掛載的地址
#mount /dev/sdb /media/imgs
4.實現(xiàn)系統(tǒng)重啟后自動掛載該分區(qū)
#vi /etc/fstab
在最后一行添加
/dev/sdb /media/imgs ext4 defaults 1 2
一、添加磁盤
添加加乎帶悉新硬盤重啟服務(wù)器
添加完之后就可以重啟機器了,如果你機器是開啟的,進入系統(tǒng)并不能看見你剛添加的那塊磁盤,只有等系統(tǒng)重啟,重新加載之后才會顯示安裝的那塊磁盤
二、進入系統(tǒng)
使用root用戶進入系統(tǒng)
三、 查看硬盤信息
# fdisk -l //磁盤命令
Disk /dev/sda: 21.5 GB,bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of* 512 =bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c4cb5
Device Boot StartEnd Blocks Id System
/dev/sda1 *行運 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda 8e Linux LVM
Disk /dev/sdb: 21.5 GB,bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of* 512 =bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xd0f5c869
Device Boot StartEnd Blocks Id System
/dev/sdb+ 83 Linux
Disk /dev/sdc: 21.5 GB,bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of* 512 =bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x
可以看到這臺機器加載了三個磁盤sda、sdb、sdc
其中sda是初始磁盤,sdb已經(jīng)初始化且經(jīng)過使用,sdc是剛剛加載的,未格式化的新磁盤
四、創(chuàng)建新硬盤分區(qū)
# fdisk /dev/sdc #進入磁歲乎盤
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x45a3cadb.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won’t be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
switch off the mode (command ‘c’) and change display units to
sectors (command ‘u’).
Command (m for help): m
Command action
a toggle a bootable flag #設(shè)定可啟動標(biāo)記
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition#刪除一個分區(qū)
l list known partition types #各分區(qū)類型所對應(yīng)的ID
m print this menu#菜單
n add a new partition#添加一個分區(qū)
o create a new empty DOS partition table
p print the partition table #顯示該磁盤下的當(dāng)前分區(qū)信息
q quit without saving changes #不保存退出
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit #保存退出
x extra functionality (experts only)
知道命令之后就可以進行分區(qū)了
Command (m for help): p //打印分區(qū)信息,可以看到當(dāng)前并沒有分區(qū)
Disk /dev/sdc: 21.5 GB,bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of* 512 =bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x45a3cadb
Device Boot StartEnd Blocks Id System
Command (m for help): n //創(chuàng)建一個新的分區(qū)
Command action
e extended//輸入e為創(chuàng)建擴展分區(qū)
p primary partition (1-4) //輸入p為創(chuàng)建邏輯分區(qū)
p
Partition number (1-4): 1//劃分邏輯分區(qū)
First cylinder (1-2610, default 1): //我這里直接回車,是不想把該磁盤分成多個分區(qū),把整個磁盤作為1個分區(qū)
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):
Using default value 2610
Command (m for help): p //再次查看可以看到該磁盤已經(jīng)有1個分區(qū)了
Disk /dev/sdc: 21.5 GB,bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of* 512 =bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x45a3cadb
Device Boot StartEnd Blocks Id System
/dev/sdc+ 83 Linux
Command (m for help): w //保存分區(qū)
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
再次使用”fdisk -l”命令查看磁盤信息
Disk /dev/sdc: 21.5 GB,bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of* 512 =bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x406a4c58
Device Boot StartEnd Blocks Id System
/dev/sdc+ 83 Linux
第三塊磁盤/dev/sdc已經(jīng)分區(qū)好了
五、格式化分區(qū)
# mkfs.ext3 /dev/sdc1
//將/dev/sdc1格式化為ext3類型,好像大部分的磁盤都是格式化為ext3類型,具體為什么沒有深入研究,暫時不清楚,想了解的朋友可以自己查一下
# mkfs.ext3 /dev/sdc1
mke2fs 1.41.12 (17-May-2023)
文件系統(tǒng)標(biāo)簽=
操作系統(tǒng):Linux
塊大小=4096 (log=2)
分塊大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
inodes,blocks
blocks (5.00%) reserved for the super user
之一個數(shù)據(jù)塊=0
Maximum filesystem blocks=
160 block groups
32768 blocks per group,fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304,,,,,,,,
正在寫入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
格式化完畢,此時就可以使用“mount”命令掛載分區(qū)了,然后使用這個磁盤空間了
六、掛載分區(qū)以及開機自動掛載
# df -h //此時只有sda1和sdb1兩個磁盤掛載
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 18G 15G 1.5G 92% /
tmpfsM 76K 932M 1% /dev/shm
/dev/sdaM 40M 421M 9% /boot
/dev/sdbG 1.2G 18G 7% /disk/diskone
/dev/sr.2G 4.2G% /media/CentOS_6.5_Final
# cd /disk/
# ll
總用量 4
drwxr-xr-x. 4 root root月:04 diskone
# cd diskone/
# ll
總用量 20
drwx——. 2 root root月:12 lost+found
drwxr-xr-x. 2 root root月:09 software
# cd ../
# mkdir disktwo //創(chuàng)建被掛載的路徑
# ll
總用量 8
drwxr-xr-x. 4 root root月:04 diskone
LINUX里用mount怎么掛在硬盤,比如E盤~mount /media/然后呢?!
#man mount
#mount /dev/(你臘仔的掘早硬盤分區(qū)) /(掛輪散汪載點也就是目錄)
首先你要E盤的編擾脊號,比如一般C盤是/dev/sda1,如果實在不知道,用cfdisk看伍核一下,然后就可以mount了,要建一個目錄掛載,比如/mnt/e,然后只要運行mount /dev/sdax /mnt/e (x是你的E盤的編緩橘滲號)。不過現(xiàn)在一般都是直接點擊就自動掛載了。
1.查看可以的硬盤
sfdisk -l
例:
/dev/sda1
/dev/sdb1
….
2. 掛載念咐扮
mount /dev/sdb1 /media #掛載
cd /media #進入
ls -l #查簡沖看仔灶
mount 掛枯豎鋒在目錄 掛載地點,纖汪運沒晌行mount /dev/sdax /mnt/e (x是你的E盤的編號)??蓞⒖肌禠inux就該這么學(xué)》了解詳細介紹
mount 掛在目錄 掛載地點
mount /dev/cdrom /media
linux mount 遠程磁盤的介紹就聊到這里吧,感謝你花時間閱讀本站內(nèi)容,更多關(guān)于linux mount 遠程磁盤,如何使用 Linux Mount 掛載遠程磁盤,linux下如何掛載硬盤?,LINUX里用mount怎么掛在硬盤,比如E盤~mount /media/然后呢?!的信息別忘了在本站進行查找喔。
香港服務(wù)器選創(chuàng)新互聯(lián),2H2G首月10元開通。
創(chuàng)新互聯(lián)(www.cdcxhl.com)互聯(lián)網(wǎng)服務(wù)提供商,擁有超過10年的服務(wù)器租用、服務(wù)器托管、云服務(wù)器、虛擬主機、網(wǎng)站系統(tǒng)開發(fā)經(jīng)驗。專業(yè)提供云主機、虛擬主機、域名注冊、VPS主機、云服務(wù)器、香港云服務(wù)器、免備案服務(wù)器等。
文章題目:如何使用LinuxMount掛載遠程磁盤(linuxmount遠程磁盤)
網(wǎng)站鏈接:http://m.5511xx.com/article/djsdheo.html


咨詢
建站咨詢
