Disks
Harddisks
1. Firmware 2. ATA, SCSI Driver 3. Physical Block Devices 4. MBR, UEFI GPT Partitions 5. LVM2 Physcical Volume (disk or partition) 7. Volume Group, spanning physical volumes 8. Logical Volumes 9. Device Mapper 10.Filesystem
Harddisk
ls -al /dev/disk/by* blkid
/dev/xvda2: UUID="2ab116ed-fdae-4ee6-aafd-f2febf9a4a96" TYPE="ext4" PARTUUID="3278fa68-67cf-476f-88e1-fa858160c1c5" /dev/xvda3: UUID="9O6sva-rWF6-DO3I-GKIz-iuMg-qrQo-y13KV4" TYPE="LVM2_member" PARTUUID="478fca97-0ca6-4597-aaa6-e709947d1868" /dev/xvdb: UUID="0d331770-95d3-4d15-839a-cce7ddcb6741" TYPE="ext4" /dev/mapper/ubuntu--vg-ubuntu--lv: UUID="597d1543-fe70-4f53-9d82-7fb0c2249ac7" TYPE="ext4"
Disks may have partitions or raw. Partion tables can be the newer GPT UEFI style, or the old MBR masterbootrecord BIOS style, limited to 4 partitions and one can be extended to house more partions, one can be 'active' which windows can boot from.
https://en.wikipedia.org/wiki/GNU_GRUB#/media/File:GNU_GRUB_on_GPT_partitioned_hard_disk_drives.svg
Boot process, grub in the first 512bytes, menu which partition to find the kernel, the initfs kernel modules and where the rootf is.
GPT
fdisk cfdisk cgdisk sfdisk sgdisk
S for scriptable, F for BIOS/MBR layout, G for UEFI/GPT layout sfdisk -l
Temp partition
Format, Journaling
mount
parted partmagic losetup
LVM
https://en.wikipedia.org/wiki/GNU_GRUB#/media/File:GNU_GRUB_on_GPT_partitioned_hard_disk_drives.svg
Physical volume Volume group Logical volume
apk add lvm2 insmod lvm vgchange -ay
pvdisplay vgdisplay lvdisplay
vgchange -ay
lvcreate -L 32G -n ubuntest-hvm /dev/vg0 dd if=/dev/vg0/ubuntu-hvm of=/dev/vg0/ubuntest-hvm lvremove /dev/vg0/truenas-hvm
lvcreate -L 16G -n truenas-hvm /dev/vg0 lvcreate -l 100%FREE -n truenas-pool /dev/vg0
--- Logical volume --- LV Path /dev/vg0/ubuntest-hvm LV Name ubuntest-hvm VG Name vg0 LV UUID OZeTmq-fCJ3-HY87-vLkH-0G2m-bPKo-SCMpwm LV Write Access read/write LV Creation host, time nl, 2020-11-08 12:15:41 +0000 LV Status available # open 0 LV Size 32.00 GiB Current LE 8192 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:4 --- Logical volume --- LV Path /dev/vg0/data LV Name data VG Name vg0 LV UUID 3wIcBP-IM69-It1X-2QGs-Bczs-KIvA-wb54hG LV Write Access read/write LV Creation host, time nl, 2020-12-30 08:14:01 +0000 LV Status available # open 1 LV Size 89.97 GiB Current LE 23033 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:5
apk add device-mapper sfdisk multipath-tools dmsetup ls dmsetup info vg0-data sfdisk -l /dev/mapper/vg0-data kpartx -av /dev/mapper/vg0-data mount /dev/mapper/vg0-data1 /data
=== Extend VG/LV ===
pvcreate /dev/sdb vgextend ubuntu-vg /dev/sdb lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
=== Next level ===
Mounting a nested volume group, which is in a GPT inside a Logical Volume, through the dev mapper using kpartx in multipath-tools
apk add multipath-tools kpartx -av /dev/mapper/vg0-data mount -t ext4 /dev/mapper/vg0-data1 /data sfdisk /dev/vg0/data dmsetup info vg0-data vgchange -ay
mount /dev/dm-4 /data/ mount -t ext4 /dev/dm-4 /data/ mount -t vfat /dev/dm-4 /data/ mount -t vfat /dev/dm-4 /data/ mount -v -t vfat /dev/dm-4 /data/ mount -vvv -t vfat /dev/dm-4 /data/ strace mount -t vfat /dev/dm-4 /data/ strace mount -t vfat /dev/dm-4 /data/ mount -vvv -t vfat /dev/dm-4 /data/
sfdisk /dev/vg0/data file -s /dev/vg0/data file -s /dev/mapper/vg0-data file /dev/vg0/data file /dev/mapper/vg0-data ls -la /dev/vg0/data mount /dev/mapper/vg0-data /data