Handbook:X86/Blocks/Disks/ko

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Handbook:X86/Blocks/Disks and the translation is 100% complete.



비록 (예를 들어서 btrfs RAID를 만든다 치면) 이론적으로 리눅스 시스템을 저장할 디스크 전체를 분할하지 않고도 사용할 수 있다고는 하지만, 실제로는 거의 불가능합니다. 대신, 전체 디스크 블록 장치를 더 작게 나누고, 더 관리하기 쉬운 블록 장치로 만들 수 있습니다. x86 시스템에서는, 분할 영역(파티션)이라고 합니다. 현재 MBR과 GPT 두가지 분할 표준 기술이 있습니다.

GPT

GPT (GUID 분할 영역 테이블) 설정에선 분할 영역에 64비트 식별자를 사용합니다. 분할 영역 정보를 저장하는 위치는 512 바이트의 MBR보다 훨씬 크며, GPT 디스크 분할 영역의 수는 실제로 제한이 없습니다. 또한 분할 영역 크기도 훨씬 큰 제한 용량 값 범위에 들어갑니다(거의 8 ZiB - 예, 제타바이트입니다).

운영 체제와 펌웨어의 시스템 프로그램 인터페이스가 (BIOS 대신) UEFI일 때, GPT는 MBR로 인한 호환성 문제가 일어나는 현 상황에서 단연 필수라 할 수 있습니다.

GPT는 또한 검사합과 중복을 활용하는 이점이 있습니다. CRC32 검사합 값을 활용하여 헤더와 분할 영역 테이블의 오류를 찾으며 디스크의 마지막 부분에 GPT 정보를 백업합니다. 백업 데이블은 디스크 시작 부분의 주 GPT가 손상됐을 경우 복원할 때 사용할 수 있습니다.

중요
There are a few caveats regarding GPT:
  • Using GPT on a BIOS-based computer works, but then one cannot dual-boot with a Microsoft Windows operating system. The reason is that Microsoft Windows will boot in UEFI mode if it detects a GPT partition label.
  • Some buggy (old) motherboard firmware configured to boot in BIOS/CSM/legacy mode might also have problems with booting from GPT labeled disks.

MBR

MBR(주 부트 레코드) 설정은 시작 섹터 및 분할 영역의 길이, 그리고 다음의 분할 영역 형식을 지원하는 32비트 식별자를 사용합니다: 주, 확장, 논리. 주 분할 영역은 마스터 부트 레코드 자체에 저장한 정보를 지니고 있습니다. 주 부트 레코드는 매우 작으며(보통 512 바이트) 디스크의 맨 처음에 위치합니다. 공간이 작기 때문에 오직 네 개의 주 분할 영역만을 지원합니다(예를 들자면, /dev/sda1부터 /dev/sda4까지).

더 많은 분할 영역을 지원하려면 주 분할 영역 중 하나를 확장 분할 영역으로 표시할 수 있습니다. 이 분할 영역은 논리 분할 영역(분할 영역 안의 분할 영역)을 보유할 수 있습니다.

중요
대부분 마더보드 제조사에서 지원하지만 분할 테이블을 오래된 기술로 간주합니다. 2010년 이전 생산 하드웨어에서 동작하지 않는다면, GUID 분할 테이블 방식으로 디스크를 분할하시는 방법이 최선입니다. MBR 방식으로 진행하려는 독자 여러분은 다음 내용을 참고바랍니다:
  • 대부분의 2010년 이후 생산 마더보드에서는 MBR 분할 방식을 오래된 (지원하지만 이상적은 아님) 부팅 설정으로 간주합니다.
  • 32비트 식별자는 2TiB 이상의 디스크를 MBR 방식으로 분할 처리하지 못합니다.
  • 확장 분할 영역을 사용하지 않는 한, MBR 방식은 4개의 최대 분할 영역을 지원합니다.
  • MBR 설정은 MBR 설정을 대체하는 어떤 기술도 지원하지 않습니다. 따라서 어떤 프로그램이나 사용자가 MBR을 덮어쓸 경우 모든 분할 영역 정보를 분실합니다.

