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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM