原文链接:统信UOS/麒麟KYLINOS上创建GPT分区
hello,大家好啊!今天我要给大家带来的是在统信UOS及麒麟KYLINOS操作系统上创建GPT(GUID Partition Table)分区的教程。在现代计算机系统中,GPT分区表因其高效和灵活性而越来越受欢迎,它支持的磁盘大小和分区数量远超传统的MBR(Master Boot Record)分区表。本文将指导您如何在这两个操作系统上创建GPT分区,操作相对简单。
注意事项
1.查看系统信息
pdsyw@pdsyw-PC:~/Desktop$ cat /etc/os-version
[Version]
SystemName=UOS Desktop
SystemName[zh_CN]=统信桌面操作系统
ProductType=Desktop
ProductType[zh_CN]=桌面
EditionName=Professional
EditionName[zh_CN]=专业版
MajorVersion=20
MinorVersion=1060
OsBuild=11014.100.100
pdsyw@pdsyw-PC:~/Desktop$
pdsyw@pdsyw-PC:~/Desktop$ uname -a
Linux pdsyw-PC 4.19.0-arm64-desktop #6034 SMP Thu Aug 17 13:12:04 CST 2023 aarch64 GNU/Linux
pdsyw@pdsyw-PC:~/Desktop$
2.查看磁盘分区
pdsyw@pdsyw-PC:~/Desktop$ sudo -i
请输入密码:
验证成功
root@pdsyw-PC:~#
root@pdsyw-PC:~# parted -l
Model: ATA 1060-0 SSD (scsi)
Disk /dev/sda: 68.7GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 316MB 315MB fat32 primary boot, esp
2 316MB 1926MB 1611MB ext4 primary
3 1926MB 10.6GB 8640MB linux-swap(v1) primary
4 10.6GB 22.7GB 12.1GB ext4 primary
5 22.7GB 38.8GB 16.1GB ext4 primary
6 38.8GB 54.9GB 16.1GB ext4 primary
7 54.9GB 68.7GB 13.8GB ext4 primary
Warning: Unable to open /dev/sr0 read-write (只读文件系统). /dev/sr0 has been opened
read-only.
Error: /dev/sr0: unrecognised disk label
Model: Virtual DVD-ROM (scsi)
Disk /dev/sr0: 3658MB
Sector size (logical/physical): 2048B/2048B
Partition Table: unknown
Disk Flags:
root@pdsyw-PC:~#
3.添加sdb磁盘后查看分区
pdsyw@pdsyw-PC:~/Desktop$ sudo -i
请输入密码:
验证成功
root@pdsyw-PC:~#
root@pdsyw-PC:~# parted -l
Model: ATA 1060-0 SSD (scsi)
Disk /dev/sda: 68.7GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 316MB 315MB fat32 primary boot, esp
2 316MB 1926MB 1611MB ext4 primary
3 1926MB 10.6GB 8640MB linux-swap(v1) primary
4 10.6GB 22.7GB 12.1GB ext4 primary
5 22.7GB 38.8GB 16.1GB ext4 primary
6 38.8GB 54.9GB 16.1GB ext4 primary
7 54.9GB 68.7GB 13.8GB ext4 primary
Error: /dev/sdb: unrecognised disk label
Model: ATA 1060-1 SSD (scsi)
Disk /dev/sdb: 107GB
Sector size (logical/physical): 512B/4096B
Partition Table: unknown
Disk Flags:
Warning: Unable to open /dev/sr0 read-write (只读文件系统). /dev/sr0 has been opened
read-only.
Error: /dev/sr0: unrecognised disk label
Model: Virtual DVD-ROM (scsi)
Disk /dev/sr0: 3658MB
Sector size (logical/physical): 2048B/2048B
Partition Table: unknown
Disk Flags:
root@pdsyw-PC:~#
4.查看parted是否安装
root@pdsyw-PC:~# apt policy parted
parted:
已安装:3.2.1-25+dde
候选: 3.2.1-25+dde
版本列表:
*** 3.2.1-25+dde 500
500 https://professional-packages.chinauos.com/desktop-professional eagle/main arm64 Packages
500 https://professional-security.chinauos.com eagle/1060/main arm64 Packages
100 /usr/lib/dpkg-db/status
root@pdsyw-PC:~#
5.如果没有安装可以通过apt安装
root@pdsyw-PC:~# apt update
获取:2 https://pro-driver-packages.uniontech.com eagle InRelease [8,386 B]
获取:3 https://pro-driver-packages.uniontech.com eagle/non-free arm64 Packages [334 kB]
获取:1 https://cdn-professional-security.chinauos.com eagle/1060 InRelease [28.8 kB]
获取:4 https://cdn-professional-security.chinauos.com eagle/1060/main arm64 Packages [17.8 MB]
获取:5 https://app-store-files.uniontech.com/240102101047559/appstore eagle-pro InRelease [6,134 B]
获取:6 https://app-store-files.uniontech.com/240102101047559/appstore eagle-pro/appstore arm64 Packages [1,691 kB]
命中:8 https://professional-packages.chinauos.com/printer eagle InRelease
获取:7 https://professional-packages.chinauos.com/desktop-professional eagle InRelease [28.8 kB]
已下载 19.9 MB,耗时 6秒 (3,511 kB/s)
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
有 61 个软件包可以升级。请执行 ‘apt list --upgradable’ 来查看它们。
root@pdsyw-PC:~# apt install parted -y
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
parted 已经是最新版 (3.2.1-25+dde)。
parted 已设置为手动安装。
下列软件包是自动安装的并且现在不需要了:
aria2 libaria2-0 sqlite3
使用'apt autoremove'来卸载它(它们)。
升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 61 个软件包未被升级。
root@pdsyw-PC:~#
6.使用parted分区
root@pdsyw-PC:~# parted /dev/sdb
GNU Parted 3.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel 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) mkpart primary ext4 0GB 20GB
(parted) print
Model: ATA 1060-1 SSD (scsi)
Disk /dev/sdb: 107GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 20.0GB 20.0GB ext4 primary
(parted) quit
Information: You may need to update /etc/fstab.
root@pdsyw-PC:~#
7.查看磁盘信息
root@pdsyw-PC:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 64G 0 disk
├─sda1 8:1 0 300M 0 part /boot/efi
├─sda2 8:2 0 1.5G 0 part /boot
├─sda3 8:3 0 8G 0 part [SWAP]
├─sda4 8:4 0 11.3G 0 part /recovery
├─sda5 8:5 0 15G 0 part /
├─sda6 8:6 0 15G 0 part
└─sda7 8:7 0 12.9G 0 part /data
sdb 8:16 0 100G 0 disk
└─sdb1 8:17 0 18.6G 0 part
sr0 11:0 1 3.4G 0 rom /media/pdsyw/UOS 20
root@pdsyw-PC:~# mkfs.ext4 /dev/sdb1
mke2fs 1.44.5 (15-Dec-2018)
Discarding device blocks: done
Creating filesystem with 4882432 4k blocks and 1220608 inodes
Filesystem UUID: a52ef1f9-e9dd-4311-be99-e5649a931e4b
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
root@pdsyw-PC:~#
8.挂载分区
root@pdsyw-PC:~# mkdir /newdata
root@pdsyw-PC:~#
root@pdsyw-PC:~# mount /dev/sdb1 /newdata/
root@pdsyw-PC:~#
root@pdsyw-PC:~# df -h
文件系统 容量 已用 可用 已用% 挂载点
udev 3.9G 0 3.9G 0% /dev
tmpfs 796M 1.4M 795M 1% /run
/dev/sda5 15G 7.0G 7.0G 51% /
tmpfs 3.9G 6.1M 3.9G 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda4 12G 41M 11G 1% /recovery
/dev/sda2 1.5G 206M 1.2G 15% /boot
/dev/sda1 300M 5.4M 294M 2% /boot/efi
/dev/sda7 13G 4.0G 8.0G 34% /data
tmpfs 796M 40K 796M 1% /run/user/1000
/dev/sr0 3.5G 3.5G 0 100% /media/pdsyw/UOS 20
/dev/sdb1 19G 45M 18G 1% /newdata
root@pdsyw-PC:~#
9.将挂载信息加入到fstab中
root@pdsyw-PC:~# cp /etc/fstab{,.bak}
root@pdsyw-PC:~#
root@pdsyw-PC:~# vim /etc/fstab
root@pdsyw-PC:~# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
# /dev/sda5 LABEL=Roota
UUID=fea4ee50-df9d-4f4c-a921-390eb70db3dd / ext4 rw,relatime 0 1
# /dev/sda2 LABEL=Boot
UUID=5a1ac5f5-bd68-4b26-a9bb-75df179ea812 /boot ext4 rw,relatime 0 2
# /dev/sda1 LABEL=EFI
UUID=CEE9-84DF /boot/efi vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 2
# /dev/sda4 LABEL=Backup
UUID=6cc55be5-c8ed-4930-aef7-2ad91d0e8475 /recovery ext4 rw,relatime 0 2
# /dev/sda7 LABEL=_dde_data
UUID=95bd3d66-8669-45be-b596-77944abca15f /data ext4 rw,relatime 0 2
# /dev/sda3 LABEL=SWAP
UUID=9aaca392-458c-4f32-925b-04692d3f9a43 none swap defaults 0 0
/data/home /home none defaults,bind 0 0
/data/opt /opt none defaults,bind 0 0
/data/root /root none defaults,bind 0 0
/data/var /var none defaults,bind 0 0
/dev/sdb1 /newdata ext4 defaults 0 0
root@pdsyw-PC:~#
10.使用mount -a挂载查看是否报错
root@pdsyw-PC:~# mount -a
root@pdsyw-PC:~#
root@pdsyw-PC:~# chown pdsyw. /newdata -R
root@pdsyw-PC:~#
root@pdsyw-PC:~# ls -ltr /newdata/
总用量 16
drwx------ 2 pdsyw pdsyw 16384 1月 2 10:26 lost+found
root@pdsyw-PC:~#
15.添加分区
pdsyw@pdsyw-PC:~/Desktop$ sudo -i
请输入密码:
验证成功
root@pdsyw-PC:~# parted /dev/sdb
GNU Parted 3.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mkpart primary ext4 20GB 40GB
(parted) print
Model: ATA 1060-1 SSD (scsi)
Disk /dev/sdb: 107GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 20.0GB 20.0GB ext4 primary
2 20.0GB 40.0GB 20.0GB ext4 primary
(parted)
16.查看新添加的分区
root@pdsyw-PC:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 64G 0 disk
├─sda1 8:1 0 300M 0 part /boot/efi
├─sda2 8:2 0 1.5G 0 part /boot
├─sda3 8:3 0 8G 0 part [SWAP]
├─sda4 8:4 0 11.3G 0 part /recovery
├─sda5 8:5 0 15G 0 part /
├─sda6 8:6 0 15G 0 part
└─sda7 8:7 0 12.9G 0 part /data
sdb 8:16 0 100G 0 disk
├─sdb1 8:17 0 18.6G 0 part /newdata
└─sdb2 8:18 0 18.6G 0 part
sr0 11:0 1 1024M 0 rom
root@pdsyw-PC:~#
17.删除分区
root@pdsyw-PC:~# parted /dev/sdb
GNU Parted 3.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: ATA 1060-1 SSD (scsi)
Disk /dev/sdb: 107GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 20.0GB 20.0GB ext4 primary
2 20.0GB 40.0GB 20.0GB primary
(parted) rm 2
(parted) print
Model: ATA 1060-1 SSD (scsi)
Disk /dev/sdb: 107GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 20.0GB 20.0GB ext4 primary
(parted)
18.查看删除后的分区
root@pdsyw-PC:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 64G 0 disk
├─sda1 8:1 0 300M 0 part /boot/efi
├─sda2 8:2 0 1.5G 0 part /boot
├─sda3 8:3 0 8G 0 part [SWAP]
├─sda4 8:4 0 11.3G 0 part /recovery
├─sda5 8:5 0 15G 0 part /
├─sda6 8:6 0 15G 0 part
└─sda7 8:7 0 12.9G 0 part /data
sdb 8:16 0 100G 0 disk
└─sdb1 8:17 0 18.6G 0 part /newdata
sr0 11:0 1 1024M 0 rom
root@pdsyw-PC:~#
19.无交互添加新分区
root@pdsyw-PC:~# parted /dev/sdb --script -- mkpart primary 20GB 40GB
root@pdsyw-PC:~#
root@pdsyw-PC:~# parted /dev/sdb print
Model: ATA 1060-1 SSD (scsi)
Disk /dev/sdb: 107GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 20.0GB 20.0GB ext4 primary
2 20.0GB 40.0GB 20.0GB primary
root@pdsyw-PC:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 64G 0 disk
├─sda1 8:1 0 300M 0 part /boot/efi
├─sda2 8:2 0 1.5G 0 part /boot
├─sda3 8:3 0 8G 0 part [SWAP]
├─sda4 8:4 0 11.3G 0 part /recovery
├─sda5 8:5 0 15G 0 part /
├─sda6 8:6 0 15G 0 part
└─sda7 8:7 0 12.9G 0 part /data
sdb 8:16 0 100G 0 disk
├─sdb1 8:17 0 18.6G 0 part /newdata
└─sdb2 8:18 0 18.6G 0 part
sr0 11:0 1 1024M 0 rom
20.无交互删除分区
root@pdsyw-PC:~# parted /dev/sdb print
Model: ATA 1060-1 SSD (scsi)
Disk /dev/sdb: 107GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 20.0GB 20.0GB ext4 primary
2 20.0GB 40.0GB 20.0GB primary
root@pdsyw-PC:~# parted /dev/sdb --script -- rm 2
root@pdsyw-PC:~# parted /dev/sdb print
Model: ATA 1060-1 SSD (scsi)
Disk /dev/sdb: 107GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 20.0GB 20.0GB ext4 primary
root@pdsyw-PC:~#
通过在统信UOS及麒麟KYLINOS上创建GPT分区,您可以更好地利用现代硬盘的大容量和灵活性。GPT分区表提供了比MBR更先进的分区技术,适用于各种存储需求。
希望这篇文章能帮助到需要在统信UOS及麒麟KYLINOS上进行磁盘分区的朋友们。如果你有任何问题或者更多的经验分享,请在评论区留言,我们一起讨论。
最后,如果你觉得这篇文章有用,请分享转发。点个关注和在看吧,让我们一起探索和学习更多关于Linux系统管理和磁盘分区的知识!