| 28 | | |
| | 28 | == Technical Details == |
| | 29 | |
| | 30 | Following are the steps for adding a solid state drive to both a host and a guest |
| | 31 | |
| | 32 | === Adding solid state drives to a host === |
| | 33 | |
| | 34 | First, order the disks (see [ticket:11870#comment:7 previous SSDs we have purchased] and order the cables and cages needed to install them (see [ticket:11870#comment:10 previous cables we have ordered]). |
| | 35 | |
| | 36 | Once installed, the should show up via `cat /proc/partitions` as something like /dev/sda and /dev/sdb. |
| | 37 | |
| | 38 | Next, modify the physical servers .pp file in puppet, changing the call to m_physical server to be: |
| | 39 | |
| | 40 | {{{ |
| | 41 | class { "mayfirst::m_physical": |
| | 42 | ssd => true |
| | 43 | } |
| | 44 | }}} |
| | 45 | |
| | 46 | Once you push, it should change /etc/lvm/lvm.conf to have: `issue_discards = 1` |
| | 47 | |
| | 48 | Next, create a single partition on each device, e.g.: |
| | 49 | |
| | 50 | {{{ |
| | 51 | 0 wiwa:/etc/lvm# parted /dev/sdb |
| | 52 | GNU Parted 3.2 |
| | 53 | Using /dev/sdb |
| | 54 | Welcome to GNU Parted! Type 'help' to view a list of commands. |
| | 55 | (parted) mklabel gpt |
| | 56 | (parted) unit s mkpart main 8192 -196608 |
| | 57 | (parted) p |
| | 58 | Model: ATA SAMSUNG MZ7KM480 (scsi) |
| | 59 | Disk /dev/sdb: 937703088s |
| | 60 | Sector size (logical/physical): 512B/512B |
| | 61 | Partition Table: gpt |
| | 62 | Disk Flags: |
| | 63 | |
| | 64 | Number Start End Size File system Name Flags |
| | 65 | 1 8192s 937506480s 937498289s main |
| | 66 | |
| | 67 | (parted) |
| | 68 | }}} |
| | 69 | |
| | 70 | Then a RAID 1 array: |
| | 71 | |
| | 72 | {{{ |
| | 73 | mdadm --create --raid-devices=2 --level=1 --metadata=1.0 --verbose /dev/md2 /dev/sda1 /dev/sdb1 |
| | 74 | }}} |
| | 75 | |
| | 76 | Scan your RAID devices: |
| | 77 | |
| | 78 | {{{ |
| | 79 | mdadm --examine --scan |
| | 80 | }}} |
| | 81 | |
| | 82 | And based on the output, edit /etc/mdadm/mdam.conf to add a line for your new RAID (something like: `ARRAY /dev/md/2 metadata=1.0 UUID=70345fc6:661e67ce:715261cf:84112f10 name=wiwa:2` |
| | 83 | |
| | 84 | Now, setup encryption and be sure to enable `--allow-discards`: |
| | 85 | |
| | 86 | {{{ |
| | 87 | 0 wiwa:/etc/lvm# cryptsetup luksFormat /dev/md2 |
| | 88 | |
| | 89 | WARNING! |
| | 90 | ======== |
| | 91 | This will overwrite data on /dev/md2 irrevocably. |
| | 92 | |
| | 93 | Are you sure? (Type uppercase yes): YES |
| | 94 | Enter passphrase: |
| | 95 | Verify passphrase: |
| | 96 | 0 wiwa:/etc/lvm# cryptsetup --allow-discards luksOpen /dev/md2 md2_crypt |
| | 97 | Enter passphrase for /dev/md2: |
| | 98 | 0 wiwa:/etc/lvm# blkid /dev/md2 |
| | 99 | /dev/md2: UUID="b360ef4f-84ea-457c-8f86-a7f94b1f9277" TYPE="crypto_LUKS" |
| | 100 | 0 wiwa:/etc/lvm# echo md2_crypt UUID=b360ef4f-84ea-457c-8f86-a7f94b1f9277 none luks,discard >> /etc/crypttab |
| | 101 | 0 wiwa:/etc/lvm# cat /etc/crypttab |
| | 102 | # <target name> <source device> <key file> <options> |
| | 103 | md1_crypt UUID=ae7a55a5-cc91-4064-8e5f-06eb293188a2 none luks |
| | 104 | md2_crypt UUID=b360ef4f-84ea-457c-8f86-a7f94b1f9277 none luks,discard |
| | 105 | 0 wiwa:/etc/lvm# pvcreate /dev/mapper/md2_crypt |
| | 106 | Physical volume "/dev/mapper/md2_crypt" successfully created |
| | 107 | 0 wiwa:/etc/lvm# vgcreate vg_wiwa1 /dev/mapper/md2_crypt |
| | 108 | Volume group "vg_wiwa1" successfully created |
| | 109 | 0 wiwa:/etc/lvm# |
| | 110 | }}} |
| | 111 | |
| | 112 | === Adding solid state drives to a guest === |
| | 113 | |
| | 114 | On the host, create a logical volume for your given host, e.g.: |
| | 115 | |
| | 116 | {{{ |
| | 117 | 0 wiwa:/etc/lvm# lvcreate --size 10GB --name jacobs vg_wiwa1 |
| | 118 | Logical volume "jacobs" created |
| | 119 | 0 wiwa:/etc/lvm# |
| | 120 | }}} |
| | 121 | |
| | 122 | Change the group ownership to match the user the guests runs as: |
| | 123 | |
| | 124 | {{{ |
| | 125 | 1 wiwa:/etc/sv/kvm/jacobs# ls -l /dev/mapper/vg_wiwa1-jacobs |
| | 126 | lrwxrwxrwx 1 root root 8 Sep 23 15:16 /dev/mapper/vg_wiwa1-jacobs -> ../dm-28 |
| | 127 | 0 wiwa:/etc/sv/kvm/jacobs# chgrp jacobs /dev/dm-28 |
| | 128 | 0 wiwa:/etc/sv/kvm/jacobs# |
| | 129 | }}} |
| | 130 | |
| | 131 | Reboot the guest. |
| | 132 | |
| | 133 | From the guest... |
| | 134 | |
| | 135 | Look for the new block device (/dev/sdb below): |
| | 136 | |
| | 137 | {{{ |
| | 138 | 0 jacobs:~# cat /proc/partitions |
| | 139 | major minor #blocks name |
| | 140 | |
| | 141 | 8 16 10485760 sdb |
| | 142 | 8 0 524288000 sda |
| | 143 | 8 1 248832 sda1 |
| | 144 | 8 2 524037120 sda2 |
| | 145 | 254 0 3997696 dm-0 |
| | 146 | 254 1 499712 dm-1 |
| | 147 | 254 2 999424 dm-2 |
| | 148 | 254 3 4997120 dm-3 |
| | 149 | 254 4 4997120 dm-4 |
| | 150 | 254 5 20971520 dm-5 |
| | 151 | 0 jacobs:~# |
| | 152 | }}} |
| | 153 | |
| | 154 | Create a single partition: |
| | 155 | |
| | 156 | {{{ |
| | 157 | 0 jacobs:~# parted /dev/sdb |
| | 158 | GNU Parted 3.2 |
| | 159 | Using /dev/sdb |
| | 160 | Welcome to GNU Parted! Type 'help' to view a list of commands. |
| | 161 | (parted) mklabel gpt |
| | 162 | (parted) unit s mkpart main 8192 -196608 |
| | 163 | (parted) p |
| | 164 | Model: QEMU QEMU HARDDISK (scsi) |
| | 165 | Disk /dev/sdb: 20971520s |
| | 166 | Sector size (logical/physical): 512B/512B |
| | 167 | Partition Table: gpt |
| | 168 | Disk Flags: |
| | 169 | |
| | 170 | Number Start End Size File system Name Flags |
| | 171 | 1 8192s 20774912s 20766721s main |
| | 172 | |
| | 173 | (parted) quit |
| | 174 | Information: You may need to update /etc/fstab. |
| | 175 | |
| | 176 | 0 jacobs:~# |
| | 177 | }}} |
| | 178 | |
| | 179 | Create a filesystem: |
| | 180 | |
| | 181 | {{{ |
| | 182 | mkfs -t ext4 /dev/sdb1 |
| | 183 | }}} |
| | 184 | |
| | 185 | ==== Replacing MySQL partition ==== |
| | 186 | |
| | 187 | If you are using this partition to replace MySQL... |
| | 188 | |
| | 189 | Stop mysql: |
| | 190 | |
| | 191 | {{{ |
| | 192 | systemctl stop mysql |
| | 193 | }}} |
| | 194 | |
| | 195 | Unmount /var/lib/mysql: |
| | 196 | |
| | 197 | {{{ |
| | 198 | umount /var/lib/mysql |
| | 199 | }}} |
| | 200 | |
| | 201 | Edit /etc/fstab, change the line for mounting /var/lib/mysql to match /dev/sdb1 instead of the existing logical volume. |
| | 202 | |
| | 203 | Mount the old logical volume on /mnt: |
| | 204 | |
| | 205 | {{{ |
| | 206 | mount /dev/mapper/vg_jacobs0-var+lib+mysql /mnt |
| | 207 | }}} |
| | 208 | |
| | 209 | Mount the new partition: |
| | 210 | |
| | 211 | {{{ |
| | 212 | mount /var/lib/mysql |
| | 213 | }}} |
| | 214 | |
| | 215 | Move the data: |
| | 216 | |
| | 217 | {{{ |
| | 218 | mv /mnt/* /var/lib/mysql |
| | 219 | }}} |
| | 220 | |
| | 221 | Umount /mnt and remove the logical volume: |
| | 222 | |
| | 223 | {{{ |
| | 224 | umount /mnt |
| | 225 | lvremove /dev/mapper/vg_jacobs0-var+lib+mysql |
| | 226 | }}} |
| | 227 | |
| | 228 | Retart mysql: |
| | 229 | |
| | 230 | {{{ |
| | 231 | systemctl start mysql |
| | 232 | }}} |