331 lines
9.2 KiB
Markdown
331 lines
9.2 KiB
Markdown
---
|
|
tags:
|
|
- howto
|
|
- homeserver
|
|
- hardware
|
|
- linux
|
|
---
|
|
# 1. 디스크 구성 확인
|
|
## 1.1. 마운트 리스트 및 용량 확인
|
|
### 1.1.1. df
|
|
```shell
|
|
df -h
|
|
```
|
|
|
|
```shell
|
|
# result
|
|
Filesystem Size Used Avail Use% Mounted on
|
|
tmpfs 1.6G 1.9M 1.6G 1% /run
|
|
efivarfs 192K 111K 77K 59% /sys/firmware/efi/efivars
|
|
/dev/mapper/ubuntu--vg-ubuntu--lv 98G 6.7G 87G 8% /
|
|
tmpfs 7.7G 0 7.7G 0% /dev/shm
|
|
tmpfs 5.0M 0 5.0M 0% /run/lock
|
|
/dev/nvme0n1p2 2.0G 96M 1.7G 6% /boot
|
|
/dev/nvme0n1p1 1.1G 6.2M 1.1G 1% /boot/efi
|
|
tmpfs 1.6G 12K 1.6G 1% /run/user/1000
|
|
```
|
|
|
|
### 1.1.2. lsblk
|
|
```shell
|
|
sudo lsblk
|
|
```
|
|
|
|
```shell
|
|
# result
|
|
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
|
|
sda 8:0 1 3.6T 0 disk
|
|
sdb 8:16 1 3.6T 0 disk
|
|
nvme0n1 259:0 0 465.8G 0 disk
|
|
├─nvme0n1p1 259:1 0 1G 0 part /boot/efi
|
|
├─nvme0n1p2 259:2 0 2G 0 part /boot
|
|
└─nvme0n1p3 259:3 0 462.7G 0 part
|
|
└─ubuntu--vg-ubuntu--lv 252:0 0 100G 0 lvm /
|
|
```
|
|
|
|
## 1.2. system file 확인
|
|
```shell
|
|
cat /proc/partitions
|
|
```
|
|
|
|
```shell
|
|
# result
|
|
major minor #blocks name
|
|
|
|
8 0 3907018584 sda
|
|
8 16 3907018584 sdb
|
|
259 0 488386584 nvme0n1
|
|
259 1 1100800 nvme0n1p1
|
|
259 2 2097152 nvme0n1p2
|
|
259 3 485186560 nvme0n1p3
|
|
252 0 104857600 dm-0
|
|
```
|
|
|
|
## 1.3. fdisk
|
|
|
|
```shell
|
|
sudo fdisk -l
|
|
```
|
|
|
|
```shell
|
|
Disk /dev/sda: 3.64 TiB, 4000787030016 bytes, 7814037168 sectors
|
|
Disk model: HGST HUS726T4TAL
|
|
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/sdb: 3.64 TiB, 4000787030016 bytes, 7814037168 sectors
|
|
Disk model: HGST HUS726T4TAL
|
|
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/nvme0n1: 465.76 GiB, 500107862016 bytes, 976773168 sectors
|
|
Disk model: Samsung SSD 980 500GB
|
|
Units: sectors of 1 * 512 = 512 bytes
|
|
Sector size (logical/physical): 512 bytes / 512 bytes
|
|
I/O size (minimum/optimal): 16384 bytes / 131072 bytes
|
|
Disklabel type: gpt
|
|
Disk identifier: 3077F15A-410B-474F-8A12-9FAAC0E64072
|
|
|
|
Device Start End Sectors Size Type
|
|
/dev/nvme0n1p1 2048 2203647 2201600 1G EFI System
|
|
/dev/nvme0n1p2 2203648 6397951 4194304 2G Linux filesystem
|
|
/dev/nvme0n1p3 6397952 976771071 970373120 462.7G Linux filesystem
|
|
|
|
|
|
Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 100 GiB, 107374182400 bytes, 209715200 sectors
|
|
Units: sectors of 1 * 512 = 512 bytes
|
|
Sector size (logical/physical): 512 bytes / 512 bytes
|
|
I/O size (minimum/optimal): 16384 bytes / 131072 bytes
|
|
```
|
|
|
|
# 2. RAID용 Hard Disk partition 생성
|
|
```shell
|
|
sudo fdisk /dev/sda
|
|
```
|
|
|
|
```
|
|
Welcome to fdisk (util-linux 2.39.3).
|
|
Changes will remain in memory only, until you decide to write them.
|
|
Be careful before using the write command.
|
|
|
|
The device contains 'linux_raid_member' signature and it will be removed by a write command. See fdisk(8) man page and --wipe option for more details.
|
|
|
|
Device does not contain a recognized partition table.
|
|
The size of this disk is 3.6 TiB (4000787030016 bytes). DOS partition table format cannot be used on drives for volumes larger than 2199023255040 bytes for 512-byte sectors. Use GUID partition table format (GPT).
|
|
|
|
Created a new DOS (MBR) disklabel with disk identifier 0xc20c4941.
|
|
|
|
Command (m for help): g
|
|
Created a new GPT disklabel (GUID: E492E4DD-1B3C-4E69-9158-E79B0B1FF44E).
|
|
|
|
Command (m for help): n
|
|
Partition number (1-128, default 1):
|
|
First sector (2048-7814037134, default 2048):
|
|
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-7814037134, default 7814035455):
|
|
|
|
Created a new partition 1 of type 'Linux filesystem' and of size 3.6 TiB.
|
|
|
|
Command (m for help): t
|
|
Selected partition 1
|
|
Partition type or alias (type L to list all): L
|
|
1 EFI System C12A7328-F81F-11D2-BA4B-00A0C93EC93B
|
|
2 MBR partition scheme 024DEE41-33E7-11D3-9D69-0008C781F39F
|
|
3 Intel Fast Flash D3BFE2DE-3DAF-11DF-BA40-E3A556D89593
|
|
4 BIOS boot 21686148-6449-6E6F-744E-656564454649
|
|
...
|
|
41 Linux reserved 8DA63339-0007-60C0-C436-083AC8230908
|
|
42 Linux home 933AC7E1-2EB4-4F13-B844-0E14E2AEF915
|
|
43 Linux RAID A19D880F-05FC-4D3B-A006-743F0F84911E
|
|
44 Linux LVM E6D6D379-F507-44C2-A23C-238F2A3DF928
|
|
...
|
|
Aliases:
|
|
linux - 0FC63DAF-8483-4772-8E79-3D69D8477DE4
|
|
swap - 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F
|
|
home - 933AC7E1-2EB4-4F13-B844-0E14E2AEF915
|
|
uefi - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
|
|
raid - A19D880F-05FC-4D3B-A006-743F0F84911E
|
|
lvm - E6D6D379-F507-44C2-A23C-238F2A3DF928
|
|
:q
|
|
|
|
Partition type or alias (type L to list all): raid
|
|
Changed type of partition 'Linux filesystem' to 'Linux RAID'.
|
|
|
|
Command (m for help): w
|
|
The partition table has been altered.
|
|
Calling ioctl() to re-read partition table.
|
|
Syncing disks.
|
|
```
|
|
|
|
# 3. RAID 설정
|
|
## 3.1. mdadm 설치
|
|
```shell
|
|
sudo apt install mdadm
|
|
```
|
|
|
|
## 3.2. RAID 생성
|
|
```shell
|
|
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
|
|
# mdadm --create [raid경로/raid명칭] --level=[레이드 구분] --raid-devices=[레이드 구성할 하드 개수] [하드 1] [하드 2] ... [하드 n]
|
|
```
|
|
|
|
```
|
|
mdadm: Note: this array has metadata at the start and
|
|
may not be suitable as a boot device. If you plan to
|
|
store '/boot' on this device please ensure that
|
|
your boot-loader understands md/v1.x metadata, or use
|
|
--metadata=0.90
|
|
Continue creating array?
|
|
Continue creating array? (y/n) y
|
|
mdadm: Defaulting to version 1.2 metadata
|
|
mdadm: array /dev/md0 started.
|
|
```
|
|
|
|
## 3.3. format
|
|
```shell
|
|
sudo mkfs.ext4 /dev/md0
|
|
```
|
|
|
|
```
|
|
mke2fs 1.47.0 (5-Feb-2023)
|
|
Creating filesystem with 976721152 4k blocks and 244187136 inodes
|
|
Filesystem UUID: c207facc-b75b-4041-9971-bb272b26b689
|
|
Superblock backups stored on blocks:
|
|
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
|
|
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
|
|
102400000, 214990848, 512000000, 550731776, 644972544
|
|
|
|
Allocating group tables: done
|
|
Writing inode tables: done
|
|
Creating journal (262144 blocks): done
|
|
Writing superblocks and filesystem accounting information: done
|
|
```
|
|
|
|
# 4. RAID 구성 확인
|
|
[[#마운트 리스트 및 용량 확인]]
|
|
[[#system file 확인]]
|
|
|
|
## 4.1. RAID 세부 정보 확인하기
|
|
```shell
|
|
more /proc/mdstat
|
|
```
|
|
|
|
```shell
|
|
# result
|
|
Personalities : [raid1] [raid0] [raid6] [raid5] [raid4] [raid10]
|
|
md0 : active raid1 sdb[1] sda[0]
|
|
3906886464 blocks super 1.2 [2/2] [UU]
|
|
bitmap: 0/30 pages [0KB], 65536KB chunk
|
|
|
|
unused devices: <none>
|
|
```
|
|
|
|
## 4.2. mdadm
|
|
```shell
|
|
sudo mdadm --detail /dev/md0
|
|
```
|
|
|
|
```
|
|
/dev/md0:
|
|
Version : 1.2
|
|
Creation Time : Thu Aug 15 16:07:02 2024
|
|
Raid Level : raid1
|
|
Array Size : 3906884608 (3.64 TiB 4.00 TB)
|
|
Used Dev Size : 3906884608 (3.64 TiB 4.00 TB)
|
|
Raid Devices : 2
|
|
Total Devices : 2
|
|
Persistence : Superblock is persistent
|
|
|
|
Intent Bitmap : Internal
|
|
|
|
Update Time : Thu Aug 15 16:18:27 2024
|
|
State : clean, resyncing
|
|
Active Devices : 2
|
|
Working Devices : 2
|
|
Failed Devices : 0
|
|
Spare Devices : 0
|
|
|
|
Consistency Policy : bitmap
|
|
|
|
Resync Status : 3% complete
|
|
|
|
Name : tuska-server:0 (local to host tuska-server)
|
|
UUID : 4c154399:14eb5dc6:7d9a9795:32654856
|
|
Events : 144
|
|
|
|
Number Major Minor RaidDevice State
|
|
0 8 1 0 active sync /dev/sda1
|
|
1 8 17 1 active sync /dev/sdb1
|
|
```
|
|
|
|
# 5. 재부팅 시 자동 마운트
|
|
## 5.1. /etc/fstab
|
|
/dev/md0 와 같이 device 파일 이름을 fstab 파일에 추가하라는 글을 쉽게 검색할 수 있다.
|
|
하지만 재부팅 시 리눅스에서 RAID 이름을 md127과 같이 바꿔버려 부팅 과정에서 오류가 발생하므로 UUID를 추가해 오류를 방지해야 한다.
|
|
|
|
```shell
|
|
blkid | grep /dev/md
|
|
```
|
|
|
|
```
|
|
/dev/md0: UUID="c207facc-b75b-4041-9971-bb272b26b689" BLOCK_SIZE="4096" TYPE="ext4"
|
|
```
|
|
|
|
UUID 복사
|
|
|
|
```shell
|
|
sudo vim /etc/fstab
|
|
```
|
|
|
|
마지막 줄에 다음 내용 추가
|
|
|
|
```
|
|
UUID=c207facc-b75b-4041-9971-bb272b26b689 /mnt/md0 ext4 defaults 0 0
|
|
```
|
|
|
|
## 5.2. mdadm conf
|
|
```shell
|
|
sudo mdadm --detail --scan
|
|
```
|
|
|
|
결과를 복사한다.
|
|
```
|
|
ARRAY /dev/md0 metadata=1.2 UUID=4c154399:14eb5dc6:7d9a9795:32654856
|
|
```
|
|
|
|
```shell
|
|
sudo vim /etc/mdadm/mdadm.conf
|
|
```
|
|
|
|
복사한 내용을 붙여넣기 한다.
|
|
```
|
|
MAILADDR root
|
|
ARRAY /dev/md0 metadata=1.2 UUID=4c154399:14eb5dc6:7d9a9795:32654856
|
|
```
|
|
|
|
### 5.2.1. 한 번에 실행
|
|
```shell
|
|
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
|
|
```
|
|
|
|
## 5.3. RAID 마운트
|
|
```shell
|
|
sudo mkdir /mnt/md0
|
|
sudo mount /dev/md0 /mnt/md0
|
|
```
|
|
|
|
## 5.4. 마운트 확인
|
|
```shell
|
|
cd /mnt
|
|
ls -al
|
|
```
|
|
|
|
```
|
|
total 12
|
|
drwxr-xr-x 3 root root 4096 Aug 15 16:28 .
|
|
drwxr-xr-x 23 root root 4096 Aug 12 07:40 ..
|
|
drwxr-xr-x 3 root root 4096 Aug 15 16:10 md0
|
|
```
|