linux GPT分区及扩容

检测数据盘

[root@iZ8vba689kou8r8sq4yw44Z ~]# fdisk -l
Disk /dev/vda: 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: 0x951dd9ee

Device     Boot Start      End  Sectors Size Id Type
/dev/vda1  *     2048 83886046 83883999  40G 83 Linux


Disk /dev/vdb: 1000 GiB, 1073741824000 bytes, 2097152000 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

开始分区

[root@iZ8vba689kou8r8sq4yw44Z ~]# parted /dev/vdb
GNU Parted 3.2
Using /dev/vdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) help                                                             
  align-check TYPE N                        check partition N for TYPE(min|opt) alignment
  help [COMMAND]                           print general help, or help on COMMAND
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)                                    ## 创建一个新的磁盘标签(分区表)
  mkpart PART-TYPE [FS-TYPE] START END     make a partition                                                            ## 从start扇区到END扇区创建一个分区
  name NUMBER NAME                         name partition NUMBER as NAME                                               ## 命名第NUMBER号分区为NAME
  print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all             ## 打印分区表,可用设备,剩余空间,所有的分区,或特定分区
        found partitions, or a particular partition
  quit                                     exit program                                                                ## 退出
  rescue START END                         rescue a lost partition near START and END                                  ## 找回从START到END扇区丢失的分区
  resizepart NUMBER END                    resize partition NUMBER
  rm NUMBER                                delete partition NUMBER                                                     ## 删除编号分区
  select DEVICE                            choose the device to edit
  disk_set FLAG STATE                      change the FLAG on selected device
  disk_toggle [FLAG]                       toggle the state of FLAG on selected device
  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER
  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER
  unit UNIT                                set the default unit to UNIT
  version                                  display the version number and copyright information of GNU Parted
(parted) help mklabel 
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)

    LABEL-TYPE is one of: atari, aix, amiga, bsd, dvh, gpt, mac, msdos, pc98, sun, loop
(parted) mklabel gpt
(parted) help mkpart mkpart PART
-TYPE [FS-TYPE] START END make a partition PART-TYPE is one of: primary, logical, extended FS-TYPE is one of: btrfs, nilfs2, ext4, ext3, ext2, fat32, fat16, hfsx, hfs+, hfs, jfs, swsusp, linux-swap(v1), linux-swap(v0), ntfs, reiserfs, hp-ufs, sun-ufs, xfs, apfs2, apfs1, asfs, amufs5, amufs4, amufs3, amufs2, amufs1, amufs0, amufs, affs7, affs6, affs5, affs4, affs3, affs2, affs1, affs0, linux-swap, linux-swap(new), linux-swap(old) START and END are disk locations, such as 4GB or 10%. Negative values count from the end of the disk. For example, -1s specifies exactly the last sector. 'mkpart' makes a partition without creating a new file system on the partition. FS-TYPE may be specified to set an appropriate partition ID.
(parted) mkpart primary
1 100% ## mkpart primary <原分区的起始扇区> <容量分配百分比,也可以使用单位> (parted) align-check optimal 1 1 aligned
如果返回的是1 not aligned,说明分区未对齐,建议您运行以下命令 ,再根据(
<optimal_io_size>+<alignment_offset>)/<physical_block_size>的公式计算出最佳分区模式的起始扇区值。
假设1024为计算得出的推荐扇区值,可以运行mkpart primary 1024s 100%重新划分一个主分区 [root@ecshost~ ]# cat /sys/block/vdb/queue/optimal_io_size [root@ecshost~ ]# cat /sys/block/vdb/queue/minimum_io_size [root@ecshost~ ]# cat /sys/block/vdb/alignment_offset [root@ecshost~ ]# cat /sys/block/vdb/queue/physical_block_size
(parted) print                                                            
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 1074GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  1074GB  1074GB               primary

通知内核分区表发生变化,创建文件系统

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

挂载

[root@iZ8vba689kou8r8sq4yw44Z ~]# mkdir /data
[root@iZ8vba689kou8r8sq4yw44Z ~]# mount /dev/vdb1 /data

