1.使用fdisk对/dev/nvme0n1剩余空间进行分区
[root@WHL ~]# 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): p Partition number (3,4, default 3): 3 First sector (57690112-62914559, default 57690112): Last sector, +sectors or +size{K,M,G,T,P} (57690112-62914559, default 62914559): +300M Created a new partition 3 of type 'Linux' and of size 300 MiB. Command (m for help): p Disk /dev/nvme0n1: 30 GiB, 32212254720 bytes, 62914560 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: 0xb4aca79a Device Boot Start End Sectors Size Id Type /dev/nvme0n1p1 * 2048 1026047 1024000 500M 83 Linux /dev/nvme0n1p2 1026048 57690111 56664064 27G 8e Linux LVM /dev/nvme0n1p3 57690112 58304511 614400 300M 83 Linux
2.新添加一块儿磁盘使用gdisk,设置gpt分区表,新建分区
[root@WHL ~]# gdisk /dev/nvme0n1p2 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): n Partition number (1-128, default 1): 1 First sector (34-56664030, default = 2048) or {+-}size{KMGTP}: Last sector (2048-56664030, default = 56664030) or {+-}size{KMGTP}: +500M Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): Changed type of partition to 'Linux filesystem' Command (? for help): p Disk /dev/nvme0n1p2: 56664064 sectors, 27.0 GiB Sector size (logical/physical): 512/512 bytes Disk identifier (GUID): A7C6254C-C06D-4B7F-B656-EBF60CFCB68C 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 56664030 Partitions will be aligned on 2048-sector boundaries Total free space is 55639997 sectors (26.5 GiB) Number Start (sector) End (sector) Size Code Name 1 2048 1026047 500.0 MiB 8300 Linux filesystem
3.使用parted对新添加的磁盘添加分区(交互式)
[root@WHL ~]# parted /dev/nvme0n1p2 GNU Parted 3.2 Using /dev/nvme0n1p2 Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) mklabel New disk label type? yes parted: invalid token: yes New disk label type? gpt Warning: The existing disk label on /dev/nvme0n1p2 will be destroyed and all data on this disk will be lost. Do you want to continue? Yes/No? yes Error: Partition(s) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64 on /dev/nvme0n1p2 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. Ignore/Cancel? Ignore (parted) mkpart Partition name? []? dp2 File system type? [ext2]? Start? 0 End? 10G Warning: The resulting partition is not properly aligned for best performance: 34s % 2048s != 0s Ignore/Cancel? Ignore Error: Partition(s) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64 on /dev/nvme0n1p2 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. Ignore/Cancel? Ignore (parted) p Model: NVMe Device (nvme) Disk /dev/nvme0n1p2: 29.0GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 17.4kB 10.0GB 10000MB ext2 dp2
4.使用parted对/dev/nvme0n1新增分区(命令式)
[root@WHL ~]# parted /dev/nvme0n1p2 mklabel gpt Warning: The existing disk label on /dev/nvme0n1p2 will be destroyed and all data on this disk will be lost. Do you want to continue? Yes/No? yes Error: Partition(s) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64 on /dev/nvme0n1p2 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. Ignore/Cancel? Ignore Information: You may need to update /etc/fstab. [root@WHL ~]# parted /dev/nvme0n1p2 mklabel msdos Warning: The existing disk label on /dev/nvme0n1p2 will be destroyed and all data on this disk will be lost. Do you want to continue? Yes/No? yes Error: Partition(s) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64 on /dev/nvme0n1p2 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. Ignore/Cancel? Ignore Information: You may need to update /etc/fstab. [root@WHL ~]# parted /dev/nvme0n1p2 mkpart primary 0 1G Warning: The resulting partition is not properly aligned for best performance: 1s % 2048s != 0s Ignore/Cancel? Ignore Error: Partition(s) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64 on /dev/nvme0n1p2 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. Ignore/Cancel? Ignore Information: You may need to update /etc/fstab. [root@WHL ~]# parted /dev/nvme0n1p2 rm 1 Error: Partition(s) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64 on /dev/nvme0n1p2 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. Ignore/Cancel? Ignore Information: You may need to update /etc/fstab.
5.挑选任一分区,进行格式化挂载(临时挂载)
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@WHL ~]# vim /etc/fstab