Linux基于大于2TB磁盘挂载

时间:2022-11-28 10:58:43

Linux基于大于2TB磁盘挂载

首先查看服务器磁盘,这里将LINUX系统安装在sda,应用程序用于存放在sdb

[root@voices-bak ~]# fdisk -l

Disk /dev/sda: 127.0 GB, 126999330816 bytes, 248045568 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: dos
Disk identifier: 0x000da1b5

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   248045567   122973184   8e  Linux LVM

Disk /dev/sdb: 23998.0 GB, 23997999742976 bytes, 46871093248 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 /dev/mapper/centos-root: 89.5 GB, 89468698624 bytes, 174743552 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 /dev/mapper/centos-swap: 36.5 GB, 36452696064 bytes, 71196672 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

这里选择/dev/sdb

[root@voices-bak ~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: LSI LSI (scsi)
Disk /dev/sdb: 24.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start  End  Size  File system  Name  Flags

(parted)
(parted) mklabel gpt
(parted) print
Model: LSI LSI (scsi)
Disk /dev/sdb: 24.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start  End  Size  File system  Name  Flags
(parted) mkpart primary 0 100%		# 将磁盘所有空间进行划分
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore
(parted)
(parted) print
Model: LSI LSI (scsi)
Disk /dev/sdb: 24.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name     Flags
 1      17.4kB  24.0TB  24.0TB               primary
(parted) quit
Information: You may need to update /etc/fstab.

格式化磁盘

[root@voices-bak ~]#  mkfs.xfs -f /dev/sdb

创建LVM卷

# pvcreate
[root@voices-bak ~]# pvcreate /dev/sdb
WARNING: xfs signature detected on /dev/sdb at offset 0. Wipe it? [y/n]: y
  Wiping xfs signature on /dev/sdb.
  Physical volume "/dev/sdb" successfully created.

# vgcreate Vg01

[root@voices-bak ~]# vgcreate Vg01 /dev/sdb
  Volume group "Vg01" successfully created


[root@voices-bak ~]# lvcreate -l 5721568 -n Lvdata Vg01		# -l 使用"Free  PE / Size       5721568"颗粒数
  Logical volume "Lvdata" created.



[root@voices-bak ~]# lvdisplay

  --- Logical volume ---
  LV Path                /dev/Vg01/Lvdata
  LV Name                Lvdata
  VG Name                Vg01
  LV UUID                x8ZZYf-33Ah-jVlj-sOS3-JQKF-au0s-sjOWgK
  LV Write Access        read/write
  LV Creation host, time voices-bak.hopetele, 2022-11-21 19:35:13 +0800
  LV Status              available
  # open                 0
  LV Size                <21.83 TiB
  Current LE             5721568
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

格式化后并挂载LVM卷

# 格式化
[root@voices-bak ~]# mkfs.xfs /dev/Vg01/Lvdata
[root@voices-bak ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/Vg01/Lvdata
  LV Name                Lvdata
  VG Name                Vg01
  LV UUID                x8ZZYf-33Ah-jVlj-sOS3-JQKF-au0s-sjOWgK
  LV Write Access        read/write
  LV Creation host, time voices-bak.hopetele, 2022-11-21 19:35:13 +0800
  LV Status              available
  # open                 0
  LV Size                <21.83 TiB
  Current LE             5721568
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2


# /dev/Vg01/Lvdata将挂载到/data 目录上
[root@voices-bak ~]# mount UUID='x8ZZYf-33Ah-jVlj-sOS3-JQKF-au0s-sjOWgK' /data

# 运行以下命令查询盘的UUID信息。
[root@voices-bak ~]# blkid
/dev/mapper/Vg01-Lvdata: UUID="85a6adfa-c7f8-4d26-846d-c05d147e66a1" TYPE="xfs"
[root@voices-bak ~]# vim /etc/fstab
UUID=85a6adfa-c7f8-4d26-846d-c05d147e66a1 /data xfs defaults 1 1

# 服务器重启验证
[root@voices-bak ~]# reboot