VMware 가상머신(Rocky 8.8) 하드디스크 추가
VM에서 하드디스크 용량 300G 추가하기
(기존 용량 800G + 300G)
1. 기존 파티션 확인
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 16G 0 16G 0% /dev
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 16G 11M 16G 1% /run
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/mapper/rl-root 792G 11G 781G 2% / ------> 기존 디스크 800G
/dev/sda1 507M 255M 253M 51% /boot
tmpfs 3.2G 48K 3.2G 1% /run/user/1000
2. 가상디스크 추가하기
2-1) 해당VM 우클릭 - 설정편집 - 추가 - 하드디스크
2-2) 새 가상 디스크 생성
2-3) 추가용량 지정
3. 추가한 디스크 확인
- 하드디스크를 추가하고 아무리 fdisk -l 을 해도, 300GB 디스크가 보이지 않아서 서버 재부팅을 했다.
- 리부팅 후 아래와 같이 /dev/sdb 에 300GB가 보인다.
[root@localhost ~]# fdisk -l
Disk /dev/sda: 800 GiB, 858993459200 bytes, 1677721600 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
Disklabel type: dos
Disk identifier: 0x93a706a0
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 1050623 1048576 512M 83 Linux
/dev/sda2 1050624 17827839 16777216 8G 82 Linux swap / Solaris
/dev/sda3 17827840 1677721599 1659893760 791.5G 8e Linux LVM
Disk /dev/sdb: 300 GiB, 322122547200 bytes, 629145600 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/mapper/rl-root: 791.5 GiB, 849862459392 bytes, 1659887616 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
4. /dev/sdb 파티션 생성
[root@localhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.32.1).
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 0x8685fba4.
Command (m for help): p
Disk /dev/sdb: 300 GiB, 322122547200 bytes, 629145600 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
Disklabel type: dos
Disk identifier: 0x8685fba4
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):
First sector (2048-629145599, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-629145599, default 629145599):
Created a new partition 1 of type 'Linux' and of size 300 GiB.
Command (m for help): p
Disk /dev/sdb: 300 GiB, 322122547200 bytes, 629145600 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
Disklabel type: dos
Disk identifier: 0x8685fba4
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 629145599 629143552 300G 83 Linux
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
5. 디스크 포맷
[root@localhost ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 78642944 4k blocks and 19660800 inodes
Filesystem UUID: f04bf0cc-fecf-434a-a3c9-bde335c608d5
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616
Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done
6. 마운트하기
/dev/sdb1 장치를 '특정경로' 로 마운트할 경우
6-1) 특정경로를 먼저 생성
[root@localhost /]# mkdir /test/kkk
6-2) 마운트 명령
[root@localhost /]# mount -t ext4 /dev/sdb1 /test/kkk
6-3) 결과확인
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 16G 0 16G 0% /dev
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 16G 9.4M 16G 1% /run
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/mapper/rl-root 792G 12G 780G 2% /
/dev/sda1 507M 255M 253M 51% /boot
tmpfs 3.2G 56K 3.2G 1% /run/user/0
/dev/sdb1 295G 28K 280G 1% /test/kkk ---> 추가 디스크 300G
7. fstab에 등록해서 재부팅해도 자동마운트 되도록 설정하기
7-1) vi /etc/fstab
7-2) 파일 제일 아래 추가한 내용:
/dev/sdb1 /test/kkk ext4 defaults 0 0
7-3) :wq 로 저장하고 나온 뒤, 서버를 재시작해도 자동 마운트됨
★후기1) 처음에 /etc/fstab에 생각없이 [파일시스템 적는 부분]에 [xfs]로 적었는데, 서버 리부팅 하니 아래와 같이 emergency mode라고 떴다. 당황.....
우선 root 패스워드를 넣고, 다시 /etc/fstab 파일 내 xfs-> ext4 로 변경후 재부팅하니 정상부팅 되었다.
" 비상 모드에 있습니다. 로그인한 후 "journalctl -xb"를 입력하여 시스템 로그를 보고,
"systemctl reboot:"를 입력하여 재부팅하고,
"system default" 또는 "exit"를 입력하여 기본 모드로 부팅합니다."
journalctl : systemd의 서비스 로그를 확인할 수 있다고 한다.