Linux

Redhat Linux 9: Tạo phân hoạch với gdisk GUID GPT



Link playlist
Red Hat Enterprise Linux Administration

2023 12 14 04 40 34

Creating GPT Partitions with gdisk
If a disk is configured with a GUID Partition Table (GPT), or if it is a new disk
that does not contain anything yet and has a size that goes beyond 2 TiB, you
need to create GUID partitions. The easiest way to do so is by using the gdisk
utility. This utility has a lot of similarities with fdisk but also has some
differences.

Command (? for help):
To save you the hassle of going through this, I verified it does
what it says. After converting an MBR to a GPT, your machine
will not start anymore.
Exercise 14-3 Creating GPT Partitions with gdisk
To apply the procedure in this exercise, you need a new disk device. Do not
use a disk that contains data that you want to keep, because this exercise will
delete all data on it. If you are using this exercise on a virtual machine, you
may add the new disk through the virtualization software. If you are working
on a physical machine, you can use a USB thumb drive as a disk device for
this exercise. Note that this exercise works perfectly on a computer that starts
from BIOS and not EFI; all you need is a dedicated disk device.
1. To create a partition with gdisk, open a root shell and type gdisk /dev/sdc.
(Replace /dev/sdc with the exact device name used on your computer.)
gdisk will try to detect the current layout of the disk, and if it detects
nothing, it will create the GPT and associated disk layout.
Click here to view code image
[root@server1 ~]# gdisk /dev/sdc
GPT fdisk (gdisk) version 1.0.7
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries in memory.
Command (? for help):
2. Type n to enter a new partition. You can choose any partition number
between 1 and 128, but it is wise to accept the default partition number that
is suggested.
Click here to view code image
Command (? for help): n
Partition number (1-128, default 1): 1
3. You now are asked to enter the first sector. By default, the first sector that is
available on disk will be used, but you can specify an offset as well. This
does not make sense, so just press Enter to accept the default first sector
that is proposed.
Click here to view code image
First sector (34-2097118, default = 2048) or {+-}
4. When asked for the last sector, by default the last sector that is available on
disk is proposed (which would create a partition that fills the entire hard
disk). You can specify a different last sector, or specify the disk size using
+, the size, and KMGTP. So to create a 1-GiB disk partition, use +1G.
Click here to view code image
Partition number (1-128, default 1): 1
First sector (34-41943006, default = 2048) or {+-
Last sector (2048-41943006, default = 41943006) o
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300)
5. You now are asked to set the partition type. If you do not do anything, the
partition type is set to 8300, which is the Linux file system partition type.
Other options are available as well. You can press l to show a list of
available partition types.
The relevant partition types are as follows:
1. 8200: Linux swap
2. 8300: Linux file system
3. 8e00: Linux LVM
Notice that these are the same partition types as the ones that are used in
MBR, with two 0s added to the IDs. You can also just press Enter to accept
the default partition type 8300.
6. The partition is now created (but not yet written to disk). Press p to show an
overview, which allows you to verify that this is really what you want to
use.
Click here to view code image
Command (? for help): p
Disk /dev/sdc: 41943040 sectors, 20.0 GiB
Model: VMware Virtual S
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 49433C2B-16A9-4EA4-9D79-2
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends
First usable sector is 34, last usable sector is
Partitions will be aligned on 2048-sector boundar
Total free space is 39845821 sectors (19.0 GiB)
Number Start (sector) End (sector) Size
1 2048 2099199 1024.0 MiB
filesystem
Command (? for help):
7. If you are satisfied with the current partitioning, press w to write changes to
disk and commit. This gives a warning which you can safely ignore by
typing Y, after which the new partition table is written to the GUID
partition table.
Click here to view code image
Command (? for help): w
Final checks complete. About to write GPT data. T
OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /de
The operation has completed successfully.
8. If at this point you get an error message indicating that the partition table is
in use, type partprobe to update the kernel partition table.

[ad_2]

source

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button