[CentOS]Adding a new hard Disk drives

這篇來實際操作一下,如何在Linux上進行disk 管理

之前我已經有新增一Disk,現在我必須要mount上去,下面紀錄一下相關步驟和command

$ df –h # get information of disk
$ dmesg | grep sdb # check sdb if itself exists
Note: df –T # get filesystem format

$ ls /dev/[sh]d*

$ fdksi –l /dev/sdb # double ckeck

可以看到目前沒有任何分割表資訊,可千萬別選錯了

$ fdisk /dev/sdb # initialize disk

input m

Command action

   a   toggle a bootable flag

   b   edit bsd disklabel

   c   toggle the dos compatibility flag

   d   delete a partition

   g   create a new empty GPT partition table

   G   create an IRIX (SGI) partition table

   l   list known partition types

   m   print this menu

   n   add a new partition

   o   create a new empty DOS partition table

   p   print the partition table

   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)

 

input n #add a new partition

Input w

$ mkfs.xfs -f /dev/sdb #format 

Mounting the xfs filesystem

$ mkdir /mnt/db
$ mount /dev/sdb /mnt/db
$ mount | grep /dev/sdb
Note: umount /dev/sdb 

 

Write uuid into fstab

$ blkid #get block id

Vi /etc/fstab

$ df -h

 

參考

第七章、Linux 磁碟與檔案系統管理

How to Create, Mount and Extend xfs Filesystem