Lenovo Yoga Slim 7x (lenovo-yoga-slim7x)

== Contributors ==
* caleb
== Users owning this device ==
== Installation ==
The most straight forward way to install pmOS to the local nvme disk is to prepare things from windows, then install postmarketOS to a USB stick, boot from it and copy everything over.
Windows prep:
1. Create space for Linux by opening disk management and shrinking the C: partition, no need to create a new partition there yet.
2. Disable bitlocker, search "bitlocker" in start, go to bitlocker settings, turn off the switch and wait for it to finish. this makes mounting the windows drive from Linux later on much easier (this will be necessary to install the firmware for the GPU and DSPs).
3. Configure the EFI boot order to boot Linux. Launch command prompt (not powershell!) as admin and do the following:
$ bcdedit /copy {current} /d "postmarketOS"
# Copy the UUID that was printed (the "{buncha-numbers}" part including the brackets).
$ bcdedit /set "{your-uuid-string}" path \EFI\Boot\bootaa64.efi
# Now make Linux the default (systemd-boot provides a Windows boot entry)
$ bcdedit /displayorder "{your-uuid-string}" "{current}"
Now we can prepare a postmarketOS image. Currently support for this device is still pending so you will need to build your own image or wait for to be merged.
Follow Installation/Using_pmbootstrap, choose postmarketos as the device vendor and trailblazer as the model. GNOME is well tested but KDE Plasma should also work. DE's using X11 are likely to have issues since they aren't well supported by the graphics driver.
Once pmbootstrap init is complete, check out the appropriate feature branch in pmaports:
$ cd $(pmbootstrap config work)/cache_git/pmaports
$ git checkout caleb/slim7x-trailblazer
# If you want systemd, then do "pmbootstrap config systemd always" and then "git rebase -i origin/master_staging_systemd", drop any commits that aren't related to the slim7x
Now we can build our image, insert your USB drive and check dmesg -w to see what it shows up as (look for /dev/sdX where X is some letter and replace it below). Don't add --fde yet since we're just booting from a USB, just be patient and it will become responsive again.
$ pmbootstrap install --disk /dev/sdX --add gptfdisk,unl0kr,mount
Now you can reboot the laptop, spam F2 to get into the EFI settings and make the following changes:
EFI Config Option	Value
Secure Boot 	Disabled
Press F10 to exit and save changes, then press F12 when the logo appears on screen to get to the boot menu and choose your USB stick (NOT the Linux entry we created earlier!).
All going well, you should now be booted into postmarketOS! Note that you won't have GPU acceleration yet, and there may be stutters or UI hangs for ~30 seconds after login due to bandwidth limitations with the USB (at least noticed in GNOME).
Now it's time to set up the rootfs and copy our installation over.
First, we'll create our new root partition using gdisk
$ sudo gdisk /dev/nvme0n1
# We expect the table to look something like this:
Command (? for help): p
...
Number Start (sector) End (sector) Size Code Name
 1 2048 534527 260.0 MiB EF00 EFI system partition
 2 534528 796671 128.0 MiB 0C01 Microsoft reserved ...
 3 796672 348723199 165.9 GiB 0700 Basic data partition
 4 1996312576 2000408575 2.0 GiB 2700 Basic data partition
# Create a new partition to fill the remaining space on the disk
Command (? for help): n
# Hit enter until you're prompted for the partition type code, you should choose 8305 here (Linux ARM64 root), the defaults are fine for the rest.
# Then write out and quit
Command (? for help): w
q
Now format and mount the partition, it is MOST LIKELY /dev/nvme0n1p5 but do check first
$ sudo su
# This prints the partitions and associated data, look for the one with PARTLABEL="Linux ARM64 Root (/)" (or whatever you picked if you did something different). Use this instead of nvme0n1p5 if it's different!
$ blkid
# Format the partition. If you want to do full disk encryption now is the time to check the arch wiki pages about cryptsetup, the rest of this guide works fine with /dev/mapper/root
$ mkfs.ext4 /dev/nvme0n1p5
# Mount it
$ mount /dev/nvme0n1p5 -t ext4 /mnt
# Create a mountboot for the EFI system partition
$ mkdir /mnt/boot
$ mount /dev/nvme0n1p1 /mnt/boot
# Create the other mountpoints we'll need later
$ mkdir -p /mnt/tmp /mnt/proc /mnt/dev /mnt/sys /mnt/run /mnt/mnt /mnt/media
# Now copy over the (live!) rootfs we're booted from. This is maybe unwise but honestly fine as long as you don't do anything else while it runs.
$ cp -a bin etc home lib opt root sbin srv tmp usr var /mnt/
# Copy over the bits for the EFI system partition. We replace the windows bootaa64.efi here but that's fine since windows runs bootmgw.efi directly
$ cp -a /boot/efi/boot/bootaa64.efi /mnt/boot/EFI/Boot/
$ cp -a /boot/efi/systemd /mnt/boot/EFI/
$ cp -a /boot/dtbs /boot/initramfs /boot/linux.efi /boot/loader /mnt/boot
# Finally, we need to update references to the boot/root partitions for our new system
$ mount --bind /sys /mnt/sys
$ mount --bind /proc /mnt/proc
$ mount --bind /dev /mnt/dev
$ chroot /mnt
# Run blkid again and note the UUIDs for our root partition and the EFI system partition (nvme0n1p5 and nvme0n1p1 respectively)
# Then edit /etc/fstab and update the UUIDs to match
$ vi /etc/fstab
# Then re-generate the boot loader entries so they contain the new UUIDs
$ mkinitfs
# Finally, copy in all the firmware from Windows. We don't want to do this for the USB drive since the ADSP firmware causes the USB bus to reset while the rootfs is mounted which is a big problem when booted from USB.
$ yoink-firmware
# hit ctrl+d to exit and then unmount everything
$ umount -R /mnt
Wew, and we're done. Do a reboot -f and unplug the USB stick, you should now boot into your new system with GPU acceleration and battery reporting!
== Known issues ==
A list of known issues can be found in the pmaports repository
== See also ==
* 
* Initial support MR: