Linux系统分区(硬盘GPT分区与MBR分区的转换)

 

 

 

 

4.分区方法

[root@rhel7 ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

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 (0 primary, 0 extended, 4 free) ##主分区
e extended ##扩展分区
Select (default p): p ##建立主分区
Partition number (1-4, default 1): 1 ##分区表位置
First sector (2048-20971519, default 2048): ##分区起始位置(推荐使用默认)
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +100M ##分区结束位置
Partition 1 of type Linux and of size 100 MiB is set

Command (m for help): p ##显示分区表

Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 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
Disk label type: dos
Disk identifier: 0x0002db10

Device Boot Start End Blocks Id System
/dev/sdb1 2048 206847 102400 83 Linux

Command (m for help): wq ##退出保存,如果直接q表示退出不保存
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@rhel7 ~]# partprobe ##同步分区表
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
[root@rhel7 ~]# mkfs.xfs /dev/sdb1 ##格式化设备为xfs文件系统(相当与在/dev/sdb1上安装设备管理软件)
mkfs.xfs: /dev/sdb1 appears to contain an existing filesystem (xfs).
mkfs.xfs: Use the -f option to force overwrite.

三.MBR分区方式转换成GPT

 

[root@rhel7 ~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.

(parted) mklabel

New disk label type? gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?

Yes/No? yes

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

 

 

四.GPT分区方式

[root@rhel7 ~]# fdisk /dev/sdb
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Welcome to fdisk (util-linux 2.23.2).

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 number (1-128, default 1): 1 ##分区表位置
First sector (34-20971486, default 2048): ##分区起始位置(推荐使用默认)
Last sector, +sectors or +size{K,M,G,T,P} (2048-20971486, default 20971486): +100M ##分区结束位置
Created partition 1

Command (m for help): p ##显示分区

Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 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
Disk label type: gpt ##分区方式为gpt
Disk identifier: 76E1957A-23A1-4FCB-8880-0DBAA9B5823A

# Start End Size Type Name
1 2048 206847 100M Linux filesyste

Command (m for help): wq ##退出保存
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

 

五.GPT分区方式转换成MBR

 

 

[root@rhel7 ~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.

(parted) mklabel

New disk label type? msdos
Warning: The existing disk label on /dev/sdb will be destroyed and all
data on this disk will be lost. Do you want to continue?

Yes/No? yes

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

 

转自:

https://blog.csdn.net/chaos_oper/article/details/104559861

 

posted on 2022-10-27 11:35  神通停客  阅读(2171)  评论(0编辑  收藏  举报

导航