상황 설명
서버에 disk가 2개 연결되어 있습니다.
이 중 /dev/sdb 디스크가 사용되지 않고 있어서, /var/log/rsyslog 폴더에 mount를 할 계획입니다.
디스크 확인하기
- /dev/sda
- /dev/sdb
logmgmt@syslogserver:~$ sudo parted -l
Model: SEAGATE ST1000NM0023 (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 32.8GB 32.8GB primary linux-swap(v1)
2 32.8GB 33.8GB 1023MB extended
5 32.8GB 33.8GB 1023MB logical ext4
3 33.8GB 34.3GB 512MB primary fat32 boot, esp
4 34.3GB 1000GB 966GB primary ext4
Model: ATA TOSHIBA MG03ACA2 (scsi)
Disk /dev/sdb: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 2000GB 2000GB primary ntfs
logmgmt@syslogserver:~$
디스크 ubuntu에서 사용할 수 있도록 변환하기
- /dev/sdb
logmgmt@syslogserver:~$ sudo parted /dev/sdb
GNU Parted 3.4
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes
(parted) print
Model: ATA TOSHIBA MG03ACA2 (scsi)
Disk /dev/sdb: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
(parted)
mount 할 디스크의 partition 및 용량 설정하기
- /dev/sdb 용량 전체로 할당 (디스크 용량을 나눠 2개 이상으로 설정할 경우 partition은 2개 이상이 될 수 있음)
- /dev/sdb1 으로 partition 설정 (디스크로 사용할 수 있는 구역, 예 - C:\, D:\)
(parted) mkpart primary ext4 0% 100%
(parted) print
Model: ATA TOSHIBA MG03ACA2 (scsi)
Disk /dev/sdb: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 2000GB 2000GB ext4 primary
(parted) quit
Information: You may need to update /etc/fstab.
logmgmt@syslogserver:~$
mount할 디스크의 device 경로 확인하기
- /dev/sdb1 (partition이 늘어날 경우 /dev/sdb2 등으로 늘어날 수 있음)
logmgmt@syslogserver:~$ fdisk -l /dev/sdb
fdisk: cannot open /dev/sdb: Permission denied
logmgmt@syslogserver:~$ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: TOSHIBA MG03ACA2
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: C016A0C2-47FB-4524-8662-62F857982457
Device Start End Sectors Size Type
/dev/sdb1 2048 3907028991 3907026944 1.8T Linux filesystem
mount할 디스크 포멧하기
logmgmt@syslogserver:~$ sudo mkfs -t ext4 /dev/sdb1
mke2fs 1.46.5 (30-Dec-2021)
/dev/sdb1 contains a ntfs file system labelled '새 볼륨'
Proceed anyway? (y,N) y
Creating filesystem with 488378368 4k blocks and 122101760 inodes
Filesystem UUID: fe303f5e-5ba7-49e4-8b14-f9a5347f2e42
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848
Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): # 엔터
done
Writing superblocks and filesystem accounting information: #엔터
done
logmgmt@syslogserver:~$
디스크 mount 하여 리눅스에서 사용하기
logmgmt@syslogserver:~$ sudo mount -t auto /dev/sdb1 /var/log/rsyslog
logmgmt@syslogserver:~$ df -m
Filesystem 1M-blocks Used Available Use% Mounted on
tmpfs 1596 2 1594 1% /run
/dev/sda4 905596 12700 846822 2% /
tmpfs 7977 0 7977 0% /dev/shm
tmpfs 5 0 5 0% /run/lock
/dev/sda5 943 191 688 22% /boot
/dev/sda3 488 7 481 2% /boot/efi
tmpfs 1596 1 1596 1% /run/user/128
tmpfs 1596 1 1596 1% /run/user/1000
/dev/sdb1 1876685 1 1781282 1% /var/log/rsyslog #mount 완료
logmgmt@syslogserver:~$
자동으로 mount 하기
- /etc/fstab에 등록하기 위해서는 disk의 UUID 정보가 필요
logmgmt@syslogserver:~$ sudo blkid | grep /dev/sdb1
/dev/sdb1: UUID="fe303f5e-5ba7-49e4-8b14-f9a5347f2e42" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="primary" PARTUUID="39587ea9-0582-4082-b3d3-6b077fc63fc9"
logmgmt@syslogserver:~$
자동 mount 등록 설정하기 (/etc/fstab)
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda4 during installation
UUID=c64bd3a1-9b2a-4d9a-bfbf-1fd93994a1dc / ext4 errors=remount-ro 0 1
# /boot was on /dev/sda5 during installation
UUID=f3d05dfd-77c8-4a66-b9ba-4ca013060550 /boot ext4 defaults 0 2
# /boot/efi was on /dev/sda3 during installation
UUID=1785-5B0F /boot/efi vfat umask=0077 0 1
# swap was on /dev/sda1 during installation
UUID=7d8047cd-6cb8-41ec-a532-c0d6d8e4de1f none swap sw 0 0
# /var/log/rsyslog was on /dev/sdb1 during installation
UUID=fe303f5e-5ba7-49e4-8b14-f9a5347f2e42 /var/log/rsyslog ext4 defaults 0 1 # 등록
자동 mount 설정 오류 확인하기
- 메시지가 아무것도 없으면 정상 작동
logmgmt@syslogserver:~$ sudo mount -a
logmgmt@syslogserver:~$
'기술 노트 > ubuntu' 카테고리의 다른 글
rsyslog 설정하기 (1) | 2023.12.04 |
---|---|
우분투에서 IP 주소 확인하기 (1) | 2023.12.04 |
kibana 설치하기 (0) | 2023.12.01 |
logstash 설치하기 (0) | 2023.12.01 |
elasticsearch 설치하기 (0) | 2023.12.01 |