[[Kategorie:Infrastruktur]]

== Hardware Info ==
* CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 5000+
* MEM: 4 GB
* HDD: 1x1TB / 1x2TB

== Software Info ==
Debian (x64) jessie/sid - Linux zaubert 3.13-1-amd64 #1 SMP Debian 3.13.10-1 (2014-04-15) x86_64 GNU/Linux

== Verwendungszweck ==
* mit BTRFS, iSCSI & Co. spielen

== Freebert iSCSI Target ==

<source lang=bash>
vi /etc/ctl.conf

target iqn.2014-01.de.c3d2.hq:zaubert {
      auth-group no-authentication
      portal-group c3d2
      alias "ZauBert BTRFS"

      lun 0 {
            path /iscsi/target2-0
            size 25G
      }
      lun 1 {
            path /iscsi/target2-1
            size 25G
      }
      lun 2 {
            path /iscsi/target2-2
            size 25G
      }
      lun 3 {
            path /iscsi/target2-3
            size 25G
      }
}
</source>

== Installation ==
PXE Netboot über Freebert DHCP/TFTP Bootimage (debian jessie/sid)

* sd(a/b)1 = 2 GB (SoftRaid1) Mirror für /boot (ext4)
* sd(a/b)2 = 2 GB SWAP
* sdc1 = iscsi BTRFS für / (root)

Setup bis zum Abschluss durchführen, nun muss noch kurz etwas manuell nachgebessert werden:

Derzeit setzt jessie/sid (kernel 3.13-1) das iSCSI Portal falsch! (fehlerhaftes booten führt zur initramfs/busybox)

{{NiftyDiv|
Farbe=#f4b9c4|
Inhalt=
'''ISCSI_TARGET_GROUP="-1"'''
}}

=== initramfs ===

NICHT abschließen, sondern zurück ins Menü und Shell (BusyBox) auswählen

<source lang=bash>
mount -t sysfs sys /target/sys
mount -o bind /dev /target/dev
mount -t proc none /target/proc
</source>
<source lang=bash>
chroot /target /bin/bash
</source>
<source lang=bash>
vi /etc/iscsi/iscsi.initramfs
</source>
<pre>
ISCSI_TARGET_GROUP="c3d2"
</pre>
<source lang=bash>
update-initramfs -u -k all
update-initramfs -u -k all -v | grep iscsi
</source>
<source lang=bash>
reboot
</source>

== Festplattenschemata ==

<source lang=bash>
df -H
Dateisystem    Größe Benutzt Verf. Verw% Eingehängt auf
/dev/sdc1        27G    1,6G   24G    7% /
udev             11M       0   11M    0% /dev
tmpfs           416M    357k  416M    1% /run
tmpfs           5,3M       0  5,3M    0% /run/lock
tmpfs           1,7G       0  1,7G    0% /run/shm
/dev/md0        2,0G     31M  1,8G    2% /boot

cat /proc/mdstat
Personalities : [raid1] 
md0 : active raid1 sda1[0] sdb1[1]
      1950720 blocks super 1.2 [2/2] [UU]
      
unused devices: <none>

lsblk
NAME    MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda       8:0    0 931,5G  0 disk  
├─sda1    8:1    0   1,9G  0 part  
│ └─md0   9:0    0   1,9G  0 raid1 /boot
└─sda2    8:2    0   1,9G  0 part  [SWAP]
sdb       8:16   0   1,8T  0 disk  
├─sdb1    8:17   0   1,9G  0 part  
│ └─md0   9:0    0   1,9G  0 raid1 /boot
└─sdb2    8:18   0   1,9G  0 part  [SWAP]
sdc       8:32   0    25G  0 disk  
└─sdc1    8:33   0    25G  0 part  
sdd       8:48   0    25G  0 disk  
sde       8:64   0    25G  0 disk  
sdf       8:80   0    25G  0 disk  
sr0      11:0    1  1024M  0 rom
</source>

<source lang=bash>
dmesg | grep sda
[    1.080771] sd 4:0:0:0: [sda] 1953523055 512-byte logical blocks: (1.00 TB/931 GiB)
[    1.080830] sd 4:0:0:0: [sda] Write Protect is off
[    1.080833] sd 4:0:0:0: [sda] Mode Sense: 00 3a 00 00
[    1.080857] sd 4:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    1.108470]  sda: sda1 sda2
[    1.108775] sd 4:0:0:0: [sda] Attached SCSI disk
[   10.350728] md: bind<sda1>
[   10.353799]  disk 0, wo:0, o:1, dev:sda1
[   16.314533] Adding 1952764k swap on /dev/sda2.  Priority:-1 extents:1 across:1952764k
</source>

