본문 바로가기
FullStack/40. Linux

[CentOS] 디스크 마운트 추가(신규 디스크 연결 하기)

by nakanara 2021. 1. 27.
반응형

디스크 마운트 추가(신규 디스크 연결 하기)

기존 사용하던 디스크의 용량 부족으로 새로운 디스크를 추가 연결하게 되어, 기록합니다.

작업은 root로 진행합니다.

# 디스크 정보 확인
$ fdisk -l

Disk /dev/xvdb: 214.7 GB, 214748364800 bytes, 419430400 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: 0x3eaf69fe

Disk /dev/xvdc: 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

신규 추가된 디스크는 /dev/xvdc로 100G 디스크로 연결되어 있습니다.

1. 파티션 생성

디스크를 추가하기 위해서는 파티션 생성 후 포맷 과정을 거쳐야 합니다.

# 대상 디스크 /dev/xvdc 
$ fdisk /dev/xvdc

# 1-1. n: add a new partition # 파티션 생성
Command (m for help): n 

# 1-2. p: primary (0 primary, 0 extended, 4 free)
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p

# 1-3. 파티션 분할 갯수
Partition number (1-4, default 1): 1

# 1-4. 시작 값 설정 - 기본으로 설정 (엔터)
First sector (2048-209715199, default 2048):
Using default value 2048

# 1-5. 끝 값 설정 - 기본으로 설정(엔터)
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199):
Using default value 209715199
Partition 1 of type Linux and of size 100 GiB is set

# 1-6. 설정 값 쓰기 - 저장하지 않으면 적용되지 않음
# w   write table to disk and exit
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

2. 디스크 포맷

기존 파티션 포맷 형식 확인

$ vi /etc/fstab

UUID=573cbd56-f0ec-4bdb-897e-208e5625b08d /                   ext4     defaults

포맷 형식이 ext4 확인

새로 생성한 파티션 정보 확인

$ fdisk -l

Disk /dev/xvdc: 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: 0xa77249bf

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdc1            2048   209715199   104856576   83  Linux # 새로 추가된 파티션
$ mkfs.ext4 /dev/xvdc1 # 포맷

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
6553600 inodes, 26214144 blocks
1310707 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2174746624
800 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

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

3. 파티션 연결

연결할 폴더 생성


$ cd /
# 디렉토리 생성
$ mkdir apps
# 디스크 연결
$ mount /dev/xvdc1 /apps

# 확인
$ mount -a
$ df -h

/dev/xvdc1              103079864    61464  97759188   1% /apps
  • mount 명령어로 연결할 경우 재시작하면 사라지기 때문에 영구적으로 적용하기 위해서는 설정 파일 변경
$ vi /etc/fstab
UUID=573cbd56-f0ec-4bdb-897e-208e5625b08d /                   ext4     defaults
/dev/xvdc1              /apps                   ext4    defaults        0 0 # 새로운 디스크 정보 작성

#centos #mount #디스크 #디스크연결

반응형