對這文章發表回應
發表限制: 非會員 可以發表
發表者: 冷日 發表時間: 2019/9/4 7:12:31
Linux加掛第二顆硬碟
出自 Itsmw
流程簡介檢查硬碟代號→ fdisk → mkfs.ext3格式化 → 永久掛載
檢查第二顆硬碟的代號
- 若 IDE 直接檢查 hd 字串
root@dns:~# dmesg |grep hd
Kernel command line: root=/dev/hda2 ro vga=788 splash=silent
:
:
hda: cache flushes supported
hda: hda1 hda2 ← 第一顆硬碟,內含兩個分割區
Adding 2931820k swap on /dev/hda1. Priority:-1 extents:1 across:2931820k
EXT3 FS on hda2, internal journal
ide-scsi is deprecated for cd burning! Use ide-cd and give dev=/dev/hdX as device
hda: selected mode 0x46
由以上知,只有一顆硬碟時,會叫 hda, 分成兩個分割區。若有第二顆會出現 hdb, 第三顆 hdc ...依此類推
- 若 SATA , 那麼 hd 及 sd 皆可能
root@dns:~# dmesg |grep sd
hdc: LITE-ON DVD SOHD-16P9S, ATAPI CD/DVD-ROM drive
SCSI device sda: 312581808 512-byte hdwr sectors (160042 MB) ← 第一顆 sata 硬碟
SCSI device sdb: 312581808 512-byte hdwr sectors (160042 MB) ← 第二顆 sata 硬碟
hdc: ATAPI 48X DVD-ROM drive, 254kB Cache ← 光碟機
由以上知,第一顆是 sda, 第二顆 sdb ...依此類推
- 若 SCSI 直接檢查 sd 字串
root@dns:~# dmesg |grep sd
SCSI device sda: 312581808 512-byte hdwr sectors (160042 MB) ← 第一顆 sata 硬碟
SCSI device sdb: 312581808 512-byte hdwr sectors (160042 MB) ← 第二顆 sata 硬碟
開始動手
安置硬碟 FDISK
- 使用 FDISK 初始化新的硬碟
root@dns# fdisk /dev/hdb
Command (m for help): x
Expert command (m for help): m
Command action
b move beginning of data in a partition
c change number of cylinders
d print the raw data in the partition table
e list extended partitions
f fix partition order
g create an IRIX (SGI) partition table
h change number of heads
m print this menu
n add a new partition
p print the partition table
q quit without saving changes
r return to main menu
s change number of sectors/track
v verify the partition table
w write table to disk and exit
- 新增
Command (m for help): n - 選完分割區大小後, 寫入
Command (m for help): w
會顯示The partition table has been altered! 訊息 - 離開 FDISK
Command (m for help): q
格式化並手動掛載
格式化硬碟只要做一次就好,format 完,先手動掛載一次,看看有沒有什麼問題。若沒問題,再使用下面介紹的永久掛載方式,以使每次開機自動掛成某個資料夾(本文以 /home2 為例)。
- 格式化 hdb1
root@dns:# mkfs.ext3 /dev/hdb1 - 將新硬碟掛在新增目錄
root@dns# mount -t ext3 /dev/hdb1 /home2
寫入/etc/fstab永久掛載
- 永久掛載
root@dns:~$ vi /etc/fstab
# # filesystem mountpoint type options dump pass |
- 依 /etc/fstab 最新的設定重新掛載:
root@dns# mount -a
- 觀察
原文出處: Linux加掛第二顆硬碟 - Itsmw