[root@iZ8vba689kou8r8sq4yw44Z ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 396M 0 396M 0% /dev
tmpfs 411M 0 411M 0% /dev/shm
tmpfs 411M 480K 411M 1% /run
tmpfs 411M 0 411M 0% /sys/fs/cgroup
/dev/vda1 40G 2.6G 38G 7% /
tmpfs 83M 0 83M 0% /run/user/0
/dev/vdb1 1000G 7.1G 993G 1% /data

添加自动挂载

向/etc/fstab写入新分区信息,启动开机自动挂载分区


备份etc/fstab
[root@iZ8vba689kou8r8sq4yw44Z ~]# cp /etc/fstab /etc/fstab.bak

[root@iZ8vba689kou8r8sq4yw44Z ~]# echo `blkid /dev/vdb1 | awk '{print $2}' | sed 's/\"//g'` /data xfs defaults 0 0 >> /etc/fstab

对已分区的GPT进行扩容

我这里用的是阿里的ecs,并且将磁盘由1T扩容至3T,将/etc/fstab里的挂载信息注释了,然后重启了服务器

1、先将挂载的磁盘卸载

2、开始分区

[root@iZ8vba689kou8r8sq4yw44Z ~]# parted /dev/vdb
GNU Parted 3.2
Using /dev/vdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print Warning: Not all of the space available to
/dev/vdb appears to be used, you can fix the GPT to use all of the ## 提示该磁盘GPT分区不是所有空间可用,建议修复 全部选择Fix space (an extra 4194304000 blocks) or continue with the current setting? Fix/Ignore? Fix Model: Virtio Block Device (virtblk) Disk /dev/vdb: 3221GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 1074GB 1074GB xfs primary

删除已有分区

(parted) rm 1                
(parted) print 
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 3221GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags

重新创建主分区

(parted) mkpart primary 1049kB 100%
(parted) print 
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 3221GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 1049kB 3221GB 3221GB primary


(parted) quit
Information: You may need to update /etc/fstab.
 

检查一致性

[root@iZ8vba689kou8r8sq4yw44Z ~]# xfs_repair -n /dev/vdb1
Phase 1 - find and verify superblock...
Phase 2 - using internal log
- zero log...
- scan filesystem freespace and inode maps...
- found root inode chunk
Phase 3 - for each AG...
- scan (but don't clear) agi unlinked lists...
- process known inodes and perform inode discovery...
- agno = 0
- agno = 1
- agno = 2
- agno = 3
- process newly discovered inodes...
Phase 4 - check for duplicate blocks...
- setting up duplicate extent list...
- check for inodes claiming duplicate blocks...
- agno = 0
- agno = 1
- agno = 2
- agno = 3
No modify flag set, skipping phase 5
Phase 6 - check inode connectivity...
- traversing filesystem ...
- traversal finished ...
- moving disconnected inodes to lost+found ...
Phase 7 - verify link counts...
No modify flag set, skipping filesystem flush and exiting.

重新挂载分区

[root@iZ8vba689kou8r8sq4yw44Z ~]# mount /dev/vdb1 /data
[root@iZ8vba689kou8r8sq4yw44Z ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 396M 0 396M 0% /dev
tmpfs 411M 0 411M 0% /dev/shm
tmpfs 411M 464K 411M 1% /run
tmpfs 411M 0 411M 0% /sys/fs/cgroup
/dev/vda1 40G 2.6G 38G 7% /
tmpfs 83M 0 83M 0% /run/user/0
/dev/vdb1 1000G 7.1G 993G 1% /data

我这里是centos8.0的操作系统

[root@iZ8vba689kou8r8sq4yw44Z ~]# uname -r
4.18.0-147.5.1.el8_1.x86_64

扩容的时候命令变了,只能对挂载点进行操作

[root@iZ8vba689kou8r8sq4yw44Z ~]# xfs_growfs /dev/vdb1
xfs_growfs: /dev/vdb1 is not a mounted XFS filesystem
[root@iZ8vba689kou8r8sq4yw44Z ~]# xfs_growfs /data
meta-data=/dev/vdb1 isize=512 agcount=4, agsize=65535872 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=262143488, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=127999, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 262143488 to 786431488

查看挂载后的磁盘空间

[root@iZ8vba689kou8r8sq4yw44Z ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 396M 0 396M 0% /dev
tmpfs 411M 0 411M 0% /dev/shm
tmpfs 411M 464K 411M 1% /run
tmpfs 411M 0 411M 0% /sys/fs/cgroup
/dev/vda1 40G 2.6G 38G 7% /
tmpfs 83M 0 83M 0% /run/user/0
/dev/vdb1 3.0T 21G 3.0T 1% /data

新增GPT分区并格式化

为了测试,将之前的分区删掉,再次创建一个1T的分区

[root@iZ8vba689kou8r8sq4yw44Z ~]# parted /dev/vdb

GNU Parted 3.2

Using /dev/vdb

Welcome to GNU Parted! Type 'help' to view a list of commands.

(parted) print                                                            

Model: Virtio Block Device (virtblk)

Disk /dev/vdb: 3221GB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Disk Flags: 


Number  Start  End  Size  File system  Name  Flags


(parted) mkpart primary 1 1T

(parted) print                                                            

Model: Virtio Block Device (virtblk)

Disk /dev/vdb: 3221GB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Disk Flags: 


Number  Start   End     Size    File system  Name     Flags

 1      1049kB  1000GB  1000GB               primary
(parted) align-check opt 1 1 aligned (parted) print Model: Virtio Block Device (virtblk) Disk /dev/vdb: 3221GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 1000GB 1000GB primary (parted) quit Information: You may need to update /etc/fstab.

查看分区情况

[root@iZ8vba689kou8r8sq4yw44Z ~]# lsblk 

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT

vda    253:0    0    40G  0 disk 

└─vda1 253:1    0    40G  0 part /

vdb    253:16   0     3T  0 disk 

└─vdb1 253:17   0 931.3G  0 part 

分区表的变化通知内核

[root@iZ8vba689kou8r8sq4yw44Z ~]# partprobe 

创建文件系统

[root@iZ8vba689kou8r8sq4yw44Z ~]# mkfs.xfs -f /dev/vdb1

meta-data=/dev/vdb1              isize=512    agcount=4, agsize=61035072 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=1        finobt=1, sparse=1, rmapbt=0

         =                       reflink=1

data     =                       bsize=4096   blocks=244140288, imaxpct=25

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0, ftype=1

log      =internal log           bsize=4096   blocks=119209, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

查看磁盘待分配容量

[root@iZ8vba689kou8r8sq4yw44Z ~]# parted /dev/vdb

GNU Parted 3.2

Using /dev/vdb

Welcome to GNU Parted! Type 'help' to view a list of commands.

(parted) print free                                                       

Model: Virtio Block Device (virtblk)

Disk /dev/vdb: 3221GB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Disk Flags: 



Number  Start   End     Size    File system  Name     Flags

        17.4kB  1049kB  1031kB  Free Space

 1      1049kB  1000GB  1000GB  xfs          primary

        1000GB  3221GB  2221GB  Free Space

可以看到,第一个分区扇区起始位置是1049kB,结束扇区为1000GB

分配另一个分区

mkpart <分区名称> <起始扇区> <容量分配百分比>

(parted) mkpart test 1000GB 100%                                          

(parted) print                                                            

Model: Virtio Block Device (virtblk)

Disk /dev/vdb: 3221GB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Disk Flags: 



Number  Start   End     Size    File system  Name     Flags

 1      1049kB  1000GB  1000GB  xfs          primary

 2      1000GB  3221GB  2221GB               test



(parted) quit                                                             

Information: You may need to update /etc/fstab.

为新分区创建文件系统

[root@iZ8vba689kou8r8sq4yw44Z ~]# mkfs.xfs -f /dev/vdb2                   

meta-data=/dev/vdb2              isize=512    agcount=4, agsize=135572800 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=1        finobt=1, sparse=1, rmapbt=0

         =                       reflink=1

data     =                       bsize=4096   blocks=542291200, imaxpct=5

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0, ftype=1

log      =internal log           bsize=4096   blocks=264790, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

查看分区容量变化

[root@iZ8vba689kou8r8sq4yw44Z ~]# fdisk -l

Disk /dev/vda: 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: 0x951dd9ee



Device     Boot Start      End  Sectors Size Id Type

/dev/vda1  *     2048 83886046 83883999  40G 83 Linux





Disk /dev/vdb: 3 TiB, 3221225472000 bytes, 6291456000 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: gpt

Disk identifier: 470E1DEF-DE79-403E-814C-0FD8F649FFC4



Device          Start        End    Sectors   Size Type

/dev/vdb1        2048 1953124351 1953122304 931.3G Linux filesystem

/dev/vdb2  1953124352 6291453951 4338329600     2T Linux filesystem

查看分区文件系统类型

[root@iZ8vba689kou8r8sq4yw44Z ~]# blkid

/dev/vda1: UUID="a135856a-aaa1-40b1-96cd-e77e01ccf728" TYPE="xfs" PARTUUID="951dd9ee-01"

/dev/vdb1: UUID="b55442f8-0bba-493d-a4b7-38234ed044a6" TYPE="xfs" PARTLABEL="primary" PARTUUID="4ce0f3b1-cbd0-41d2-b60e-ebc34edf38d8"

/dev/vdb2: UUID="32c7dfc0-8de4-47be-9a6f-04e4b3d6105e" TYPE="xfs" PARTLABEL="test" PARTUUID="68527707-f2e2-423e-a5eb-b8b98fe35f21"

挂载

[root@iZ8vba689kou8r8sq4yw44Z ~]# df -h

Filesystem      Size  Used Avail Use% Mounted on

devtmpfs        396M     0  396M   0% /dev

tmpfs           411M     0  411M   0% /dev/shm

tmpfs           411M  472K  411M   1% /run

tmpfs           411M     0  411M   0% /sys/fs/cgroup

/dev/vda1        40G  2.6G   38G   7% /

tmpfs            83M     0   83M   0% /run/user/0

[root@iZ8vba689kou8r8sq4yw44Z ~]# mount /dev/vdb2 /data

[root@iZ8vba689kou8r8sq4yw44Z ~]# df -h

Filesystem      Size  Used Avail Use% Mounted on

devtmpfs        396M     0  396M   0% /dev

tmpfs           411M     0  411M   0% /dev/shm

tmpfs           411M  472K  411M   1% /run

tmpfs           411M     0  411M   0% /sys/fs/cgroup

/dev/vda1        40G  2.6G   38G   7% /

tmpfs            83M     0   83M   0% /run/user/0

/dev/vdb2       2.1T   15G  2.1T   1% /data

[root@iZ8vba689kou8r8sq4yw44Z ~]# parted /dev/vdbGNU Parted 3.2Using /dev/vdbWelcome to GNU Parted! Type 'help' to view a list of commands.(parted) print                                                            Model: Virtio Block Device (virtblk)Disk /dev/vdb: 3221GBSector size (logical/physical): 512B/512BPartition Table: gptDisk Flags: 
Number  Start  End  Size  File system  Name  Flags
(parted) mklabel gpt                                                      Warning: The existing disk label on /dev/vdb will be destroyed and all data on this disk will be lost. Do youwant to continue?Yes/No? q                                                                 parted: invalid token: qYes/No? No                                                                (parted) help                                                               align-check TYPE N                        check partition N for TYPE(min|opt) alignment  help [COMMAND]                           print general help, or help on COMMAND  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)  mkpart PART-TYPE [FS-TYPE] START END     make a partition  name NUMBER NAME                         name partition NUMBER as NAME  print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all        found partitions, or a particular partition  quit                                     exit program  rescue START END                         rescue a lost partition near START and END  resizepart NUMBER END                    resize partition NUMBER  rm NUMBER                                delete partition NUMBER  select DEVICE                            choose the device to edit  disk_set FLAG STATE                      change the FLAG on selected device  disk_toggle [FLAG]                       toggle the state of FLAG on selected device  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER  unit UNIT                                set the default unit to UNIT  version                                  display the version number and copyright information of GNU Parted(parted) help mkpart                                                             mkpart PART-TYPE [FS-TYPE] START END     make a partition
PART-TYPE is one of: primary, logical, extended        FS-TYPE is one of: btrfs, nilfs2, ext4, ext3, ext2, fat32, fat16, hfsx, hfs+, hfs, jfs, swsusp,        linux-swap(v1), linux-swap(v0), ntfs, reiserfs, hp-ufs, sun-ufs, xfs, apfs2, apfs1, asfs, amufs5,        amufs4, amufs3, amufs2, amufs1, amufs0, amufs, affs7, affs6, affs5, affs4, affs3, affs2, affs1,        affs0, linux-swap, linux-swap(new), linux-swap(old)        START and END are disk locations, such as 4GB or 10%.  Negative values count from the end of the        disk.  For example, -1s specifies exactly the last sector.                'mkpart' makes a partition without creating a new file system on the partition.  FS-TYPE may be        specified to set an appropriate partition ID.(parted) mkpart primary 1 1T(parted) print                                                            Model: Virtio Block Device (virtblk)Disk /dev/vdb: 3221GBSector size (logical/physical): 512B/512BPartition Table: gptDisk Flags: 
Number  Start   End     Size    File system  Name     Flags 1      1049kB  1000GB  1000GB               primary
(parted) align-check align-check  help         mktable      quit         resizepart   set          version      disk_set     mklabel      name         rescue       rm           toggle       disk_toggle  mkpart       print        resize       select       unit         (parted) align-check opt 11 aligned(parted) print                                                            Model: Virtio Block Device (virtblk)Disk /dev/vdb: 3221GBSector size (logical/physical): 512B/512BPartition Table: gptDisk Flags: 
Number  Start   End     Size    File system  Name     Flags 1      1049kB  1000GB  1000GB               primary
(parted) quit                                                             Information: You may need to update /etc/fstab.
[root@iZ8vba689kou8r8sq4yw44Z ~]# mkfs.xfs /dev/v                         vcs           vcs4          vcsa1         vcsa5         vdb           vhci          vport1p1vcs1          vcs5          vcsa2         vcsa6         vdb1          vhost-net     vcs2          vcs6          vcsa3         vda           vfio/         vhost-vsock   vcs3          vcsa          vcsa4         vda1          vga_arbiter   virtio-ports/ [root@iZ8vba689kou8r8sq4yw44Z ~]# mkfs.xfs /dev/vdb1mkfs.xfs: /dev/vdb1 appears to contain an existing filesystem (xfs).mkfs.xfs: Use the -f option to force overwrite.[root@iZ8vba689kou8r8sq4yw44Z ~]# lsblk NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTvda    253:0    0    40G  0 disk └─vda1 253:1    0    40G  0 part /vdb    253:16   0     3T  0 disk └─vdb1 253:17   0 931.3G  0 part [root@iZ8vba689kou8r8sq4yw44Z ~]# partprobe [root@iZ8vba689kou8r8sq4yw44Z ~]# mkfs.xfs /dev/vdb1mkfs.xfs: /dev/vdb1 appears to contain an existing filesystem (xfs).mkfs.xfs: Use the -f option to force overwrite.[root@iZ8vba689kou8r8sq4yw44Z ~]# mkfs.xfs -f /dev/vdb1meta-data=/dev/vdb1              isize=512    agcount=4, agsize=61035072 blks         =                       sectsz=512   attr=2, projid32bit=1         =                       crc=1        finobt=1, sparse=1, rmapbt=0         =                       reflink=1data     =                       bsize=4096   blocks=244140288, imaxpct=25         =                       sunit=0      swidth=0 blksnaming   =version 2              bsize=4096   ascii-ci=0, ftype=1log      =internal log           bsize=4096   blocks=119209, version=2         =                       sectsz=512   sunit=0 blks, lazy-count=1realtime =none                   extsz=4096   blocks=0, rtextents=0[root@iZ8vba689kou8r8sq4yw44Z ~]# parted /dev/vdbGNU Parted 3.2Using /dev/vdbWelcome to GNU Parted! Type 'help' to view a list of commands.(parted) print free                                                       Model: Virtio Block Device (virtblk)Disk /dev/vdb: 3221GBSector size (logical/physical): 512B/512BPartition Table: gptDisk Flags: 
Number  Start   End     Size    File system  Name     Flags        17.4kB  1049kB  1031kB  Free Space 1      1049kB  1000GB  1000GB  xfs          primary        1000GB  3221GB  2221GB  Free Space
(parted) mkpart test 1000GB 100%                                          (parted) print                                                            Model: Virtio Block Device (virtblk)Disk /dev/vdb: 3221GBSector size (logical/physical): 512B/512BPartition Table: gptDisk Flags: 
Number  Start   End     Size    File system  Name     Flags 1      1049kB  1000GB  1000GB  xfs          primary 2      1000GB  3221GB  2221GB               test
(parted) quit                                                             Information: You may need to update /etc/fstab.
[root@iZ8vba689kou8r8sq4yw44Z ~]# mkfs.xfs -f /dev/vdb2                   meta-data=/dev/vdb2              isize=512    agcount=4, agsize=135572800 blks         =                       sectsz=512   attr=2, projid32bit=1         =                       crc=1        finobt=1, sparse=1, rmapbt=0         =                       reflink=1data     =                       bsize=4096   blocks=542291200, imaxpct=5         =                       sunit=0      swidth=0 blksnaming   =version 2              bsize=4096   ascii-ci=0, ftype=1log      =internal log           bsize=4096   blocks=264790, version=2         =                       sectsz=512   sunit=0 blks, lazy-count=1realtime =none                   extsz=4096   blocks=0, rtextents=0[root@iZ8vba689kou8r8sq4yw44Z ~]# fdisk -lDisk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisklabel type: dosDisk identifier: 0x951dd9ee
Device     Boot Start      End  Sectors Size Id Type/dev/vda1  *     2048 83886046 83883999  40G 83 Linux

Disk /dev/vdb: 3 TiB, 3221225472000 bytes, 6291456000 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisklabel type: gptDisk identifier: 470E1DEF-DE79-403E-814C-0FD8F649FFC4
Device          Start        End    Sectors   Size Type/dev/vdb1        2048 1953124351 1953122304 931.3G Linux filesystem/dev/vdb2  1953124352 6291453951 4338329600     2T Linux filesystem[root@iZ8vba689kou8r8sq4yw44Z ~]# blkid/dev/vda1: UUID="a135856a-aaa1-40b1-96cd-e77e01ccf728" TYPE="xfs" PARTUUID="951dd9ee-01"/dev/vdb1: UUID="b55442f8-0bba-493d-a4b7-38234ed044a6" TYPE="xfs" PARTLABEL="primary" PARTUUID="4ce0f3b1-cbd0-41d2-b60e-ebc34edf38d8"/dev/vdb2: UUID="32c7dfc0-8de4-47be-9a6f-04e4b3d6105e" TYPE="xfs" PARTLABEL="test" PARTUUID="68527707-f2e2-423e-a5eb-b8b98fe35f21"[root@iZ8vba689kou8r8sq4yw44Z ~]# df -hFilesystem      Size  Used Avail Use% Mounted ondevtmpfs        396M     0  396M   0% /devtmpfs           411M     0  411M   0% /dev/shmtmpfs           411M  472K  411M   1% /runtmpfs           411M     0  411M   0% /sys/fs/cgroup/dev/vda1        40G  2.6G   38G   7% /tmpfs            83M     0   83M   0% /run/user/0[root@iZ8vba689kou8r8sq4yw44Z ~]# mount /dev/vdb1 /data[root@iZ8vba689kou8r8sq4yw44Z ~]# mount /dev/vdb2 /data[root@iZ8vba689kou8r8sq4yw44Z ~]# df -hFilesystem      Size  Used Avail Use% Mounted ondevtmpfs        396M     0  396M   0% /devtmpfs           411M     0  411M   0% /dev/shmtmpfs           411M  472K  411M   1% /runtmpfs           411M     0  411M   0% /sys/fs/cgroup/dev/vda1        40G  2.6G   38G   7% /tmpfs            83M     0   83M   0% /run/user/0/dev/vdb2       2.1T   15G  2.1T   1% /data

猜你喜欢

转载自www.cnblogs.com/zh-dream/p/12685098.html