GPT分区和挂载

2023年 7月 16日 33.8k 0

将GPT转换MBR会格式化硬盘:

[root@node1 ~]# parted /dev/sda mklabel msdos 
Warning: Partition(s) on /dev/sda are being used.                         
Ignore/Cancel? ignore                                                     
Warning: The existing disk label on /dev/sda will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? no  

GPT转换MBR会格式化so,需要从新分区

[root@node1 ~]# parted
GNU Parted 2.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mkpart  创建
Partition name?  []? KVM2       名称叫KVM2                                       
File system type?  [ext2]? ext4           格式为ext4                                
Start? 501GB       起始位置501GB                                                       
End? 896GB         结束位置896GB                                                       
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes
until after reboot.
(parted) p                                                                
Model: IBM ServeRAID M5110e (scsi)
Disk /dev/sda: 897GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

Number  Start   End     Size    File system     Name  Flags
 1      1049kB  211MB   210MB   fat16                 boot
 2      211MB   735MB   524MB   ext4
 3      735MB   21.7GB  21.0GB  ext4
 4      21.7GB  42.7GB  21.0GB  ext4
 5      42.7GB  53.2GB  10.5GB  ext4
 6      53.2GB  61.6GB  8389MB  linux-swap(v1)
 7      61.6GB  500GB   438GB   ext4            KVM
 8      501GB   896GB   395GB                   KVM2

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

查看下分区,是否一被加载,如果没有则强制加载

[root@node1 ~]# partx -l /dev/sda
# 1:      2048-   411647 (   409600 sectors,    209 MB)
# 2:    411648-  1435647 (  1024000 sectors,    524 MB)
# 3:   1435648- 42395647 ( 40960000 sectors,  20971 MB)
# 4:  42395648- 83355647 ( 40960000 sectors,  20971 MB)
# 5:  83355648-103835647 ( 20480000 sectors,  10485 MB)
# 6: 103835648-120219647 ( 16384000 sectors,   8388 MB)
# 7: 120219648-976562175 (856342528 sectors, 438447 MB)
# 8: 978515968-1749999615 (771483648 sectors, 394999 MB)

强制内核重读分区表

[root@node1 ~]# partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3
BLKPG: Device or resource busy
error adding partition 4
BLKPG: Device or resource busy
error adding partition 5
BLKPG: Device or resource busy
error adding partition 6
BLKPG: Device or resource busy
error adding partition 7
BLKPG: Device or resource busy
error adding partition 8

格式化分区

[root@node1 ~]# mke2fs -t ext4 /dev/sda8
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=1 blocks, Stripe width=0 blocks
24109056 inodes, 96435456 blocks
4821772 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
2943 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@node1 ~]#

查看分区UUID

[root@node1 ~]# blkid
/dev/sda5: UUID="af26c309-0fe0-4b87-9127-69a9448be0e0" TYPE="ext4" 
/dev/sda1: SEC_TYPE="msdos" UUID="60E4-D99C" TYPE="vfat" 
/dev/sda2: UUID="0a298063-c54a-4e12-ac3f-886fc8f61bd6" TYPE="ext4" 
/dev/sda3: UUID="62fd59e9-46bf-471c-8660-ba8296ddbe97" TYPE="ext4" 
/dev/sda4: UUID="88ee1c0c-f644-4d6b-9d9c-ea2772a814e3" TYPE="ext4" 
/dev/sda6: UUID="172977b9-2d1b-49c3-9f7c-73b73684dbdc" TYPE="swap" 
/dev/sda7: UUID="a51c6276-afc4-44e9-b0e7-bbd1286dd2d2" TYPE="ext4" 
/dev/sda8: UUID="6fb79176-5eeb-4a80-82c8-e221db87abeb" TYPE="ext4" 

开机挂载

[root@node1 kvm]# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Mon Nov 30 14:01:08 2015
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=62fd59e9-46bf-471c-8660-ba8296ddbe97 /                       ext4    defaults        1 1
UUID=0a298063-c54a-4e12-ac3f-886fc8f61bd6 /boot                   ext4    defaults        1 2
UUID=60E4-D99C          /boot/efi               vfat    umask=0077,shortname=winnt 0 0
UUID=88ee1c0c-f644-4d6b-9d9c-ea2772a814e3 /usr/local              ext4    defaults        1 2
UUID=af26c309-0fe0-4b87-9127-69a9448be0e0 /var                    ext4    defaults        1 2
UUID=172977b9-2d1b-49c3-9f7c-73b73684dbdc swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
UUID="a51c6276-afc4-44e9-b0e7-bbd1286dd2d2"     /kvm    ext4    defaults    1 1    
UUID="6fb79176-5eeb-4a80-82c8-e221db87abeb"     /backup    ext4    defaults    1 1 

请输入图片描述

相关文章

服务器端口转发,带你了解服务器端口转发
服务器开放端口,服务器开放端口的步骤
产品推荐:7月受欢迎AI容器镜像来了,有Qwen系列大模型镜像
如何使用 WinGet 下载 Microsoft Store 应用
百度搜索:蓝易云 – 熟悉ubuntu apt-get命令详解
百度搜索:蓝易云 – 域名解析成功但ping不通解决方案

发布评论