본문 바로가기
컴퓨터 & IT (Computer & IT)/Linux

[linux] 파티션 추가하는 방법

by Physics 2023. 9. 4.
728x90

현재 상황: 사용하고 있는 클러스터의 마스터 서버에 HDD 2TB 2개와 SDD 1TB를 추가하려고 한다. 이때, HDD와 SDD는 각각 메인보드에 연결이 되어있는 상태이다. 
  a. 사용하고 있는 OS: Ubuntu 20.04 

1. fdisk를 이용하여 운영체제가 연결한 HDD 및 SDD를 인식하고 있는지 확인 

명령어 fdisk -l을 사용하여 SDD 및 HDD를 확인한다. 

Figure 1. fdisk -l 명령어를 사용한 결과

 위 Figure를 보면, sda, sdb, nvme0n1 파일이 있는 것을 확인할 수 있다. (NOTE: 리눅스의 경우, 외부 기기를 "파일"로 인식을 한다.) 하지만, nvme1n1과 다르게 아직 파티션이 할당되지 않은 것도 확인할 수 있다. 

2. 파티션 할당 

NOTE 1: Figure 1을 봤을 때, sda, sdb, nvme0n1 이 세 파일들은 파티션이 할당되지않은 patitionless 상태이다. 이런 경우에도, mkfx.xfs  명령어를 사용하여 마운트를 할 수 있다 [1]. patitionless filesystem에 대한 정보는 아래의 링크 [2]들을 확인하기 바란다.

[1] https://www.2cpu.co.kr/QnA/867161     
[2] https://unix.stackexchange.com/questions/14010/the-merits-of-a-partitionless-filesystem     

 

파티션을 할당하기 위해, fdisk 명령어를 이용을 한다. fdisk에 대한 옵션은 아래와 같다. 

Help:

  GPT
   M   enter protective/hybrid MBR

  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table

파티션을 할당하기 위해 우리가 사용할 명령어는 크게 아래 3가지이다: g, p, n 

(base) root@master:/home/xxxx# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xde931304.

Command (m for help): g
Created a new GPT disklabel (GUID: 4127C98C-9930-6947-8531-B517B8F7E112).

Command (m for help): p
Disk /dev/sdb: 1.84 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: WDC WD20EZAZ-00G
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: gpt
Disk identifier: 4127C98C-9930-6947-8531-B517B8F7E112

Command (m for help): n
Partition number (1-128, default 1): 1
First sector (2048-3907029134, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-3907029134, default 3907029134):

Created a new partition 1 of type 'Linux filesystem' and of size 1.8 TiB.

 

 

Reference
[1] https://topis.me/109    
[2] https://dataonair.or.kr/db-tech-reference/d-lounge/technical-data/?mod=document&uid=236771   

728x90

댓글