핸드북 저자는 젠투를 설치할 경우라면 GPT 사용을 추천합니다.

고급 저장장치

x86 설치 CD에서는 논리 볼륨 관리자(LVM)을 지원합니다. LVM에서는 분할 영역 설정을 통해 유연성을 제공합니다. 아래 설치 과정은 일반 분할 영역을 중점적으로 다루지만, 이런 방식을 원할 경우를 대비하여 LVM을 지원한다는 사실을 알아두시는 게 유익합니다. 자세한 내용은 LVM 게시글을 살펴보십시오. 초보자 여러분은 LVM의 완전한 설명은 이 안내서의 내용 범위에 벗어난다는 사실을 알아두셨으면 합니다.

기본 분할 형태

Throughout the remainder of the handbook, we will discuss and explain two cases:

  1. UEFI firmware with GUID Partition Table (GPT) disk.
  2. MBR DOS/legacy BIOS firmware with a MBR partition table disk.

While it is possible to mix and match boot types with certain motherboard firmware, mixing goes beyond the intention of the handbook. As previously stated, it is strongly recommended for installations on modern hardware to use UEFI boot with a GPT disklabel disk.

이 핸드북의 나머지 부분에서는 다음 공간 분할 형태를 간단한 배치 예제로 활용합니다:

중요
The first row of the following table contains exclusive information for either a GPT disklabel or a MBR DOS/legacy BIOS disklabel. When in doubt, proceed with GPT, since x86 machines manufactured after the year 2010 generally support UEFI firmware and GPT boot sector.
분할 영역 파일 시스템 크기 설명
/dev/sda1 (부트로더) 2M BIOS 부트 분할 영역
/dev/sda1 ext2 (UEFI를 사용하는 경우 fat32) 128M 부트/EFI 시스템 분할 영역
/dev/sda3 (스왑) 512M 이상 스왑 분할 영역
/dev/sda4 ext4 디스크 나머지 부분 루트 분할 영역

이 내용으로 충분하고 독자 여러분이 GPT 방식으로 진행하겠다면 기본: 디스크 분할시 parted 사용편으로 넘어갈 수 있습니다. 여전히 MBR 방식(이보쇼?!)을 선호하고 예제 배치를 따라가겠다면 대안: 디스크 분할시 fdisk 사용편으로 넘어갈 수 있습니다.

fdiskparted는 디스크 공간 분할 유틸리티입니다. fdisk는 잘 알려진, 안정적인 프로그램이며 MBR 공간 분할 방식에 추천하지만 parted는 GPT 공간 분할 방식을 지원하는 리눅스용 첫 블록 장치 관리 유틸리티 중 하나입니다. fdisk 인터페이스 방식을 선호하는 사용자라면 parted 대신 gdisk(GPT fdisk)를 사용할 수 있습니다.

만들기 절차를 진행하기 전에 해당 절의 첫번째 부분에서는 분할 영역 형태를 어떻게 만드는지와 일반적인 문제를 언급하는 내용을 다루겠습니다.

분할 배치 설계

분할 영역을 얼마나 많이, 크게 할까요?

분할 영역의 수는 환경에 따라 다릅니다. 예를 들어, 사용자가 많을 경우 보안성을 개선하고 백업을 쉽게 하기 위해 /home/을 나누는 것이 좋습니다. 젠투를 메일 서버로 설치한다면, /var/에 모든 메일을 저장하므로 /var/를 나누어야 합니다. 파일 시스템의 탁월한 선택은 성능을 극대화합니다. 게임 서버는 게임 서버를 설치할 /opt/를 따로 나눕니다. 이유는 /home/과 비슷합니다: 보안과 백업이죠. 대부분의 상황에서 /usr/는 거대한 상태고 남아있습니다. 주요 프로그램을 저장할 뿐만 아니라, (보통 /usr/portage에 기본으로 들어가는) 젠투 이빌드 저장소는 거의 650MB를 차지합니다. 이 디스크 공간은 보통 이빌드 저장소내에 저장하는 packages/distfiles/ 디렉터리는 제외하고 추산합니다.

