發新話題

Linux加掛第二顆硬碟,FDISK初始化新的硬碟

Linux加掛第二顆硬碟,FDISK初始化新的硬碟

流程簡介 檢查硬碟代號→ 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:2931820kEXT3 FS on hda2, internal journalide-scsi is deprecated for cd burning! Use ide-cd and give dev=/dev/hdX as devicehda: selected mode 0x46  由以上知,只有一顆硬碟時,會叫 hda, 分成兩個分割區。若有第二顆會出現 hdb, 第三顆 hdc ...依此類推

  • 若 SATA , 那麼 hd 及 sd 皆可能
    root@dns:~# dmesg |grep sd
hdc: LITE-ON DVD SOHD-16P9S, ATAPI CD/DVD-ROM driveSCSI 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): xExpert command (m for help): mCommand 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

格式化並手動掛載
  • 格式化 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
/dev/sda2 / ext3 defaults,errors=remount-ro 0 1
/dev/sda1 none swap sw 0 0
proc /proc proc defaults 0 0
/dev/fd0 /floppy vfat defaults,user,noauto,showexec,umask=022 0 0
/dev/cdrom /cdrom iso9660 defaults,ro,user,noexec,noauto 0 0
none /sys sysfs defaults 0 0
none /dev/pts devpts defaults 0 0
/dev/hdb1 /home2 ext3 defaults,errors=remount-ro 0 0

  • 依 /etc/fstab 最新的設定重新掛載:
    root@dns#mount -a
  • 觀察
  • root@dns# df
  • root@dns# fdisk -l

TOP

發新話題

本站所有圖文均屬網友發表,僅代表作者的觀點與本站無關,如有侵權請通知版主會盡快刪除。