<source lang=bash>
dmesg | grep sdb
[    1.080762] sd 5:0:0:0: [sdb] 3907029168 512-byte logical blocks: (2.00 TB/1.81 TiB)
[    1.080766] sd 5:0:0:0: [sdb] 4096-byte physical blocks
[    1.080823] sd 5:0:0:0: [sdb] Write Protect is off
[    1.080827] sd 5:0:0:0: [sdb] Mode Sense: 00 3a 00 00
[    1.080851] sd 5:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    1.105590]  sdb: sdb1 sdb2
[    1.105925] sd 5:0:0:0: [sdb] Attached SCSI disk
[   10.350559] md: bind<sdb1>
[   10.353801]  disk 1, wo:0, o:1, dev:sdb1
[   16.323616] Adding 1952764k swap on /dev/sdb2.  Priority:-2 extents:1 across:1952764k
</source>

<source lang=bash>
dmesg | grep sdc
[    9.292166] sd 6:0:0:0: [sdc] 52428800 512-byte logical blocks: (26.8 GB/25.0 GiB)
[    9.293177] sd 6:0:0:0: [sdc] Write Protect is off
[    9.293182] sd 6:0:0:0: [sdc] Mode Sense: 57 00 00 08
[    9.294860] sd 6:0:0:0: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    9.531531]  sdc: sdc1
[    9.534631] sd 6:0:0:0: [sdc] Attached SCSI disk
[   10.875018] btrfs: device label system devid 1 transid 139 /dev/sdc1
[   13.448486] btrfs: device label system devid 1 transid 139 /dev/sdc1
[   13.511497] btrfs: device label system devid 1 transid 139 /dev/sdc1
</source>

<source lang=bash>
parted -l
Model: ATA WDC WD1001FALS-0 (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system     Flags
 1      1049kB  2000MB  1999MB  primary  ext4            boot, raid
 2      2000MB  3999MB  2000MB  primary  linux-swap(v1)


Model: ATA WDC WD20EARX-00P (scsi)
Disk /dev/sdb: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos

Number  Start   End     Size    Type     File system     Flags
 1      1049kB  2000MB  1999MB  primary  ntfs            boot, raid
 2      2000MB  3999MB  2000MB  primary  linux-swap(v1)


Model: FREEBSD CTLDISK (scsi)
Disk /dev/sdc: 26,8GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  26,8GB  26,8GB  primary  btrfs


Model: FREEBSD CTLDISK (scsi)
Disk /dev/sdd: 26,8GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End  Size  Type  File system  Flags


Model: FREEBSD CTLDISK (scsi)
Disk /dev/sde: 26,8GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End  Size  Type  File system  Flags


Model: FREEBSD CTLDISK (scsi)
Disk /dev/sdf: 26,8GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End  Size  Type  File system  Flags


Model: Linux Software RAID Array (md)
Disk /dev/md0: 1998MB
Sector size (logical/physical): 512B/4096B
Partition Table: loop

Number  Start  End     Size    File system  Flags
 1      0,00B  1998MB  1998MB  ext4
</source>

<source lang=bash>
btrfs filesystem show /
Label: 'system'  uuid: a231f9ab-8a92-4ab5-b9b2-7365b637fdbe
        Total devices 1 FS bytes used 1.36GiB
        devid    1 size 25.00GiB used 4.04GiB path /dev/sdc1

Btrfs v3.14.1
</source>

== Kernel mit iSCSI ==

<source lang=bash>
[    8.779815] Loading iSCSI transport class v2.0-870.
[    8.781499] iscsi: registered transport (tcp)
[    9.037268] scsi6 : iSCSI Initiator over TCP/IP
[    9.290955] scsi 6:0:0:0: Direct-Access     FREEBSD  CTLDISK          0001 PQ: 0 ANSI: 5
[    9.291160] sd 6:0:0:0: Attached scsi generic sg3 type 0
[    9.291897] scsi 6:0:0:1: Direct-Access     FREEBSD  CTLDISK          0001 PQ: 0 ANSI: 5
[    9.292080] sd 6:0:0:1: Attached scsi generic sg4 type 0
[    9.292166] sd 6:0:0:0: [sdc] 52428800 512-byte logical blocks: (26.8 GB/25.0 GiB)
[    9.292618] scsi 6:0:0:2: Direct-Access     FREEBSD  CTLDISK          0001 PQ: 0 ANSI: 5
[    9.292737] sd 6:0:0:1: [sdd] 52428800 512-byte logical blocks: (26.8 GB/25.0 GiB)
[    9.292830] sd 6:0:0:2: Attached scsi generic sg5 type 0
[    9.293177] sd 6:0:0:0: [sdc] Write Protect is off
[    9.293182] sd 6:0:0:0: [sdc] Mode Sense: 57 00 00 08
[    9.293214] scsi 6:0:0:3: Direct-Access     FREEBSD  CTLDISK          0001 PQ: 0 ANSI: 5
[    9.293380] sd 6:0:0:3: Attached scsi generic sg6 type 0
[    9.294354] sd 6:0:0:2: [sde] 52428800 512-byte logical blocks: (26.8 GB/25.0 GiB)
[    9.294838] sd 6:0:0:3: [sdf] 52428800 512-byte logical blocks: (26.8 GB/25.0 GiB)
[    9.294860] sd 6:0:0:0: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    9.294982] sd 6:0:0:1: [sdd] Write Protect is off
[    9.294985] sd 6:0:0:1: [sdd] Mode Sense: 57 00 00 08
[    9.515170] sd 6:0:0:2: [sde] Write Protect is off
[    9.515178] sd 6:0:0:2: [sde] Mode Sense: 57 00 00 08
[    9.515345] sd 6:0:0:3: [sdf] Write Protect is off
[    9.515348] sd 6:0:0:3: [sdf] Mode Sense: 57 00 00 08
[    9.515364] sd 6:0:0:1: [sdd] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    9.515874] sd 6:0:0:2: [sde] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    9.515882] sd 6:0:0:3: [sdf] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    9.531531]  sdc: sdc1
[    9.534631] sd 6:0:0:0: [sdc] Attached SCSI disk
[    9.541120]  sde:
[    9.541149]  sdd:
[    9.541255]  sdf:
[    9.544132] sd 6:0:0:1: [sdd] Attached SCSI disk
[    9.544788] sd 6:0:0:3: [sdf] Attached SCSI disk
[    9.544926] sd 6:0:0:2: [sde] Attached SCSI disk
</source>