In most situations on Gentoo, /usr and /var should be kept relatively large in size. /usr hosts the majority of applications available on the system and the Linux kernel sources (under /usr/src). By default, /var hosts the Gentoo ebuild repository (located at /var/db/repos/gentoo) which, depending on the file system, generally consumes around 650 MiB of disk space. This space estimate excludes the /var/cache/distfiles and /var/cache/binpkgs directories, which will gradually fill with source files and (optionally) binary packages respectively as they are added to the system.

관리자 취향에 달려있습니다. 분할 영역 또는 볼륨을 나누면 다음과 같은 장점이 있습니다:

  • 각 분할 영역 또는 볼륨에 대해 최상의 동작을 수행하는 파일 시스템을 선택합니다.
  • 제 기능을 상실한 도구가 분할 영역 또는 볼륨에 계속 파일을 기록할 경우, 남아 있는 공간이 없어져 전체 시스템이 동작하지 않습니다.
  • 필요한 경우, (이 장점은 여러 개의 분할 영역보다는 여러 대의 디스크에서 더 돋보이지만) 동시에 여러 분할 영역을 검사할 수 있어, 파일 시스템 검사 시간을 줄일 수 있습니다.
  • 일부 분할 영역 또는 볼륨을 읽기 전용, nosuid(setuid 무시), noexec(실행 비트 무시) 등으로 마운트하여 보안성을 개선할 수 있습니다.


그러나, 마찬가지로 다중 분할 영역에는 단점도 존재합니다. 제대로 설정하지 않으면 어떤 분할 영역에는 공간이 상당히 남지만, 다른 분할 영역은 그렇지 않을 수 있습니다. 다른 골칫거리는 분할 영역이 나뉘어져 있는 상황입니다. /usr/ 또는 /var/와 같은 중요한 마운트 지점은 특히 그렇습니다. 다른 부팅 스크립트를 시작하기 전에 분할 영역을 마운트하려면 관리자가 종종 initramfs로 부팅해야합니다. 항상 있는 경우는 아니기 때문에 결과가 다양하게 나타납니다.

디스크에서 GPT 레이블을 사용하지 않으면 SCSI와 SATA에서는 분할 영역 갯수가 15개로 제한되어있습니다.

참고
Installations that intend to use systemd as the service and init system must have the /usr directory available at boot, either as part of the root filesystem or mounted via an initramfs.

스왑 공간이 무엇인가요?

완벽한 스왑 분할 영역 값은 없습니다. 스왑 영역의 존재 목적은 내부 메모리(RAM)가 용량 고갈에 처해있을 때 커널에서 디스크 공간을 제공하려는 것입니다. 스왑 영역은 커널에서 곧 접근하지 않을 메모리 페이지를 디스크(스왑 또는 페이지-아웃)에 옮기고 메모리를 확보할 수 있도록 합니다. 물론 메모리가 갑자기 필요할 때도 이 페이지를 메모리에 되돌려놓습니다만(페이지-인), 시간이 오래걸립니다(내부 메모리에 비해 디스크는 비교적 매우 느립니다).

시스템이 메모리를 집중적으로 사용하는 프로그램을 실행하려 하지 않거나 시스템에 충분한 메모리가 있을 경우 많은 스왑 영역이 필요하지 않을지도 모릅니다. 그러나 스왑 영역은 최대 절전모드 기능을 사용할 경우 전체 메모리 공간을 사용하기도 합니다. 시스템을 최대 절전모드로 진입하려 한다면, 더 큰 스왑 영역이 필요하며, 최소한, 종종 시스템에 대용량의 메모리를 설치합니다.


UEFI 사용

운영체제를 부팅할 때 (BIOS 대신) UEFI를 사용하는 시스템에 젠투를 설치할 경우, EFI 시스템 분할 영역(ESP)을 만드는 과정이 중요합니다. 아래에 설명할 parted의 절차에는 이 동작을 올바르게 처리하는데 필요한 포인터가 있습니다.

ESP는 (때로는 리눅스 시스템에서 vfat으로 나타나는) FAT 종류 중 하나여야 합니다. 공식 UEFI 명세en에서는 UEFI 펌웨어에서, ESP를 활용할 때 FAT32를 추천하지만, FAT 12, 16, 32 파일 시스템을 인식한다고 명시되어 있습니다. ESP를 FAT32로 포맷하기로 합니다:

root #mkfs.fat -F 32 /dev/sda1
중요
FAT 변종을 ESP에 사용하지 않으면 시스템의 UEFI 펌웨어를 부트로더(또는 리눅스 커널)에서 찾을 수 있음을 장담할 수 없으며 대부분의 경우 시스템 부팅이 불가능합니다!

BIOS 부트 분할 영역이란?

BIOS 부팅 분할 영역은 매우 작(1~2MB)으며 GRUB2와 같은 부트로더가 할당 저장 공간(MBR의 경우 몇 백 메가바이트정도 저장함)에 맞지 않는 추가 데이터를 저장할 수 있으며, 어떤 위치에든 둘 수 있는건 아닙니다.

대안: 디스크 분할시 fdisk 사용

다음 부분에서는 fdisk를 사용하여 예제 분할 영역 배치를 만드는 방법을 설명합니다. 예제 분할 영역 배치는 앞서 언급했습니다:

개인 취향에 따라 분할 영역 배치를 바꾸십시오.

분할 영역 설명
/dev/sda1 BIOS 부팅 분할 영역
/dev/sda1 부팅 분할 영역
/dev/sda3 스왑 분할 영역
/dev/sda4 루트 분할 영역

현재 분할 영역 배치 보기

fdisk는 디스크를 분할 영역으로 나누는 유명하고 강력한 도구입니다. fdisk를 디스크에서 다시 실행해보십시오(예제에서는 /dev/sda를 사용):

root #fdisk /dev/sda

p키를 사용하여 현재 분할 영역 설정을 표시하십시오:

Command (m for help):p
Disk /dev/sda: 240 heads, 63 sectors, 2184 cylinders
Units = cylinders of 15120 * 512 bytes
  
   Device Boot    Start       End    Blocks   Id  System
/dev/sda1   *         1        14    105808+  83  Linux
/dev/sda2            15        49    264600   82  Linux swap
/dev/sda3            50        70    158760   83  Linux
/dev/sda4            71      2184  15981840    5  Extended
/dev/sda5            71       209   1050808+  83  Linux
/dev/sda6           210       348   1050808+  83  Linux
/dev/sda7           349       626   2101648+  83  Linux
/dev/sda8           627       904   2101648+  83  Linux
/dev/sda9           905      2184   9676768+  83  Linux

Device Start End Sectors Size Type /dev/sda1 2048 2099199 2097152 1G EFI System /dev/sda2 2099200 10487807 8388608 4G Linux swap /dev/sda3 10487808 1953523711 1943035904 926.5G Linux root (x86-64)

}}

각각의 디스크에는 하나의 스왑 분할 영역과("Linux Swap"으로 나타남) 7개의 리눅스 시스템(각각의 분할 영역이 "Linux"라고 나타남)을 넣도록 설정했습니다.

fdisk에서 모든 분할 영역 제거

Pressing the g key will instantly remove all existing disk partitions and create a new GPT disklabel:

Command (m for help):g
Created a new GPT disklabel (GUID: 3E56EE74-0571-462B-A992-9872E3855D75).

디스크에서 모든 분할 영역을 제거하십시오. d를 입력하여 분할 영역을 삭제하십시오. 기존의 /dev/sda1 분할 영역을 삭제하려면:

Command (m for help):d
Partition number (1-4): 1

분할 영역을 삭제할 예정입니다. 분할 영역 목록에는 더이상 나타나지 않겠지만(p) 바뀐 내용을 저장하기 전에는 지워지지 않습니다. 사용자가 실수했을 경우 진행을 멈출 수 있습니다. 이 경우 q를 바로 입력하고 Enter를 치면 분할 영역을 삭제하지않습니다.

p를 입력하여 분할 영역 목록을 출력하고 d와 삭제할 분할 영역 번호를 입력하는 과정을 반복하십시오. 최종적으로, 분할 영역 테이블을 비웠습니다:

Command (m for help):p
Disk /dev/sda: 30.0 GB, 30005821440 bytes
240 heads, 63 sectors/track, 3876 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
  
Device Boot    Start       End    Blocks   Id  System

이제 메모리에 있는 분할 영역 테이블을 비웠고, 분할 영역을 만들 준비를 끝냈습니다.

BIOS 부팅 분할 영역 만들기

참고
A smaller ESP is possible but not recommended, especially given it may be shared with other OSes.

먼저 매우 작은 BIOS 부팅 분할 영역을 만들겠습니다. 새 분할 영역을 만드는 명령 n을 입력하시고, 주 분할 영역을 선택할 p를 입력한 후, 1을 입력하여 첫번째 주 분할 영역을 선택하십시오. 첫번째 섹터를 물어보면 2048부터 시작하는지(부트로더에 필요함)확인한 후 Enter를 치십시오. 마지막 섹터를 물어보면 +2M을 입력하여 2MB 크기의 분할 영역을 만드십시오:

Command (m for help):n
Command action
  e   extended
  p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (64-10486533532, default 64): 2048
Last sector, +sectors +size{M,K,G} (4096-10486533532, default 10486533532): +2M

Do you want to remove the signature? [Y]es/[N]o: Y The signature will be removed by a write command.

}}

UEFI 용도로 분할 영역을 표시하십시오:

Command (m for help):t
Selected partition 1
Hex code (type L to list codes): 4
Changed system type of partition 1 to 4 (BIOS boot)

Optionally, to have the ESP conform to the Discoverable System Partition (DSP) specification, switch to expert mode and perform the following extra step to set the partition's UUID:

Command (m for help):x
Expert command (m for help):u
Selected partition 1
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
New UUID (in 8-4-4-4-12 format): c12a7328-f81f-11d2-ba4b-00a0c93ec93b
Partition UUID changed from 10293DC1-DF6C-4443-8ACF-C756B81B4767 to C12A7328-F81F-11D2-BA4B-00A0C93EC93B.

Press the r key to return to the main menu:

Expert command (m for help):r
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Command (m for help):

스왑 분할 영역 만들기

마지막으로, 루트 분할 영역을 만들려면, 새 분할 영역을 만드는 명령 n을 입력하시고, p를 입력하여 fdisk에게 주 분할 영역 만들기를 지시한 후, 3을 입력하여 세번째 주 분할 영역 /dev/sda3을 만드십시오. 첫번째 섹터를 물어보면 Enter를 치십시오. 마지막 섹터를 물어보면 +512M(또는 필요한 스왑 공간만큼)을 입력하여 512MB 크기의 분할 영역을 만드십시오.

부팅 분할 영역 만들기

이 과정이 끝난 후 분할 영역 형식을 설정하는 명령 t를 입력하고, 3을 입력하여 방금 만든 분할 영역을 입력한 후, 82를 입력하여 "Linux Swap" 형식으로 바꾸십시오.

Command (m for help):t
Partition number (1,2, default 2): 2
Partition type or alias (type L to list all): 19
 
Changed type of partition 'Linux filesystem' to 'Linux swap'.

Optionally, to have the swap partition conform to the Discoverable System Partition (DSP) specification, switch to expert mode and perform the following extra step to set the partition's UUID:

Command (m for help):x
Expert command (m for help):u
Partition number (1,2, default 2): 2
Selected partition 2
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
New UUID (in 8-4-4-4-12 format): 0657fd6d-a4ab-43c4-84e5-0933c84b4f4f
Partition UUID changed from 7529CDF6-9482-4497-B021-576745648B2A to 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F..

Press the r key to return to the main menu:

Expert command (m for help):r
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Command (m for help):

루트 분할 영역 만들기

마지막으로, 루트 분할 영역을 만들려면, 새 분할 영역을 만드는 명령 n을 입력하시고, p를 입력하여 fdisk에게 주 분할 영역 만들기를 지시한 후, 4를 입력하여 네번째 주 분할 영역 /dev/sda4를 만드십시오. 첫번째 섹터를 물어보면 Enter를 치십시오. 마지막 섹터를 물어보면 Enter를 쳐서 디스크의 나머지 공간을 취하는 분할 영역을 만드십시오. 이 과정이 끝나면 p를 입력하였을 때 다음과 같은 분할 영역 테이블 모습이 나타나야합니다:

Command (m for help):n
Partition number (3-128, default 3): 3
First sector (10487808-1953525134, default 10487808):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (10487808-1953525134, default 1953523711):
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Created a new partition 3 of type 'Linux filesystem' and of size 926.5 GiB..
참고
Setting the root partition's type to "Linux root (x86-64)" is not required and the system will function normally if it is set to the "Linux filesystem" type. This filesystem type is only necessary for cases where a bootloader that supports it (i.e. systemd-boot) is used and a fstab file is not wanted.

After creating the root partition, press t to set the partition type, 3 to select the partition just created, and then type in 23 to set the partition type to "Linux Root (x86-64)".

Command(m for help):t
Partition number (1-3, default 3): 3
Partition type or alias (type L to list all): 23
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Changed type of partition 'Linux filesystem' to 'Linux root (x86-64)'

Optionally, to have the root partition conform to the Discoverable System Partition (DSP) specification, switch to expert mode and perform the following extra step to set the partition's UUID:

Command (m for help):x
Expert command (m for help):u
Partition number (1-3, default 3): 3
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
New UUID (in 8-4-4-4-12 format): 4f68bce3-e8cd-4db1-96e7-fbcaf984b709
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Partition UUID changed from 40465382-FA2A-4846-9827-640821CC001F to 4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709.

Press the r key to return to the main menu:

Expert command (m for help):r
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Command (m for help):

After completing these steps, pressing p should display a partition table that looks similar to the following:

Command (m for help):p
Disk /dev/sda: 30.0 GB, 30005821440 bytes
240 heads, 63 sectors/track, 3876 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
  
   Device Boot    Start       End    Blocks   Id  System
/dev/sda1             1         3      5198+  ef  EFI (FAT-12/16/32)
/dev/sda2   *         3        14    105808+  83  Linux
/dev/sda3            15        81    506520   82  Linux swap
/dev/sda4            82      3876  28690200   83  Linux

Device Start End Sectors Size Type /dev/sda1 2048 2099199 2097152 1G Linux filesystem /dev/sda2 2099200 10487807 8388608 4G Linux swap /dev/sda3 10487808 1953523711 1943035904 926.5G Linux root (x86-64)

Filesystem/RAID signature on partition 1 will be wiped.

}}

분할 영역 배치 저장하기

분할 영역 배치를 저장하고 fdisk를 빠져나가려면 w를 입력하십시오.

Command (m for help):w

분할 영역을 만들었다면 이제 파일 시스템을 올려놓을 차례입니다.

Partitioning the disk with MBR for BIOS / legacy boot

The following table provides a recommended partition layout for a trivial MBR DOS / legacy BIOS boot installation. Additional partitions can be added according to personal preference or system design goals.

Device path (sysfs) Mount point File system DPS UUID (PARTUUID) Description
/dev/sda1 ext4 N/A MBR DOS / legacy BIOS boot partition details.
/dev/sda2 N/A. Swap is not mounted to the filesystem like a device file. 0657fd6d-a4ab-43c4-84e5-0933c84b4f4f Swap partition details.
/dev/sda3 / xfs 44479540-f297-41b2-9af7-d131d5f0458a Root partition details.

Change the partition layout according to personal preference.

Viewing the current partition layout

Fire up fdisk against the disk (in our example, we use /dev/sda):

root #fdisk /dev/sda

Use the p key to display the disk's current partition configuration:

Command (m for help):p
Disk /dev/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: HGST HTS721010A9
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xf163b576
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Device     Boot    Start        End    Sectors   Size Id Type
/dev/sda1  *        2048    2099199    2097152     1G 83 Linux
/dev/sda2        2099200   10487807    8388608     4G 82 Linux swap / Solaris
/dev/sda3       10487808 1953525167 1943037360 926.5G 83 Linux

This particular disk was until now configured to house two Linux filesystems (each with a corresponding partition listed as "Linux") as well as a swap partition (listed as "Linux swap"), using a GPT table.

Creating a new disklabel / removing all partitions

Pressing o will instantly remove all existing disk partitions and create a new MBR disklabel (also named DOS disklabel):

Command (m for help):o
Created a new DOS disklabel with disk identifier 0xf163b576.
The device contains 'gpt' signature and it will be removed by a write command. See fdisk(8) man page and --wipe option for more details.

Alternatively, to keep an existing DOS disklabel (see the output of p above), consider removing the existing partitions one by one from the disk. Press d to delete a partition. For instance, to delete an existing /dev/sda1:

Command (m for help):d
Partition number (1-4): 1

The partition has now been scheduled for deletion. It will no longer show up when printing the list of partitions (p, but it will not be erased until the changes have been saved. This allows users to abort the operation if a mistake was made - in that case, type q immediately and hit Enter and the partition will not be deleted.

Repeatedly press p to print out a partition listing and then press d and the number of the partition to delete it. Eventually, the partition table will be empty:

Command (m for help):p
Disk /dev/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: HGST HTS721010A9
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xf163b576

The disk is now ready to create new partitions.

Creating the boot partition

First, create a small partition which will be mounted as /boot. Press n to create a new partition, followed by p for a primary partition and 1 to select the first primary partition. When prompted for the first sector, make sure it starts from 2048 (which may be needed for the boot loader) and press Enter. When prompted for the last sector, type +1G to create a partition 1 GB in size:

Command (m for help):n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-1953525167, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-1953525167, default 1953525167): +1G
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Created a new partition 1 of type 'Linux' and of size 1 GiB.

Mark the partition as bootable by pressing the a key and pressing Enter:

Command (m for help):a
Selected partition 1
The bootable flag on partition 1 is enabled now.

Note: if more than one partition is available on the disk, then the partition to be flagged as bootable will have to be selected.

Creating the swap partition

Next, to create the swap partition, press n to create a new partition, then p, then type 2 to create the second primary partition, /dev/sda2. When prompted for the first sector, press Enter. When prompted for the last sector, type +4G (or any other size needed for the swap space) to create a partition 4GB in size.

Command (m for help):n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2099200-1953525167, default 2099200):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2099200-1953525167, default 1953525167): +4G
 
Created a new partition 2 of type 'Linux' and of size 4 GiB.

After all this is done, press t to set the partition type, 2 to select the partition just created and then type in 82 to set the partition type to "Linux Swap".

Command (m for help):t
Partition number (1,2, default 2): 2
Hex code (type L to list all codes): 82
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Changed type of partition 'Linux' to 'Linux swap / Solaris'.

Creating the root partition

Finally, to create the root partition, press n to create a new partition. Then press p and 3 to create the third primary partition, /dev/sda3. When prompted for the first sector, hit Enter. When prompted for the last sector, hit Enter to create a partition that takes up the rest of the remaining space on the disk:

Command (m for help):n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3): 3
First sector (10487808-1953525167, default 10487808):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (10487808-1953525167, default 1953525167):
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Created a new partition 3 of type 'Linux' and of size 926.5 GiB.

After completing these steps, pressing p should display a partition table that looks similar to this:

Command (m for help):p
Disk /dev/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: HGST HTS721010A9
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xf163b576
</div>

<div lang="en" dir="ltr" class="mw-content-ltr">
Device     Boot    Start        End    Sectors   Size Id Type
/dev/sda1  *        2048    2099199    2097152     1G 83 Linux
/dev/sda2        2099200   10487807    8388608     4G 82 Linux swap / Solaris
/dev/sda3       10487808 1953525167 1943037360 926.5G 83 Linux

Saving the partition layout

Press w to write the partition layout and exit fdisk:

Command (m for help):w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

Now it is time to put filesystems on the partitions.