Gdisk

Gdisk to narzędzie do partycjonowania dysków, które obsługuje tylko GPT.

# gdisk /dev/xvda
GPT fdisk (gdisk) version 0.8.6

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: not present

Command (? for help): ?
b       back up GPT data to a file
c       change a partition's name
d       delete a partition
i       show detailed information on a partition
l       list known partition types
n       add a new partition
o       create a new empty GUID partition table (GPT)
p       print the partition table
q       quit without saving changes
r       recovery and transformation options (experts only)
s       sort partitions
t       change a partition's type code
v       verify disk
w       write table to disk and exit
x       extra functionality (experts only)
?       print this menu

Command (? for help):

Polecenia gdisk przedstawia poniższa tabela.

Polecenie Opis
c Zmienia nazwę partycji.
d Kasuje partycję.
i Wyświetla informacje o partycji.
l Wyświetla dostępne typy partycji.
n Tworzy partycję.
o Nadaje dyskowi etykietę GPT.
p Wyświetla tablicę partycji.
q Wychodzi z gdisk bez zapisywania modyfikacji.
r Zapewnia dodatkowe polecenia do odzyskiwania i transformacji.
S Wyświetla posortowaną listę partycji.
v Weryfikuje dysk.
w Zapisuje zmiany i wychodzi z gdisk.
x Zapewnia dodatkowe polecenia dla operacji na poziomie eksperta.

 

Ćwiczenie 1. Tworzenie tablicy partycji GPT i partycji przy użyciu gdisk.

Uruchamiamy gdisk na dysku /dev/vdc:
# gdisk /dev/vdc
GPT fdisk (gdisk) version 0.8.6
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries.
Command (? for help):

Przypisanie dyskowi tablicy partycji GPT przy użyciu polecenia o:
Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y

Uruchamiamy p aby wyświetlić etykietę dysku:
Command (? for help): p
Disk /dev/vdc: 4194304 sectors, 2.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): AA668D3F-FEB4-4959-B949-7D15684F5254
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 4194270
Partitions will be aligned on 2048-sector boundaries
Total free space is 4194237 sectors (2.0 GiB)
Number Start (sector) End (sector) Size Code Name
The output shows the assigned GUID states that the partition table can hold up to 128 partition entries.

Tworzymy partycję o rozmiarze 200MB przy użyciu polecenia n. Wybieramy wartości domyślne poza rozmiarem partycji.
Command (? For help): n
Partition number (1-128, default 1):
First sector (34-4194270, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-4194270, default = 4194270) or {+-}size{KMGTP}: +200M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'

Weryfikujemy nowe partycje komendą p:
Command (? for help): p

Zapisujemy zmiany dysku poleceniem w, potwierdzamy y:
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/vdc.
The operation has completed successfully.
You may need to run the partprobe command after exiting the gdisk utility to inform the kernel of changes in the
partition table if the disk previously had partitions. This is not required for new unpartitioned disks.

Weryfikujemy informacje o partycjach:
# gdisk –l /dev/vdc
GPT fdisk (gdisk) version 0.8.6
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Disk /dev/vdc: 4194304 sectors, 2.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): AA668D3F-FEB4-4959-B949-7D15684F5254
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 4194270
Partitions will be aligned on 2048-sector boundaries
Total free space is 3784637 sectors (1.8 GiB)
Number Start (sector) End (sector) Size Code Name
1 2048 411647 200.0 MiB 8300 Linux filesystem

Ćwiczenie 2. Kasowanie partycji przy użyciu gdisk.

Uruchamiamy gdisk na dysku /dev/vdc:
# gdisk /dev/vdc

Wyświetlamy aktualną tablicę partycji:
Command (? for help): p

Wykonujemy polecenie d i określamy numer partycji do usunięcia:
Command (? for help): d1

Weryfikujemy informacje o partycjach poleceniem p i opuszczamy gdisk:
Command (? for help): p
Command (? for help): q

Weryfikujemy informacje o partycjach:
# gdisk –l /dev/vdc
# grep vdc /proc/partitions

Leave a Reply

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