root@sung-haproxy:~# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.34).
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 0x6a0c98a4.
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-104857599, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-104857599, default 104857599):
Created a new partition 1 of type 'Linux' and of size 50 GiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
# partprobe : partition recognize without reboot
root@sung-haproxy:/# partprobe /dev/vdb
root@sung-haproxy:/iscsi/iscsi1# mkfs.btrfs /dev/vdb1
btrfs-progs v5.4.1
See http://btrfs.wiki.kernel.org for more information.
Label: (null)
UUID: e92bab2c-ffba-4b6e-8ee5-ca26120decee
Node size: 16384
Sector size: 4096
Filesystem size: 50.00GiB
Block group profiles:
Data: single 8.00MiB
Metadata: DUP 256.00MiB
System: DUP 8.00MiB
SSD detected: no
Incompat features: extref, skinny-metadata
Checksum: crc32c
Number of devices: 1
Devices:
ID SIZE PATH
1 50.00GiB /dev/vdb1
#vdc 생략
# vg 생성
root@sung-haproxy:/iscsi/iscsi1# vgcreate iscsi_vg /dev/vdb1 /dev/vdc1
Volume group "iscsi_vg" successfully created
root@sung-haproxy:/iscsi/iscsi1# vgdisplay iscsi_vg
--- Volume group ---
VG Name iscsi_vg
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 99.99 GiB
PE Size 4.00 MiB
Total PE 25598
Alloc PE / Size 0 / 0
Free PE / Size 25598 / 99.99 GiB
VG UUID 4P8XCb-cBnA-WDDt-d4vv-EZPl-nVN5-pL8Yqi
# lv 생성
root@sung-haproxy:/dev/mapper# lvcreate -n iscsi_lv -l 100%FREE iscsi_vg
Logical volume "iscsi_lv" created.
root@sung-haproxy:/dev/mapper# lvdisplay
--- Logical volume ---
LV Path /dev/iscsi_vg/iscsi_lv
LV Name iscsi_lv
VG Name iscsi_vg
LV UUID RoYxzG-yZHa-uS08-l3oF-ed4G-e6sq-YjA9zz
LV Write Access read/write
LV Creation host, time sung-haproxy, 2022-08-03 03:52:25 +0000
LV Status available
# open 0
LV Size 99.99 GiB
Current LE 25598
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
#
root@sung-haproxy:/dev/mapper# mkfs.btrfs /dev/iscsi_vg/iscsi_lv
btrfs-progs v5.4.1
See http://btrfs.wiki.kernel.org for more information.
Label: (null)
UUID: db07ddef-5a3a-46de-a542-ffd60492f2dc
Node size: 16384
Sector size: 4096
Filesystem size: 99.99GiB
Block group profiles:
Data: single 8.00MiB
Metadata: DUP 1.00GiB
System: DUP 8.00MiB
SSD detected: no
Incompat features: extref, skinny-metadata
Checksum: crc32c
Number of devices: 1
Devices:
ID SIZE PATH
1 99.99GiB /dev/iscsi_vg/iscsi_lv
mkdir -p /iscsi
root@sung-haproxy:/# mount /dev/iscsi_vg/iscsi_lv /iscsi/
root@sung-haproxy:/# df -h | grep iscsi
/dev/mapper/iscsi_vg-iscsi_lv 100G 3.8M 98G 1% /iscsi
--------------------------------------------------------
그냥 btrfs subvolume 생성만 해도 되나?
root@sung-haproxy:/iscsi# chmod 755 /iscsi/disk
root@sung-haproxy:/iscsi/disk# btrfs subvolume create /iscsi/disk1
Create subvolume '/iscsi/disk1'
root@sung-haproxy:/iscsi# dd if=/dev/zero of=/iscsi/disk1/sung-ubuntu01-disk.img bs=1G count=5
50+0 records in
50+0 records out
53687091200 bytes (54 GB, 50 GiB) copied, 573.436 s, 93.6 MB/s
#dd if=/dev/zero of=/iscsi/disk1/sung-ubuntu02-disk.img bs=1G count=5
#dd if=/dev/zero of=/iscsi/disk1/sung-ubuntu03-disk.img bs=1G count=5
#dd if=/dev/zero of=/iscsi/disk1/sung-ubuntu04-disk.img bs=1G count=5
#dd if=/dev/zero of=/iscsi/disk1/sung-ubuntu05-disk.img bs=1G count=5
##한 번에..
#for i in {1..5}; do echo $i; dd if=/dev/zero of=/iscsi/disk1/sung-ubuntu0$i-disk.img bs=1GB count=5; sleep 5; done
(4) 새로운 iSCSI Target 생성
# 1. 새로운 Target의 이름 및 id (tid) 생성
tgtadm --lld iscsi --op new --mode target --tid 3466 -T iqn.server.ubuntu:sllee3466
# New Target Name : iscsi
# tid : 3466
# ISCSI Qualified Name(iqn) : iqn.server.ubuntu:sllee
root@sung-haproxy:/iscsi# tgtadm --lld iscsi --mode target --op show
Target 3466: iqn.server.ubuntu:sllee3466
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 0d8a0000
SCSI SN: beaf34660
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: null
Backing store path: None
Backing store flags:
Account information:
ACL information:
# 2. tid에 대응되는 logicalunit에 디스크 이미지 연결
tgtadm --lld iscsi --op new --mode logicalunit --tid 3466 --lun 1 -b /iscsi/disk1/sung-ubuntu01-disk.img
tgtadm --lld iscsi --op new --mode logicalunit --tid 3466 --lun 2 -b /iscsi/disk1/sung-ubuntu02-disk.img
tgtadm --lld iscsi --op new --mode logicalunit --tid 3466 --lun 3 -b /iscsi/disk1/sung-ubuntu03-disk.img
tgtadm --lld iscsi --op new --mode logicalunit --tid 3466 --lun 4 -b /iscsi/disk1/sung-ubuntu04-disk.img
tgtadm --lld iscsi --op new --mode logicalunit --tid 3466 --lun 5 -b /iscsi/disk1/sung-ubuntu05-disk.img
# 3. tid 접속 허가 설정
tgtadm --lld iscsi --op bind --mode target --tid 3466 -I 192.168.110.100
tgtadm --lld iscsi --op bind --mode target --tid 3466 -I 192.168.110.101
tgtadm --lld iscsi --op bind --mode target --tid 3466 -I 192.168.110.102
tgtadm --lld iscsi --op bind --mode target --tid 3466 -I 192.168.110.103
tgtadm --lld iscsi --op bind --mode target --tid 3466 -I 192.168.110.104
#LUN에 특정 노드 할당 할 수 있을까?
# - SAN Storage에서는 가능한 것 같은데, iscsiadm으로는 안되는 것 같음
# 설정 확인
root@sung-haproxy:/iscsi/disk1# tgtadm --lld iscsi --mode target --op show
Target 3466: iqn.server.ubuntu:sllee3466
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 0d8a0000
SCSI SN: beaf34660
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET 0d8a0001
SCSI SN: beaf34661
Size: 5000 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: rdwr
Backing store path: /iscsi/disk1/sung-ubuntu01-disk.img
Backing store flags:
LUN: 2
Type: disk
SCSI ID: IET 0d8a0002
SCSI SN: beaf34662
Size: 5000 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: rdwr
Backing store path: /iscsi/disk1/sung-ubuntu02-disk.img
Backing store flags:
LUN: 3
Type: disk
SCSI ID: IET 0d8a0003
SCSI SN: beaf34663
Size: 5000 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: rdwr
Backing store path: /iscsi/disk1/sung-ubuntu03-disk.img
Backing store flags:
LUN: 4
Type: disk
SCSI ID: IET 0d8a0004
SCSI SN: beaf34664
Size: 5000 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: rdwr
Backing store path: /iscsi/disk1/sung-ubuntu04-disk.img
Backing store flags:
LUN: 5
Type: disk
SCSI ID: IET 0d8a0005
SCSI SN: beaf34665
Size: 5000 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: rdwr
Backing store path: /iscsi/disk1/sung-ubuntu05-disk.img
Backing store flags:
Account information:
ACL information:
192.168.110.100
192.168.110.101
192.168.110.102
192.168.110.103
192.168.110.104
## 생성된 target 삭제
# tgtadm --lld iscsi --op delete --mode target --tid 3466
## 사용중 target 강제삭제
#tgtadm --lld iscsi --op delete --force --mode target --tid 3466
root@brightforest-ubuntu:~# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.34).
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 0x7558c0e3.
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-104857599, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-104857599, default 104857599):
Created a new partition 1 of type 'Linux' and of size 50 GiB.
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): L
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx
5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility
8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt
9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi ea Rufus alignment
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs
f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT
10 OPUS 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f1 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f4 SpeedStor
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fb VMware VMFS
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fc VMware VMKCORE
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fd Linux raid auto
1c Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fe LANstep
1e Hidden W95 FAT1 80 Old Minix be Solaris boot ff BBT
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
(2) 파티션 확인
root@brightforest-ubuntu:~# fdisk -l
...
Disk /dev/vdb: 50 GiB, 53687091200 bytes, 104857600 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: 0x7558c0e3
Device Boot Start End Sectors Size Id Type
/dev/vdb1 2048 104857599 104855552 50G 8e Linux LVM
Disk /dev/vdc: 60 GiB, 64424509440 bytes, 125829120 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: 0x0fa7eae4
Device Boot Start End Sectors Size Id Type
/dev/vdc1 2048 125829119 125827072 60G 8e Linux LVM
Disk /dev/vdd: 70 GiB, 75161927680 bytes, 146800640 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: 0xce0b4588
Device Boot Start End Sectors Size Id Type
/dev/vdd1 2048 146800639 146798592 70G 8e Linux LVM
2. 물리볼륨 생성
root@brightforest-ubuntu:~# pvcreate /dev/vdb1
Physical volume "/dev/vdb1" successfully created.
root@brightforest-ubuntu:~# pvcreate /dev/vdc1
Physical volume "/dev/vdc1" successfully created.
root@brightforest-ubuntu:~# pvcreate /dev/vdd1
Physical volume "/dev/vdd1" successfully created.
root@brightforest-ubuntu:~# pvdisplay
"/dev/vdb1" is a new physical volume of "<50.00 GiB"
--- NEW Physical volume ---
PV Name /dev/vdb1
VG Name
PV Size <50.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID wP5pKr-2kNV-aXIb-5E2F-Wv8w-3aHc-Vns37O
"/dev/vdc1" is a new physical volume of "<60.00 GiB"
--- NEW Physical volume ---
PV Name /dev/vdc1
VG Name
PV Size <60.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID r01RIY-mPPb-850G-DyYX-go5j-VjlQ-4C2vJU
"/dev/vdd1" is a new physical volume of "<70.00 GiB"
--- NEW Physical volume ---
PV Name /dev/vdd1
VG Name
PV Size <70.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID DXuL0f-apwh-BLPP-4wvG-jIjc-J3dX-ieNgsi
3. 볼륨그룹 생성
root@brightforest-ubuntu:~# vgcreate brightforest-vg /dev/vdb1 /dev/vdc1 /dev/vdd1
Volume group "brightforest-vg" successfully created
root@brightforest-ubuntu:~# vgdisplay
--- Volume group ---
VG Name brightforest-vg
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 3
Act PV 3
VG Size <179.99 GiB
PE Size 4.00 MiB
Total PE 46077
Alloc PE / Size 0 / 0
Free PE / Size 46077 / <179.99 GiB
VG UUID Es9ha0-Vc1M-xspN-WVcn-JBco-3nor-BgzRdZ
4. 논리볼륨 생성
- 100GB, 80GB(나머지) Logical Volume 생성
root@brightforest-ubuntu:~# lvcreate -n bf-lv01 -L 100GB brightforest-vg
Logical volume "bf-lv01" created.
root@brightforest-ubuntu:~# lvcreate -n bf-lv02 -l 100%FREE brightforest-vg
Logical volume "bf-lv02" created.
root@brightforest-ubuntu:~# lvdisplay
--- Logical volume ---
LV Path /dev/brightforest-vg/bf-lv01
LV Name bf-lv01
VG Name brightforest-vg
LV UUID NpQpoL-8wKY-KbXB-Tqo8-5pUq-Kur4-sefnw0
LV Write Access read/write
LV Creation host, time brightforest-ubuntu, 2022-10-13 06:45:37 +0000
LV Status available
# open 0
LV Size 100.00 GiB
Current LE 25600
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/brightforest-vg/bf-lv02
LV Name bf-lv02
VG Name brightforest-vg
LV UUID 5Zc6zq-EkD4-U78O-4AcT-Sz0T-24jm-d2wo8U
LV Write Access read/write
LV Creation host, time brightforest-ubuntu, 2022-10-13 06:46:32 +0000
LV Status available
# open 0
LV Size <79.99 GiB
Current LE 20477
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
root@sung-ubuntu02:~# fdisk /dev/vdc
Welcome to fdisk (util-linux 2.34).
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 0x3fcbbd50.
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-2097151, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-2097151, default 2097151):
Created a new partition 1 of type 'Linux' and of size 1023 MiB.
#포맷변경 Command (m for help): t Selected partition 1 Hex code (type L to list all codes): L
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris 1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT- 2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT- 3 XENIX usr 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT- 4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx 5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data 6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / . 7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility 8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt 9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi ea Rufus alignment e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT 10 OPUS 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/ 11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b 12 Compaq diagnost 5c Priam Edisk a9 NetBSD f1 SpeedStor 14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f4 SpeedStor 16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary 17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fb VMware VMFS 18 AST SmartSleep 65 Novell Netware b8 BSDI swap fc VMware VMKCORE 1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fd Linux raid auto 1c Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fe LANstep 1e Hidden W95 FAT1 80 Old Minix be Solaris boot ff BBT Hex code (type L to list all codes): 82 Changed type of partition 'Linux' to 'Linux swap / Solaris'.
Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
root@sung-ubuntu02:~#
- 포맷 & UUID 확인
```bash
root@sung-ubuntu02:~# fdisk -l
...
Disk /dev/vdc: 1 GiB, 1073741824 bytes, 2097152 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: 0x3fcbbd50
Device Boot Start End Sectors Size Id Type
/dev/vdc1 2048 2097151 2095104 1023M 82 Linux swap / Solaris
root@sung-ubuntu02:~# mkswap /dev/vdc1
Setting up swapspace version 1, size = 1023 MiB (1072689152 bytes)
no label, UUID=066cafe3-114c-432a-b038-8a7cba878267