使用fdisk对/dev/nvme0n1剩余空间进行分区,.新添加一块儿磁盘使用gdisk,设置gpt分区表,新建分区,使用parted对新添加的磁盘添加分区,临时挂载,永久挂载

1.使用fdisk对/dev/nvme0n1剩余空间进行分区

[root@192 ~]# fdisk /dev/nvme0n1

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): 

Using default response p.
Partition number (3,4, default 3): 3
First sector (78301184-83886079, default 78301184): 
Last sector, +sectors or +size{K,M,G,T,P} (78301184-83886079, default 83886079): 

Created a new partition 3 of type 'Linux' and of size 2.7 GiB.
Command (m for help): p
Disk /dev/nvme0n1: 40 GiB, 42949672960 bytes, 83886080 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
Disklabel type: dos
Disk identifier: 0x38d65830

Device         Boot    Start      End  Sectors  Size Id Type
/dev/nvme0n1p1 *        2048  2099199  2097152    1G 83 Linux
/dev/nvme0n1p2       2099200 78301183 76201984 36.3G 8e Linux LVM
/dev/nvme0n1p3      78301184 83886079  5584896  2.7G 83 Linux

2.新添加一块儿磁盘使用gdisk,设置gpt分区表,新建分区

在这里插入图片描述

[root@192 ~]# gdisk /dev/nvme0n2
GPT fdisk (gdisk) version 1.0.3

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries.

Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y

Command (? for help): n
Partition number (1-128, default 1): 
First sector (34-2097118, default = 2048) or {+-}size{KMGTP}: 
Last sector (2048-2097118, default = 2097118) or {+-}size{KMGTP}: 
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8e00
Changed type of partition to 'Linux LVM'

Command (? for help): p
Disk /dev/nvme0n2: 2097152 sectors, 1024.0 MiB
Model: VMware Virtual NVMe Disk
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 6555EB8D-7C16-4D0F-A0BC-35B51F7535F1
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 2097118
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         2097118   1023.0 MiB  8E00  Linux LVM

3.使用parted对新添加的磁盘添加分区(交互式)

(parted) mkpart gzw1 200M 500M
(parted) p                                                                
Model: NVMe Device (nvme)
Disk /dev/nvme0n2: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start  End    Size   File system  Name  Flags
 1      200MB  500MB  300MB               gzw1

4.使用parted对/dev/nvme0n1新增分区(命令式)

[root@192 ~]# parted /dev/nvme0n2
GNU Parted 3.2
Using /dev/nvme0n2
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                                
Error: /dev/nvme0n2: unrecognised disk label
Model: NVMe Device (nvme)                                                 
Disk /dev/nvme0n2: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags: 
(parted) mklabel gpt                                                      
(parted) mkpart
Partition name?  []? gzw1                                                 
File system type?  [ext2]? ext4                                           
Start? 0                                                                  
End? 1074MB                                                               
Warning: The resulting partition is not properly aligned for best performance: 34s % 2048s != 0s
Ignore/Cancel? Ignore                                                     
(parted) p                                                                
Model: NVMe Device (nvme)
Disk /dev/nvme0n2: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      17.4kB  1074MB  1074MB  ext4         gzw1

5.挑选任一分区,进行格式化挂载(临时挂载)

[root@192 ~]# mkfs -t xfs /dev/nvme0n2p1
meta-data=/dev/nvme0n2p1         isize=512    agcount=4, agsize=65534 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=262135, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=1566, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

6.挑选另一分区,进行格式化挂载(永久挂载)

[root@server /]# vim /etc/fstab  

使用fdisk对/dev/nvme0n1剩余空间进行分区,.新添加一块儿磁盘使用gdisk,设置gpt分区表,新建分区,使用parted对新添加的磁盘添加分区,临时挂载,永久挂载_第1张图片

你可能感兴趣的:(linux,运维,centos)