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. 查看下是否有分区


    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

  2. 开始分区

    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):

  3. 输入m,查看命令:

    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):

  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 硬盘分区,分区,删除分区,格式化,挂载,卸载笔记

你可能感兴趣的:(linux下挂载新硬盘,设置为XFS文件系统)