# ext4 with LVM and RAID5 (3 disks)

**Download** VMDK (zipped)

<https://files.iblue.team/279b6e00-851e/2GB-ext4-raid5/LINUX-MINT-8.vmdk.7z>\
<https://files.iblue.team/279b6e00-851e/2GB-ext4-raid5/LINUX-MINT-7.vmdk.7z>\
<https://files.iblue.team/279b6e00-851e/2GB-ext4-raid5/LINUX-MINT-6.vmdk.7z>

**Download** RAW (zipped)

<https://files.iblue.team/279b6e00-851e/2GB-ext4-raid5/LINUX-MINT-8.vmdk.dd.7z>\
<https://files.iblue.team/279b6e00-851e/2GB-ext4-raid5/LINUX-MINT-7.vmdk.dd.7z>\
<https://files.iblue.team/279b6e00-851e/2GB-ext4-raid5/LINUX-MINT-6.vmdk.dd.7z>

I've created a 3 disk RAID5 array using mdadm/LVM, which contained a few files to demonstrate how data is striped across an array.

How it was created;

1. Create file of a fixed size, using a unique string/word which is easily identifiable such as 'APPLE'

The 'yes' command will output the string passed to it (APPLE) continually until killed. It's piped into head, and it'll output a file of a size of 1GB which is redirected to apple.txt

```
$ yes APPLE | head -c 1073741824 > apple.txt
```

Do this 3 more times using  banana, carrot, date, eggplant, to produce 5 x 1GB text files.

2. Create 3 x 2GB volumes, attach to virtual machine.
3. Unwilling to restart the virtual machine, I probed the SCSI host to detect new disks.

```
$ for host in /sys/class/scsi_host/*; do echo "- - -" | sudo tee $host/scan; ls /dev/sd* ; done
```

<pre><code><strong>$ lsblk
</strong>NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda      8:0    0    2G  0 disk
sdb      8:16   0   80G  0 disk
├─sdb1   8:17   0    1M  0 part
├─sdb2   8:18   0  513M  0 part /boot/efi
└─sdb3   8:19   0 79.5G  0 part /
sdc      8:32   0    2G  0 disk
sdd      8:48   0    2G  0 disk
</code></pre>

So we have sda, sdc, and sdd.

Create RAID5 volume using mdadm

```
$ mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sda /dev/sdc /dev/sdd
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: chunk size defaults to 512K
mdadm: size set to 2094080K
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
```

Check block device output prior to creating filesystem

```
$ lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINTS
sda      8:0    0    2G  0 disk
└─md0    9:0    0    4G  0 raid5
sdb      8:16   0   80G  0 disk
├─sdb1   8:17   0    1M  0 part
├─sdb2   8:18   0  513M  0 part  /boot/efi
└─sdb3   8:19   0 79.5G  0 part  /
sdc      8:32   0    2G  0 disk
└─md0    9:0    0    4G  0 raid5
sdd      8:48   0    2G  0 disk
└─md0    9:0    0    4G  0 raid5
sr0     11:0    1 1024M  0 rom

$ fdisk -l /dev/md0
Disk /dev/md0: 3.99 GiB, 4288675840 bytes, 8376320 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 524288 bytes / 1048576 bytes
```

Create ext4 filesystem on /dev/md0

```
$ mkfs.ext4 /dev/md0
mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 1047040 4k blocks and 262144 inodes
Filesystem UUID: 63a60555-ea65-4ed4-83f7-e7e851db8f52
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736

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

Mount volume to /mnt/iblue5 and copy dummy data to it (attempted to copy all 5 x 1GB files, which partially failed due to insufficient space).

```
$ mkdir /mnt/iblue5
$ mount /dev/mapper/data-iblue /mnt/iblue5
$ ls /mnt/iblue5
lost+found
$ cp /home/user/Desktop/*.txt /mnt/iblue5/
$ ls -lah /mnt/iblue5
total 3.9G
drwxr-xr-x  3 root root 4.0K Dec  9 22:39 .
drwxr-xr-x 17 root root 4.0K Dec  9 22:25 ..
-rw-r--r--  1 root root 1.0G Dec  9 22:38 apple.txt
-rw-r--r--  1 root root 1.0G Dec  9 22:38 banana.txt
-rw-r--r--  1 root root 1.0G Dec  9 22:39 carrot.txt
-rw-r--r--  1 root root 858M Dec  9 22:39 date.txt
-rw-r--r--  1 root root    0 Dec  9 22:39 eggplant.txt
drwx------  2 root root  16K Dec  9 22:37 lost+found
```

Unmount /dev/md0

```
$ umount /dev/md0
$ ls /mnt/iblue5
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.iblue.team/general-notes-1/disk-images-for-various-filesystems-and-configurations/ext4-with-lvm-and-raid5-3-disks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
