새소식

개발+공부/Linux 리눅스

[Gentoo] Gentoo Handbook: Installation (2) Preparing the disks

  • -
728x90

가장 중요한 부분이라고도 할 수 있는 partition을 설정하는 파트이다.
이 파트의 설명은 Handbook을 한 번쯤 읽어보는 것도 좋다.

Introduction to block devices

Partition tables

Linex 시스템에 분할되지 않은 disk를 그냥 사용할 수도 있지만, 실제로 거의 그렇게 하지는 않는다. 대신, disk block devices 더 작고 더 관리하기 쉬운 block devices로 분할된다. amd64(x86, ...) 시스템에서, 이것을 partition이라 부른다. 현재, 2가지 표준 partitioning 기법이 사용되고 있다: MBR(DOS disklabel)과 GPT이다. 각각 legacy BIOS boot 그리고 UEFI boot process를 적용한다.

GPT를 사용하므로 MBR에 관해서는 따로 다루지 않는다. (MBR에 관한 자세한 설명은 Handbook 참고)

GUID Partition Table(GPT)

GPT 설정(GPT disklabel)은 partition에 64-bit identifier를 사용한다. 파티션 정보를 저장하는 곳은 (512 byte:MBR보다 훨씬 크므로) 사실상 GPT 디스크의 파티션 양에는 제한이 없다. 또한, 파티션 size는 훤씬 더 큰 8 ZiB로 제한된다.

운영체제와 펌웨어 사이의 시스템 소프트웨어 인터페이스가 (BIOS 대신) UEFI일 때, 호환성 문제로 인해 GPT가 거의 필수적이다.

 

Designing a partition scheme

What is the EFI System Partition (ESP)?

OS를 부팅하기 위해 UEFI를 사용하는 시스템에서 Gentoo를 설치하는 경우, EFI System Partition(ESP)가 생성되는 것이 중요하다. EFI system partition은 BIOS/Legacy 모드에서 부팅할 때는 요구되지 않는다.

ESP는 FAT variant(vfat on Linux)이어야 한다. ESP에는 FAT32가 권장된다. Partition이후, 다음 명령어를 실행해 ESP를 포맷해준다!

root # mkfs.fat -F 32 /dev/sda1
중요!
ESP가 FAT 버전으로 포맷되지 않은 경우, 시스템의 UEFI 펌웨어가 부팅로더(or Linux 커널)를 찾지 못해 시스템을 부팅할 수 없게 된다!

 

Partitioning the disk with GPT for UEFI

해당 파트에서는 fdisk를 사용하여 GPT/UEFI boot 설치를 위한 partition layout 예제를 만든다.

Partition Description
/dev/sda1 EFI system (and boot) partition
/dev/sda2 Swap partition
/dev/sda3 Root partition

Viewing the current partition layout

 fdisk 는 disk를 partition으로 분할하는 인기있고 강력한 도구이다. (예제에서 우리는 /dev/sda 디스크를 사용한다.)

root # fdisk /dev/sda
  •  p : 현재 partition 설정을 확인한다.
Command (m for help): p
Disk /dev/sda: 28.89 GiB, 31001149440 bytes, 60549120 sectors
Disk model: DataTraveler 2.0
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 21AAD8CF-DB67-0F43-9374-416C7A4E31EA
 
Device        Start      End  Sectors  Size Type
/dev/sda1      2048   526335   524288  256M EFI System
/dev/sda2    526336  2623487  2097152    1G Linux swap
/dev/sda3   2623488 19400703 16777216    8G Linux filesystem
/dev/sda4  19400704 60549086 41148383 19.6G Linux filesystem

(위 출력결과는 어디까지나 예시이므로 신경쓸 필요없다.)

Creating a new disklabel / removing all partitions

겁내지 말고 하면 된다. 어차피 save 전까지는 실제 반영되지 않는다.
  •  g : disk에 새로운 GPT disklabel을 생성한다. (원래 존재하던 건 제거)
