Ubuntu16.04 中如何掛載第二塊磁盤,掛載成功,但是用reboot和shutdown重啟或關機后掛載就沒有了的解決辦法


本測試機有4塊硬盤,初始意圖想做一個磁盤陣列,但是在安裝系統的時候不知道引導文件如何選擇安裝,所以暫時不使用磁盤陣列(后期研究)

檢測硬盤能否被識別

root@ranxf:/# fdisk -l

Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disklabel type: gpt Disk identifier: 59353137-DD3B-40FF-9656-314427DE1ADB 設備 Start 末尾 扇區 Size 類型 /dev/sda1 2048 1050623 1048576 512M EFI System /dev/sda2 1050624 960419839 959369216 457.5G Linux filesystem /dev/sda3 960419840 976771071 16351232 7.8G Linux swap Disk /dev/sdb: 465.8 GiB, 500107862016 bytes, 976773168 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disklabel type: dos Disk identifier: 0xc48b3f11 設備 啟動 Start 末尾 扇區 Size Id 類型 /dev/sdb1 2048 976773119 976771072 465.8G 83 Linux Disk /dev/sdc: 465.8 GiB, 500107862016 bytes, 976773168 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/sdd: 465.8 GiB, 500107862016 bytes, 976773168 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes

上圖中

dev/sda是系統安裝時自動分區;

dev/sdb為手動格式化后的情況

dev/sdc和dev/sdd暫時未分區情況。

 

格式化磁盤

root@ranxf:/# mkfs.ext4 /dev/sdb

掛載磁盤

 在本地硬盤中臨時創建一個目錄/wwwroot

並掛載第二塊硬盤中的一個分區/dev/sdb1到/wwwroot

查看掛載是否成功。

root@ranxf:/# mkdir /wwwroot
root@ranxf:/# mount /dev/sdb1 /wwwroot/
root@ranxf:/# df -h
文件系統        容量  已用  可用 已用% 掛載點
udev            3.8G     0  3.8G    0% /dev
tmpfs           778M  9.4M  769M    2% /run
/dev/sda2       451G   20G  408G    5% /
tmpfs           3.8G   56M  3.8G    2% /dev/shm
tmpfs           5.0M     0  5.0M    0% /run/lock
tmpfs           3.8G     0  3.8G    0% /sys/fs/cgroup
/dev/sda1       511M  3.6M  508M    1% /boot/efi
tmpfs           778M     0  778M    0% /run/user/121
tmpfs           778M   92K  778M    1% /run/user/1000
/dev/sdb1       459G   70M  435G    1% /wwwroot
root@ranxf:/# 

掛載是成功了,但是用reboot和shutdown重啟或關機后掛載就沒有了,怎么解決

要修改/etc/fstab文件。
加一行字:
/dev/sdb1      /wwwroot               ext4     defaults        0       0

 

也可以把你的掛載命令寫入/etc/rc.local,這樣開機自動掛載

 

卸載硬盤

#umount /dev/sdb1

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM