Changes between Version 1 and Version 2 of Snailix


Ignore:
Timestamp:
11/13/21 11:17:42 (3 years ago)
Author:
admin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Snailix

    v1 v2  
    44Detail see [https://wiki.gentoo.org/wiki/LVM]
    55
     6=== Basic Discs ===
     7two 1TB disks. Partition layout will be gpt with 3 partitions (BIOS boot 2M, EFI system, Linux LVM).
     8LVM will be RAID1.
     9Disks are sdd and sde
     10
     11==== Partitioning: ====
     12{{{
     13fdisk /dev/sdd
     14g
     15n default +2M
     16t 1 4
     17n default +128M
     18t 2 1
     19n default default
     20t 3 30
     21w
     22p
     23}}}
     24Result:
     25{{{
     26Festplatte /dev/sdd: 931,51 GiB, 1000204886016 Bytes, 1953525168 Sektoren
     27Festplattenmodell: Samsung SSD 870
     28Einheiten: Sektoren von 1 * 512 = 512 Bytes
     29Sektorgröße (logisch/physikalisch): 512 Bytes / 512 Bytes
     30E/A-Größe (minimal/optimal): 512 Bytes / 512 Bytes
     31Festplattenbezeichnungstyp: gpt
     32Festplattenbezeichner: EA219CEB-45F9-C34C-8C6B-A3F491EA8B88
     33
     34Gerä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}}}
     39repeat for second disk /dev/sde
     40
     41==== LVM: ====
     42===== Physical volumes =====
     43{{{
     44pvcreate /dev/sd[de]3
     45}}}
     46Result 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{{{
     72vgcreate vg01 /dev/sd[de]3
     73}}}
     74Result 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{{{
     100lvcreate --mirrors 1 --type raid1 -L 256G -n root vg01
     101}}}
     102Result 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{{{
     126blkid | 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{{{
     135blkid | 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 ===
     142Boot from USB and mount the old and the new root. mount using UUID to be sure to mount the right devices.
     143{{{
     144mkdir /mnt/root-old
     145mkdir /mnt/root-new
     146mount UUID="fcafeec5-6c23-4edd-acf3-dfab41ae7776" /mnt/root-old
     147mount UUID="06a2c8e7-dc77-49db-8e72-c7d0fa9ebe77" /mnt/root-new
     148rsync -aHv --progress --delete /mnt/root-old/ /mnt/root-new/
     149
     150=== fstab ===
     151edit fstab to reflect the UUIDs
     152{{{
     153UUID="bfb2c0c7-e7bf-44d3-b8c9-1cd60ace50a4"     /boot           ext2            noauto,noatime          1 2
     154UUID="06a2c8e7-dc77-49db-8e72-c7d0fa9ebe77"     /               ext4            noatime                 0 1
     155...
     156}}}
     157
     158=== initramfs ===
     159mount sdd2 on boot (using UUID to be sure that it is the correct one)
     160{{{
     161umount /boot
     162mount UUID="bfb2c0c7-e7bf-44d3-b8c9-1cd60ace50a4" /boot
     163}}}
     164generate initrd (wiht lvm busybox luks support)
     165{{{
     166genkernel --lvm --busybox --luks --install initramfs
     167}}}
     168
    6169=== grub2 ===
     170Grub2 installation. using gpt layout but no UEFI.
     171==== Install ====
     172{{{
     173grub-install /dev/sdd
     174grub-install /dev/sde
     175}}}
     176==== Default ====
    7177in /etc/default/grub
    8 
    9 {{{
    10 GRUB_CMDLINE_LINUX="dolvm rootfstype=ext4 init=/usr/lib/systemd/systemd"
    11 }}}
    12 
     178{{{
     179GRUB_CMDLINE_LINUX="dolvm root=UUID=06a2c8e7-dc77-49db-8e72-c7d0fa9ebe77 rootfstype=ext4 vga=0x31B init=/usr/lib/systemd/systemd"
     180}}}
     181==== Config ====
     182{{{
     183grub-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, ...
     186Therfore I have to change the hd-entries in /boot/grub/grub.cfg using
     187{{{
     188sed -i 's/hd3/hd0/g' /boot/grub/grub.cfg
     189}}}
     190==== Sync boot over discs ====
     191to 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{{{
     193echo 'mount boot'
     194mount /boot
     195echo 'mount sda1'
     196mount /dev/sda1 /mnt/sda1
     197echo 'mount sde2'
     198mount /dev/sde2 /mnt/sde2
     199echo 'sync to sda1'
     200rsync -aHv --progress --delete /boot/ /mnt/sda1/
     201echo 'sync to sde2'
     202rsync -aHv --progress --delete /boot/ /mnt/sde2/
     203echo 'umount sde2'
     204umount /mnt/sde2
     205echo 'umount sda1'
     206umount /mnt/sda1
     207echo 'umount boot'
     208umount boot
     209echo 'done'
     210}}}