Command (m for help):g
Created a new GPT disklabel (GUID: 87EA4497-2722-DF43-A954-368E46AE5C5F).

 g  이후 다시,  p 를 입력하면 partition table이 비워진 것을 확인할 수 있다.

Command (m for help):p
Disk /dev/sda: 28.89 GiB, 31001149440 bytes, 60549120 sectors
Disk model: DataTraveler 2.0
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 87EA4497-2722-DF43-A954-368E46AE5C5F

Creating the EFI system partition (ESP)

먼저 EFI system partition을 생성한다.

  •  n  : 새로운 partition 생성
  •  n  1  >  2048  >  Enter  +256M
    • 2048 ~ +256M의 1번 partition을 생성한다.
Command (m for help):n
Partition number (1-128, default 1): 1
First sector (2048-60549086, default 2048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-60549086, default 60549086): +256M
 
Created a new partition 1 of type 'Linux filesystem' and of size 256 MiB.

여기서 signature를 삭제하겠냐고 묻는 다면,  y 를 입력하면 된다.

아직은 생성한 파티션이 EFI System이 아니다. partition의 type을 EFI System으로 설정한다.

  •  t : parition type 설정
Command (m for help):t
Selected partition 1
Partition type (type L to list all types): 1
Changed type of partition 'Linux filesystem' to 'EFI System'.

Creating the swap partition

swap 파티션을 생성하기 위해,  n ,  2(or Enter) ,  Enter ,  +4G 를 입력한다.

Command (m for help):n
Partition number (2-128, default 2): 
First sector (526336-60549086, default 526336): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (526336-60549086, default 60549086): +4G
 
Created a new partition 2 of type 'Linux filesystem' and of size 4 GiB.

파티션 type을 Linux swap으로 설정한다.

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

Creating the root partition

마지막으로 root partition을 생성하기 위해,  n ,  3 ,  Enter ,  Enter 를 차례로 입력한다.

 p 명령으로 생성된 partition을 확인해보자.

Command (m for help):p
Disk /dev/sda: 28.89 GiB, 31001149440 bytes, 60549120 sectors
Disk model: DataTraveler 2.0
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 87EA4497-2722-DF43-A954-368E46AE5C5F
 
Device       Start      End  Sectors  Size Type
/dev/sda1     2048   526335   524288  256M EFI System
/dev/sda2   526336  8914943  8388608    4G Linux swap
/dev/sda3  8914944 60549086 51634143 24.6G Linux filesystem

Saving the partition layout

  •  w : partition layout을 저장하고 fdisk에서 빠져나온다.
Command (m for help):w

 

Creating file systems

file system 관련 설명은 Handbook에서 읽어보길...

What is the EFI System Partition (ESP)? 섹션에서 언급했듯이 **EFI system partition(/dev/sda1)**은 FAT32로, **root partition(/dev/sda3)**은 ext4로 설정해야 한다.

root # mkfs.vfat -F 32 /dev/sda1
root # mkfs.ext4 /dev/sda3

Activating the swap partition

  •  mkswap : swap partition을 초기화한다.
root # mkswap /dev/sda2
  •  swapon : swap partition을 활성화한다.
root # swapon /dev/sda2

 

 

Mounting the root partition

partition은 초기화되었으며 파일시스템을 수용하고 있다. 이제 해당 partition들을 마운트할 차례이다. mount 명령을 사용하되 생성된 모든 파티션에 필요한 mount directory를 생성해야 한다.

예를 들어, root partition(/dev/sda3)을 mount한다.

root # mount /dev/sda3 /mnt/gentoo

 

 

다음 글

 

[Gentoo] Gentoo Handbook: Installation (3) Installing stage 3

Installing a stage tarball Setting the date and time date : 현재 날짜와 시간을 확인한다. root # date Mon Oct 3 13:16:22 PDT 2021 Automatic ntpd : 자동으로 system clock을 UTC time으로 sync한다. root..

soso-cod3v.tistory.com

 

728x90
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.