Centos 7 挂载新硬盘,设置为XFS文件系统

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Maplematics/article/details/87893862

Centos 7 挂载新硬盘,设置为XFS文件系统

初始配置的服务器硬盘容量为1T,进行 WRF/Chem 数值模拟明显容量不够,于是新增一块2T硬盘,挂载后,设置为XFS文件系统。据说此系统相对于之前的linux EXT3 EXT4等系统更为优秀。
Ref.

  1. 为什么CENTOS 7.0开始选择XFS作为默认的文件系统?XFS相比ext有什么优点? - wangsl的回答 - 知乎
    https://www.zhihu.com/question/24413471/answer/38883787
  2. linux xfs和ext4的区别
    https://blog.csdn.net/nuli888/article/details/51870184

步骤如下

1. 查看当前磁盘信息
$ sudo fdisk -l //查看磁盘信息;
会有如下显示等:

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
.
.
.
Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors

若有分区,会显示如下:

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes, 3907029168 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 label type: gpt


#         Start          End    Size  Type            Name
 1         2048   3907029134    1.8T  Linux filesyste 

2. 分区
执行如下命令:

$ sudo fdisk /dev/sdb
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help):

输入m查看帮助

Command action
  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
  q   quit without saving changes
  s   create a new empty Sun disklabel
  w   write table to disk and exit

删除分区,输入d,新建分区输入n,一路默认;

Command (m for help): n
Partition number (1-128, default 1): 
First sector (34-3907029134, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-3907029134, default 3907029134): 
Created partition 1

w保存

Command (m for help): w
The partition table has been altered!

分区后状态如下

$ sudo fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes, 1953525168 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 label type: gpt


#         Start          End    Size  Type            Name
 1         2048      2050047   1000M  Windows recover 
 2      2050048      2582527    260M  EFI System      EFI system partition
 3      2582528      2844671    128M  Microsoft reser Microsoft reserved partition
 4      2844672    254519295    120G  Microsoft basic Basic data partition
 5    254519296    464246783    100G  Microsoft basic Basic data partition
 6    464246784    506191871     20G  Microsoft basic Linux data partition
 7    506191872    506193919      1M  BIOS boot parti 
 8    506193920    506603519    200M  EFI System      EFI System Partition
 9    506603520    507627519    500M  Microsoft basic 
10    507627520   1953409023  689.4G  Linux LVM       
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes, 3907029168 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 label type: gpt


#         Start          End    Size  Type            Name
 1         2048   3907029134    1.8T  Linux filesyste 

3. 格式化分区为XFS

$ sudo mkfs.xfs -f /dev/sdb1
meta-data=/dev/sdb1              isize=256    agcount=4, agsize=122094597 blks
        =                       sectsz=512   attr=2, projid32bit=1
        =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=488378385, imaxpct=5
        =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=238466, version=2
        =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

新分区如下:

$ sudo fdisk -l

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes, 3907029168 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 label type: gpt


#         Start          End    Size  Type            Name
 1         2048   3907029134    1.8T  Linux filesyste 

4. 挂载硬盘
先创建一个目录,然后将 /dev/sdb1 挂载到该目录下
$ sudo mount -t xfs /dev/sdb1 /home/disk2
5. 修改 /etc/fstab 来进行自动加载
加入下列行到/etc/fstab:修改 /etc/fstab 来进行自动加载,加入下列行到/etc/fstab:加入下列行到/etc/fstab:修改 /etc/fstab 来进行自动加载,加入下列行到/etc/fstab:
/dev/sdb1 /home/disk2 xfs defaults 0 0

Ref.

  1. linux下挂载新硬盘,设置为XFS文件系统
    https://www.jianshu.com/p/e7485d3ecae1
  2. centos7 挂载新的硬盘
    https://blog.csdn.net/u013919633/article/details/79016201

猜你喜欢

转载自blog.csdn.net/Maplematics/article/details/87893862