== BTRFS Platten hinzufügen ==

Der Wahnsinn beginnt damit, einfach eine nackte Platte ohne Partitionstabelle hinzufügen zu können :D

{{NiftyDiv|
Farbe=#f4b9c4|
Inhalt=
<source lang=bash>
btrfs device add /dev/sdd /
/dev/sdd appears to contain a partition table (dos).
Use the -f option to force overwrite.

btrfs device add -f /dev/sdd /
Performing full device TRIM (25.00GiB) ...

btrfs filesystem show /
Label: 'system'  uuid: a231f9ab-8a92-4ab5-b9b2-7365b637fdbe
        Total devices 2 FS bytes used 1.37GiB
        devid    1 size 25.00GiB used 4.04GiB path /dev/sdc1
        devid    2 size 25.00GiB used 0.00 path /dev/sdd

Btrfs v3.14.1
</source>
}}

der übliche Weg ... 3 Festplatten, mit Partitionstabelle, hinzufügen und Raid5 erzeugen

<source lang=bash>
fdisk /dev/sdd
fdisk /dev/sde
fdisk /dev/sdf
</source>


<source lang=bash>
sdc       8:32   0    25G  0 disk  
└─sdc1    8:33   0    25G  0 part  
sdd       8:48   0    25G  0 disk  
└─sdd1    8:49   0    25G  0 part  
sde       8:64   0    25G  0 disk  
└─sde1    8:65   0    25G  0 part  
sdf       8:80   0    25G  0 disk  
└─sdf1    8:81   0    25G  0 part
</source>


<source lang=bash>
btrfs device add /dev/sdd1 /
btrfs device add /dev/sde1 /
btrfs device add /dev/sdf1 /
</source>


<source lang=bash>
btrfs filesystem show /
Label: 'system'  uuid: a231f9ab-8a92-4ab5-b9b2-7365b637fdbe
        Total devices 4 FS bytes used 1.37GiB
        devid    1 size 25.00GiB used 4.04GiB path /dev/sdc1
        devid    2 size 25.00GiB used 0.00 path /dev/sdd1
        devid    3 size 25.00GiB used 0.00 path /dev/sde1
        devid    4 size 25.00GiB used 0.00 path /dev/sdf1

Btrfs v3.14.1
</source>

== BTRFS RAID 5 erstellen ==

<source lang=bash>
btrfs balance start -dconvert=raid5 -mconvert=raid5 /

Done, had to relocate 7 out of 7 chunks
</source>


<source lang=bash>
btrfs balance status /
No balance found on '/'

btrfs filesystem show /
Label: 'system'  uuid: a231f9ab-8a92-4ab5-b9b2-7365b637fdbe
        Total devices 4 FS bytes used 1.37GiB
        devid    1 size 25.00GiB used 3.38GiB path /dev/sdc1
        devid    2 size 25.00GiB used 3.38GiB path /dev/sdd1
        devid    3 size 25.00GiB used 3.38GiB path /dev/sde1
        devid    4 size 25.00GiB used 3.38GiB path /dev/sdf1

Btrfs v3.14.1
</source>

== BTRFS Mount Optionen ==

<source lang=bash>
vi /etc/fstab

UUID=xxx   /   btrfs   defaults,autodefrag,compress=zlib   0   1
</source>

== Log ==
* 02.05.2014 - fährt nicht sauber runter
* 02.05.2014 - einfaches Basis Setup
