一分钟学会Linux分区挂载

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

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


相关实践学习
CentOS 7迁移Anolis OS 7
龙蜥操作系统Anolis OS的体验。Anolis OS 7生态上和依赖管理上保持跟CentOS 7.x兼容,一键式迁移脚本centos2anolis.py。本文为您介绍如何通过AOMS迁移工具实现CentOS 7.x到Anolis OS 7的迁移。
相关文章
|
3月前
|
存储 监控 安全
在Linux中,⼀个EXT3的文件分区,当使用touch test.file命令创建⼀个新文件时报错,报错的信息是提示磁盘已满,但是采用df -h命令查看磁盘大小时,只使用了,60%的磁盘空间,为什么会出现这个情况?
在Linux中,⼀个EXT3的文件分区,当使用touch test.file命令创建⼀个新文件时报错,报错的信息是提示磁盘已满,但是采用df -h命令查看磁盘大小时,只使用了,60%的磁盘空间,为什么会出现这个情况?
|
1月前
|
Linux
linux开机挂载镜像
【10月更文挑战第1天】在 Linux 系统中,开机挂载镜像通常涉及几个关键步骤,包括创建挂载点、编辑配置文件以及重新加载配置
71 0
|
3月前
|
Ubuntu Linux
内核实验(四):Qemu调试Linux内核,实现NFS挂载
本文介绍了在Qemu虚拟机中配置NFS挂载的过程,包括服务端的NFS服务器安装、配置和启动,客户端的DHCP脚本添加和开机脚本修改,以及在Qemu中挂载NFS、测试连通性和解决挂载失败的方法。
192 0
内核实验(四):Qemu调试Linux内核,实现NFS挂载
|
3月前
|
存储 Linux
在Linux中,如何使用fstab文件配置自动挂载?
在Linux中,如何使用fstab文件配置自动挂载?
|
3月前
|
算法 Linux 索引
Linux0.11 根文件系统挂载(四)
Linux0.11 根文件系统挂载(四)
33 0
|
3月前
|
存储 Linux Shell
【应用服务 App Service】App Service For Linux 中如何挂载一个共享文件夹呢? Mount Azure Storage Account File Share
【应用服务 App Service】App Service For Linux 中如何挂载一个共享文件夹呢? Mount Azure Storage Account File Share
|
3月前
|
存储 Linux 网络安全
【Azure 存储服务】如何把开启NFS 3.0协议的Azure Blob挂载在Linux VM中呢?(NFS: Network File System 网络文件系统)
【Azure 存储服务】如何把开启NFS 3.0协议的Azure Blob挂载在Linux VM中呢?(NFS: Network File System 网络文件系统)
|
3月前
|
存储 Linux 5G
linux操作系统初始化后,再也不用手动分区了
linux操作系统初始化后,再也不用手动分区了
33 0
|
3月前
|
Linux
在Linux中,如何挂载一个ISO文件?
在Linux中,如何挂载一个ISO文件?
|
3月前
|
Linux
在Linux中,如何创建一个分区?
在Linux中,如何创建一个分区?

热门文章

最新文章