Linux的磁盘分区

目录

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

2.新添加一块儿磁盘使用gdisk,设置gpt分区表,新建分区先去添加一块SATA硬盘,然后开机查看是否加载到新的硬盘,如果检测到再进行管理操作

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

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


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

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

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): 
First sector (68675584-83886079, default 68675584):       #从当前68675584扇区开始分区
Last sector, +sectors or +size{K,M,G,T,P} (68675584-83886079, default 83886079): +500M

Created a new partition 3 of type 'Linux' and of size 500 MiB.

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

Using default response e.
Selected partition 4
First sector (69699584-83886079, default 69699584): +500M
First sector (69699584-83886079, default 69699584): 
Last sector, +sectors or +size{K,M,G,T,P} (69699584-83886079, default 83886079): +500M

Created a new partition 4 of type 'Extended' and of size 500 MiB.

...                                                                       

Command (m for help): w                                
The partition table has been altered.
Syncing disks.


2.新添加一块儿磁盘使用gdisk,设置gpt分区表,新建分区
先去添加一块SATA硬盘,然后开机查看是否加载到新的硬盘,如果检测到再进行管理操作

[root@localhost ~]# gdlsk /dev/sda 

Command (? for help): o                             #创建一个新的GPT分区表
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}: +500M
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): w                           

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y              
OK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed successfully.

 


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

先需要添加一块SATA硬盘然后检测一下

[root@localhost ~]# gdlsk /dev/sda 

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}: +500M
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): w                          

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y              
OK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed successfully.
 


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

[root@localhost ~]# parted /dev/sdb
(parted) mklabel gpt                          

(parted) mkpart part1 10M 510M 

(parted) quit                                     

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

root@localhost ~]# lsblk   

NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda             8:0    0    1G  0 disk 
├─sda1          8:1    0  500M  0 part 
└─sda2          8:2    0  300M  0 part 
sdb             8:16   0    1G  0 disk 
└─sdb1          8:17   0  476M  0 part 
 


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

[root@localhost ~]# parted /dev/sdb mkpart part2 511M 1011M

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

[root@localhost ~]# lsblk                                                    
NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda             8:0    0    1G  0 disk 
├─sda1          8:1    0  500M  0 part 
└─sda2          8:2    0  300M  0 part 
sdb             8:16   0    1G  0 disk 
├─sdb1          8:17   0  476M  0 part 
└─sdb2          8:18   0  477M  0 part 


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

[root@localhost ~]# mkfs -text4 /dev/sdb1
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 487424 1k blocks and 121920 inodes
Filesystem UUID: 1ac915fe-2ba2-4bc4-8da4-fe6deeb68fba
Superblock backups stored on blocks: 
    8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done 
root@localhost ~]# mount /dev/sdb1 /mount1          


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

[root@localhost ~]# vim /etc/fstab                       

Linux的磁盘分区_第1张图片

 

你可能感兴趣的:(servlet,java,前端)