| 6 | === Basic Discs === |
| 7 | two 1TB disks. Partition layout will be gpt with 3 partitions (BIOS boot 2M, EFI system, Linux LVM). |
| 8 | LVM will be RAID1. |
| 9 | Disks are sdd and sde |
| 10 | |
| 11 | ==== Partitioning: ==== |
| 12 | {{{ |
| 13 | fdisk /dev/sdd |
| 14 | g |
| 15 | n default +2M |
| 16 | t 1 4 |
| 17 | n default +128M |
| 18 | t 2 1 |
| 19 | n default default |
| 20 | t 3 30 |
| 21 | w |
| 22 | p |
| 23 | }}} |
| 24 | Result: |
| 25 | {{{ |
| 26 | Festplatte /dev/sdd: 931,51 GiB, 1000204886016 Bytes, 1953525168 Sektoren |
| 27 | Festplattenmodell: Samsung SSD 870 |
| 28 | Einheiten: Sektoren von 1 * 512 = 512 Bytes |
| 29 | Sektorgröße (logisch/physikalisch): 512 Bytes / 512 Bytes |
| 30 | E/A-Größe (minimal/optimal): 512 Bytes / 512 Bytes |
| 31 | Festplattenbezeichnungstyp: gpt |
| 32 | Festplattenbezeichner: EA219CEB-45F9-C34C-8C6B-A3F491EA8B88 |
| 33 | |
| 34 | Gerät Anfang Ende Sektoren Größe Typ |
| 35 | /dev/sdd1 2048 6143 4096 2M BIOS boot |
| 36 | /dev/sdd2 6144 268287 262144 128M EFI-System |
| 37 | /dev/sdd3 268288 1953525134 1953256847 931,4G Linux LVM |
| 38 | }}} |
| 39 | repeat for second disk /dev/sde |
| 40 | |
| 41 | ==== LVM: ==== |
| 42 | ===== Physical volumes ===== |
| 43 | {{{ |
| 44 | pvcreate /dev/sd[de]3 |
| 45 | }}} |
| 46 | Result in **dvdisplay** |
| 47 | {{{ |
| 48 | --- Physical volume --- |
| 49 | PV Name /dev/sdd3 |
| 50 | VG Name vg01 |
| 51 | PV Size <931,39 GiB / not usable 2,69 MiB |
| 52 | Allocatable yes |
| 53 | PE Size 4,00 MiB |
| 54 | Total PE 238434 |
| 55 | Free PE 172897 |
| 56 | Allocated PE 65537 |
| 57 | PV UUID 9KCwX5-KuDX-de30-J0ke-9822-ljkX-wj3jKr |
| 58 | |
| 59 | --- Physical volume --- |
| 60 | PV Name /dev/sde3 |
| 61 | VG Name vg01 |
| 62 | PV Size <931,39 GiB / not usable 2,69 MiB |
| 63 | Allocatable yes |
| 64 | PE Size 4,00 MiB |
| 65 | Total PE 238434 |
| 66 | Free PE 172897 |
| 67 | Allocated PE 65537 |
| 68 | PV UUID N4TuOc-Dq6A-ZwVW-61t7-gfME-pSFu-Q9Iwty |
| 69 | }}} |
| 70 | ===== Volume group ===== |
| 71 | {{{ |
| 72 | vgcreate vg01 /dev/sd[de]3 |
| 73 | }}} |
| 74 | Result in **vgdisplay** |
| 75 | {{{ |
| 76 | --- Volume group --- |
| 77 | VG Name vg01 |
| 78 | System ID |
| 79 | Format lvm2 |
| 80 | Metadata Areas 2 |
| 81 | Metadata Sequence No 4 |
| 82 | VG Access read/write |
| 83 | VG Status resizable |
| 84 | MAX LV 0 |
| 85 | Cur LV 1 |
| 86 | Open LV 1 |
| 87 | Max PV 0 |
| 88 | Cur PV 2 |
| 89 | Act PV 2 |
| 90 | VG Size <1,82 TiB |
| 91 | PE Size 4,00 MiB |
| 92 | Total PE 476868 |
| 93 | Alloc PE / Size 131074 / <512,01 GiB |
| 94 | Free PE / Size 345794 / <1,32 TiB |
| 95 | VG UUID i1M7O9-dbOQ-azV4-ajmF-utwq-cKaj-RhBROV |
| 96 | }}} |
| 97 | ===== Logical Volumes ===== |
| 98 | ====== for root ====== |
| 99 | {{{ |
| 100 | lvcreate --mirrors 1 --type raid1 -L 256G -n root vg01 |
| 101 | }}} |
| 102 | Result in **lvdisplay** |
| 103 | {{{ |
| 104 | --- Logical volume --- |
| 105 | LV Path /dev/vg01/root |
| 106 | LV Name root |
| 107 | VG Name vg01 |
| 108 | LV UUID N95R5k-dFV6-VecO-j2yQ-nQ12-xjwC-eyjnZ9 |
| 109 | LV Write Access read/write |
| 110 | LV Creation host, time snailix, 2021-11-11 23:58:06 +0100 |
| 111 | LV Status available |
| 112 | # open 1 |
| 113 | LV Size 256,00 GiB |
| 114 | Current LE 65536 |
| 115 | Mirrored volumes 2 |
| 116 | Segments 1 |
| 117 | Allocation inherit |
| 118 | Read ahead sectors auto |
| 119 | - currently set to 256 |
| 120 | Block device 252:4 |
| 121 | }}} |
| 122 | |
| 123 | === block ids === |
| 124 | ==== root ==== |
| 125 | {{{ |
| 126 | blkid | grep vg01-root |
| 127 | }}} |
| 128 | {{{ |
| 129 | /dev/mapper/vg01-root_rimage_0: UUID="06a2c8e7-dc77-49db-8e72-c7d0fa9ebe77" BLOCK_SIZE="4096" TYPE="ext4" |
| 130 | /dev/mapper/vg01-root: UUID="06a2c8e7-dc77-49db-8e72-c7d0fa9ebe77" BLOCK_SIZE="4096" TYPE="ext4" |
| 131 | /dev/mapper/vg01-root_rimage_1: UUID="06a2c8e7-dc77-49db-8e72-c7d0fa9ebe77" BLOCK_SIZE="4096" TYPE="ext4" |
| 132 | }}} |
| 133 | ==== boot ==== |
| 134 | {{{ |
| 135 | blkid | grep sdd2 |
| 136 | }}} |
| 137 | {{{ |
| 138 | /dev/sdd2: UUID="bfb2c0c7-e7bf-44d3-b8c9-1cd60ace50a4" BLOCK_SIZE="1024" TYPE="ext2" PARTUUID="e7666b15-77f8-2942-806b-6f5a198fa496" |
| 139 | }}} |
| 140 | |
| 141 | === copy root from old installation === |
| 142 | Boot from USB and mount the old and the new root. mount using UUID to be sure to mount the right devices. |
| 143 | {{{ |
| 144 | mkdir /mnt/root-old |
| 145 | mkdir /mnt/root-new |
| 146 | mount UUID="fcafeec5-6c23-4edd-acf3-dfab41ae7776" /mnt/root-old |
| 147 | mount UUID="06a2c8e7-dc77-49db-8e72-c7d0fa9ebe77" /mnt/root-new |
| 148 | rsync -aHv --progress --delete /mnt/root-old/ /mnt/root-new/ |
| 149 | |
| 150 | === fstab === |
| 151 | edit fstab to reflect the UUIDs |
| 152 | {{{ |
| 153 | UUID="bfb2c0c7-e7bf-44d3-b8c9-1cd60ace50a4" /boot ext2 noauto,noatime 1 2 |
| 154 | UUID="06a2c8e7-dc77-49db-8e72-c7d0fa9ebe77" / ext4 noatime 0 1 |
| 155 | ... |
| 156 | }}} |
| 157 | |
| 158 | === initramfs === |
| 159 | mount sdd2 on boot (using UUID to be sure that it is the correct one) |
| 160 | {{{ |
| 161 | umount /boot |
| 162 | mount UUID="bfb2c0c7-e7bf-44d3-b8c9-1cd60ace50a4" /boot |
| 163 | }}} |
| 164 | generate initrd (wiht lvm busybox luks support) |
| 165 | {{{ |
| 166 | genkernel --lvm --busybox --luks --install initramfs |
| 167 | }}} |
| 168 | |
8 | | |
9 | | {{{ |
10 | | GRUB_CMDLINE_LINUX="dolvm rootfstype=ext4 init=/usr/lib/systemd/systemd" |
11 | | }}} |
12 | | |
| 178 | {{{ |
| 179 | GRUB_CMDLINE_LINUX="dolvm root=UUID=06a2c8e7-dc77-49db-8e72-c7d0fa9ebe77 rootfstype=ext4 vga=0x31B init=/usr/lib/systemd/systemd" |
| 180 | }}} |
| 181 | ==== Config ==== |
| 182 | {{{ |
| 183 | grub-mkconfig -o /boot/grub/grub.cfg |
| 184 | }}} |
| 185 | **Remark:** for me during runtime the disks are sdd (hd3) and sde (hd4) but during boot they are sda (hd0) and sdb (hd1) because the devices on the hardware controller are moved to sda, ... |
| 186 | Therfore I have to change the hd-entries in /boot/grub/grub.cfg using |
| 187 | {{{ |
| 188 | sed -i 's/hd3/hd0/g' /boot/grub/grub.cfg |
| 189 | }}} |
| 190 | ==== Sync boot over discs ==== |
| 191 | to be able to boot from another disk (I have 3 disk that have a grub2 installation) I use the following script. (create mountpoints in /mnt accordingly). And this relies on a correct entry for boot in fstab) |
| 192 | {{{ |
| 193 | echo 'mount boot' |
| 194 | mount /boot |
| 195 | echo 'mount sda1' |
| 196 | mount /dev/sda1 /mnt/sda1 |
| 197 | echo 'mount sde2' |
| 198 | mount /dev/sde2 /mnt/sde2 |
| 199 | echo 'sync to sda1' |
| 200 | rsync -aHv --progress --delete /boot/ /mnt/sda1/ |
| 201 | echo 'sync to sde2' |
| 202 | rsync -aHv --progress --delete /boot/ /mnt/sde2/ |
| 203 | echo 'umount sde2' |
| 204 | umount /mnt/sde2 |
| 205 | echo 'umount sda1' |
| 206 | umount /mnt/sda1 |
| 207 | echo 'umount boot' |
| 208 | umount boot |
| 209 | echo 'done' |
| 210 | }}} |