본문으로 바로가기

1. 디스크 확인

# fdisk -l

Disk /dev/sdb: 2199.0 GB, 2199022206976 bytes, 4294965248 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000b94e4

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   209715199   103808000   8e  Linux LVM

 

Disk /dev/sdb: 2199.0 GB, 2199022206976 bytes, 4294965248 sectors

sdb라는 이름으로 2TB짜리 디스크가 추가된 것을 알 수 있습니다.

 

2. 파티션 나누기

# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel
New disk label type? gpt
(parted) unit TB
(parted) print
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 2.20TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start  End  Size  File system  Name  Flags

(parted) mkpart primary 0TB 2.29TB
(parted) q
Information: You may need to update /etc/fstab.

 

GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel // 디스크 라벨을 설정 (bsd, gpt, loop, mac, mips, msdos, pc98, sun 지원)

New disk label type? gpt // 2TB 이상 사용하기 위해서 gpt 사용 (일반적으로 msdos 사용)
(parted) unit TB // 기준 단위 TB로 변환
(parted) print // 디스크 정보 출력 (파티션 테이블)
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 2.20TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start  End  Size  File system  Name  Flags

(parted) mkpart primary 0TB 2.29TB // 파티션 나누기 (파티션타입  [파일시스템 타입] FirstSector LastSector)
(parted) q // parted 종료
Information: You may need to update /etc/fstab.

 

3. 파일 시스템 포맷

파일 시스템은 다음과 같이 권장합니다. (실제 현업에서도 이렇게 사용합니다.)

2TB 이상일 경우 ext4 (추가적으로 2TB 이상일 경우 fdisk 말고 parted 명령어를 이용하여 설정을 권장합니다)
2TB 미만일 경우 xfs

# mkfs.ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
134217728 inodes, 536870144 blocks
26843507 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
16384 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000, 214990848, 512000000

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

 

4. 파티션 확인

# parted -l
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 107GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  1075MB  1074MB  primary  xfs          boot
 2      1075MB  107GB   106GB   primary               lvm


Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 2199GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  2199GB  2199GB  ext4         primary

1이라는 이름 (=sdb1)으로 2TB ext4로 파티션이 생성된 것을 확인할 수 있습니다.

Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 2199GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  2199GB  2199GB  ext4         primary

 

5. 디렉터리 생성 & 마운트

1. 디렉토리 생성

마운트 할 디렉터리를 생성합니다.

# cd /
# mkdir disk
# ll
합계 24
lrwxrwxrwx.   1 root root    7  4월  7  2021 bin -> usr/bin
dr-xr-xr-x.   5 root root 4096  5월 12  2021 boot
drwxr-xr-x.  21 root root 3300  4월 17 00:23 dev
drwxr-xr-x.   2 root root    6  4월 17 00:24 disk
...

 

2. UUID 확인

etc/fstab 파일에 마운트 등록을 하기 위해 UUID를 확인합니다. 

# blkid
/dev/sdb1: UUID="cc3f93c0-aeb7-4e5e-9e04-406a4dc67d1b" TYPE="ext4" PARTLABEL="primary" PARTUUID="44f7d38b-b01a-498c-b1d1-3a2d45d72e5b"
/dev/sda1: UUID="e20d2ddb-b9a3-49be-8dd0-22603baf506d" TYPE="xfs"

 

3. fstab 등록

재부팅 시에도 자동으로 마운트 하기 위해서 etc/fstab 파일에 마운트 정보를 등록합니다.

# vi /etc/fstab
UUID=cc3f93c0-aeb7-4e5e-9e04-406a4dc67d1b /disk ext4 defaults 0 0

 

4. 마운트

fstab에 있는 모든 파일 시스템을 마운트 합니다.

# mount -a

 

6. 확인

# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 1.9G     0  1.9G   0% /dev
tmpfs                    1.9G     0  1.9G   0% /dev/shm
tmpfs                    1.9G  9.3M  1.9G   1% /run
tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/centos-root   75G   11G   65G  14% /
/dev/mapper/centos-home   21G   68M   21G   1% /home
/dev/sda1               1014M  280M  735M  28% /boot
tmpfs                    379M   12K  379M   1% /run/user/42
tmpfs                    379M     0  379M   0% /run/user/0
/dev/sdb1                2.0T   81M  1.9T   1% /disk

 

7. 권한 부여(필요시)

# chmod 777 disk/