linux下掛載新硬盤,設置為XFS文件系統

一 XFS文件系統簡介

XFS是高性能文件系統,SGI為他們的IRIX平臺而設計。自從2001年移植到Linux內核上,由于它的高性能,XFS成為了許多企業級系統的首選,特別是有大量數據,需要結構化伸縮性和穩定性的。例如,RHEL/CentOS 7 和Oracle Linux將XFS作為默認文件系統,SUSE/openSUSE已經為XFS做了長期支持。
XFS有許多獨特的性能提升功能使他從眾多文件系統中脫穎而出,像可伸縮/并行 IO,元數據日志,熱碎片整理,IO 暫停/恢復,延遲分配等。

二 安裝XFS系統工具集

Debian, Ubuntu , Linux Mint系統:

$ sudo apt-get install xfsprogs
Fedora, CentOS, RHEL系統:

$ sudo yum install xfsprogs
其他版本Linux:

$ sudo pacman -S xfsprogs

三創建分區

  1. 查看下是否有分區
    <code><p>
    root@HWPKI-TEST-98:~# fdisk -l
    Disk /dev/sda: 500.1 GB, 500107862016 bytes
    255 heads, 63 sectors/track, 60801 cylinders, total 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 identifier: 0x00083283
    Device Boot Start End Blocks Id System
    /dev/sda1 * 2048 968601599 484299776 83 Linux
    /dev/sda2 968603646 976771071 4083713 5 Extended
    /dev/sda5 968603648 976771071 4083712 82 Linux swap / Solaris
    Disk /dev/sdb: 3000.6 GB, 3000592982016 bytes
    255 heads, 63 sectors/track, 364801 cylinders, total 5860533168 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
    Disk identifier: 0x3ab14c4d
    Device Boot Start End Blocks Id System
    </p></code>

  2. 開始分區
    <code>
    root@HWPKI-TEST-98:~# fdisk /dev/sdb
    WARNING: The size of this disk is 3.0 TB (3000592982016 bytes).
    DOS partition table format can not be used on drives for volumes
    larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
    partition table format (GPT)
    The device presents a logical sector size that is smaller than
    the physical sector size. Aligning to a physical sector (or optimal
    I/O) size boundary is recommended, or performance may be impacted.
    Command (m for help):
    </code>

  3. 輸入m,查看命令:
    <code>
    Command (m for help): m
    Command action
    a toggle a bootable flag
    b edit bsd disklabel
    c toggle the dos compatibility flag
    d delete a partition
    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)

Command (m for help):
</code>

  1. 輸入n新建一個分區,輸入p 建立分區,輸入分區編號 1
    然后一路默認
  2. 輸入w保存

四 格式化分區

1.格式化分區為XFS,使用mkfs.xfs命令。如果已有其他文件系統創建在此分區,必須加上"-f"參數來覆蓋它。
sudo mkfs.xfs -f /dev/sdb1
2.格式化后分區來掛載。假設/mnt是XFS本地掛載點。使用下述命令掛載
sudo mount -t xfs /dev/sdb1 /mnt
3.驗證XFS掛載是否成功:
df -Th /storage
4.如果你想要啟動時自動掛載XFS分區在/storage上,加入下列行到/etc/fstab:
/dev/sdb1 /storage xfs defaults 0 0

參考文章:
Linux有問必答-如何創建和掛載XFS文件系統
linux 硬盤分區,分區,刪除分區,格式化,掛載,卸載筆記

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容