• 1 Post
  • 15 Comments
Joined 1 year ago
cake
Cake day: July 5th, 2023

help-circle

  • WARNING: doing this will absolutely DESTROY YOUR SYSTEM, PERMANENTLY!!!

    But if you wish to continue, you can erase all the EFI variables using the rm utility, I dont think you will be able to completely zero out the chip on the system from inside of Linux as its read-only.

    But to delete all the EFI variables, cd into /sys/firmware/efi/efivars, if this directory is not availiable, either the efivarfs is not mounted, or you are booted in legacy BIOS mode. But once you are in this directory, run chattr -i ./* as root or sudo to remove the immutable bit on all the files, then run rm ./* as root. This WILL break your system. Only do this if you know how to restore your system using like a chip programmer.


  • This happened to me too. I had to grab the box that comes up and resize it like I would with a normal window, mine glitched a lot when I tried it, try resizing it as far as you can, it will try and glitch back, but just keep fighting it until it becomes a usable size, then log out of Plasma and log back in, and then you can size it back down to a normal size. Hopefully there will be an official fix for this soon




  • Alright, could you see what the root variable is in the grub console before manually setting it by running echo $root, and if it prints anything, could you run ls / in the grub console and see if you see like home dev etc, or the directories you would expect to see in / inside linux, and if you do see anything, could you run ls /boot/grub/ and see if you see grub.cfg. But if you are already inside linux, go ahead and install grub with --removable, it wont overwrite your current installation. I dont want you to format the efi partition, incase something goes wrong and you wont be able to boot into linux at all


  • I think anything that can be done with a fresh format can be done with the current one, when you ran grub-install after the issue with not running it as root, did you only do it with --removable? If so, the old grub is might be getting picked over the new grub installed at the removable fallback path, because it has a proper entry in the boot order. I dont know what key it is on your system, but if you can get into the boot order menu where it shows all the different boot devices, like where you can pick where you want to boot from, id look for one that just says something like "UEFI boot " or something like along those lines, it wont say like grub or your distro name, if there is such an option available, could you try booting from that option?



  • This is definitely strange, but the EFI system partition will have to be mounted to install grub to it, maybe the disk got mounted as read only, could you try explicitly mounting it as rw with this command

    sudo mount /dev/nvme0n1p1 /boot/efi -o rw
    

    and then see if you can make a file as root by doing

    sudo touch /boot/efi/test
    

    if it doesnt fail on a permissions error, try installing grub again with --removable incase this error has something to do with it trying to tell the firmware what disk to look in like this

    sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --removable
    

    hopefully this will run without error and install grub, and if it does id run it again without the removable flag


  • As long as the kde neon partition is still there, recovery should be possible. You will need a way to boot into a linux environment like a installation media of just about any distro, where you will be able to mount your kde neon install, chroot in, and reinstall grub. Now I dont know your system or how you have it setup, but I can try and give some basic instructions.

    So first things first, you are gonna want to get into a linux environment and open a terminal and start a root shell, this may be different depending on your environment, but its pretty much just:

    sudo bash
    

    or

    su -l root
    

    now if either of these ask you for a password, and its not presented somewhere, you may have to search on the internet for like installation disk default password, but hopefully sudo is just setup to run without one.

    Now that you are in the root shell, you need to find the name of the block device that corresponds with your kde neon partition, the lsblk utility can be used to list all detected block devices, you are gonna want to find the one with the same size as your kde neon partition, this will likely be the one. Now if your partition has a label on it, you can use ls to look into the /dev/disk/by-label/ directory and see if you see your partitions label there, if so, you can just mount it like this:

    mount /dev/disk/by-label/example-label /mnt
    

    If the /dev/disk/by-label/ directory does not exist, it just means that none of the partitions are labeled. If you are having trouble determining what partition has your data, you can try mounting each one and looking inside, and unmounting them if it doesnt have your kde neon install like this:

    mount /dev/sda1 /mnt
    ls /mnt
    umount /mnt
    

    sda1 is just an example here, it may be different on your system.

    Now when you have found the partition that has your kde neon install and mounted it to /mnt, you can now cd in and bind mount the special directories like this:

    cd /mnt
    mount -t proc /proc proc/
    mount -t sysfs /sys sys/
    mount --rbind /dev dev/
    

    now if you are booting using UEFI, you will have to bind mount the efivars directory with this command:

    mount --rbind /sys/firmware/efi/efivars sys/firmware/efi/efivars/
    

    Now with everything mounted, you should be ready to chroot in and reinstall grub, you can chroot with this command:

    chroot /mnt /bin/bash
    

    Now that you are in your kde neon install, you can reinstall grub, the installation process may vary depending on if you are booting legacy BIOS or UEFI, to install grub on bios, you would run:

    grub-install --target=i386-pc /dev/sda
    

    now /dev/sda is just an example here, but you want to install it to the main disk, dont install it to a partition like sda1 or something.

    But if you are on efi, there may be an extra mount involved, the EFI system partition, now if the EFI system partition gets mounted automatically in normal circumstances, you should be able to just run:

    mount -a
    

    this command will mount the partitions listed in the /etc/fstab file. If the partition was destroyed, it will have to be recreated. If it is not listed in the fstab and is not automatically mounted, you may have to seek it out manually with lsblk, it should be the smallest partition, use the mount command to mount it to /boot/efi, creating this directory if it does not already exist. If you have to create one, just make a partition with at least 16 megs of space, and format it as a FAT partition, you can use the mkfs.msdos or mkfs.fat command line utilities like this:

    mkfs.msdos /dev/sda2
    

    where /dev/sda2 is the free space that is gonna be used for the system partition, this command is destructive, and will overwrite any data on the partition, so make sure you enter the one with just free space.

    Once you know what partition is your efi system partition, and you have mounted it to /boot/efi in the chroot, you can now install the UEFI version of grub, you can use this command

    grub-install --target=x86_64-efi --efi-directory=/boot/efi
    

    and for good measure/backup incase grub cant tell your firmware where it is located, you can install it to the removable media path where your firmware will look if it doesnt have any entries with this command:

    grub-install --target=x86_64-efi --efi-directory=/boot/efi --removable
    

    And finally, once you have installed grub for either UEFI or BIOS, you can generate the config file, like this:

    grub-mkconfig -o /boot/grub/grub.cfg
    

    Now you can reboot using the reboot command like this:

    reboot
    

    it should take care of unmounting everything for you, make sure you remove whatever installation media if you are using any from your system. And hopefully it should just boot into the normal grub menu and start your kde neon install.





  • Im glad I was able to help!

    Something that should be noted when adding colors to your shell prompt function is adding the non printable characters that keep the terminal from buggin out, this caused me a massive headache until I figured it out. When putting it in the PS1 variable directly you will put \[ to begin a color sequence and \] to end one, but printf will print a literal [ and ] so instead you will have to use \001 to start and \002 to end, I also recommend changing \e to \033 or \x1B to make things a bit more portable. For a quick example \[\e[1;31m\] would become \001\033[1;31m\002. Without these characters the terminal will like glitch out when you type a long command and then go back to the front.

    If you are like messing around or trying to learn a new programming language, you can try like porting your shell prompt to that language, Ive ported mine to C and set it using the same subsitution shell method, I thought it was a fun lil challenge.

    But anyways, I hope you have fun customizing your shell prompt!


  • A person in this thread already recommended having different colors for different conditions like ssh and running as root, I havent seen anyone mention this specifically but you can determine if the current working directory is writable with something like [ -w "$(pwd)" ] and set the color to red or print a symbol if it doesnt return true.

    Also I recommend putting all the code and logic for your shell prompt in a shell function, and using a substitution shell to put it into the PS1 variable like this:

    __shellprompt ()
    {
    	if [ "$(id -u)" = 0 ]; then
    		local PROMPT_EMBLEM='#'
    	else
    		local PROMPT_EMBLEM='$'
    	fi
    	printf "%s" "$(whoami)@$(uname -n):$(pwd)"
    	printf "\n%c " "$PROMPT_EMBLEM"
    }
    PS1='$(__shellprompt)'
    

    Now this is just a really barebones example, there is a whole lot more you can do like passing in the last exit code through the argv of your shellprompt function like this PS1='$(__shellprompt $?)' and like print it out if its non-zero so you wont have to like echo $? to see if the last command failed, but you should be able to still do this. In my testing, running the shell prompt function in the subsitiution shell didnt effect the $? variable.

    In my first comment on another thread about shell prompts, I posted my full shellprompt, it is slightly outdated (I just changed hostname to uname -n), if you cant find it feel free to send a message or just ask, and I will send you the code.


  • I designed this prompt shortly after I switched to Linux, I’ve been using it for a while, it has a few features like putting the exit code if it isn’t 0, changing the hostname color if its detected that you are over ssh, changing the directory color to red if it isn’t writeable, changing the prompt color to red if your euid is 0, and instead of printing I have no name! when your user does not have an entry in the passwd file, it will just print your uid in red. I also have a version that I wrote in C that works the same way with a subsitution shell, but it was harder to sync across all my devices when I made a change, so I rewrote it in posix shell that could be synced with just my .bashrc and work almost anywhere.

    I don’t know how to post a screenshot, sorry for the long paragraph, but here is the source code, feel free to share or do whatever with it!

    #-----PS1-----#
    BOLDRED="\001\033[1;31m\002"
    BOLDBLUE="\001\033[1;34m\002"
    BOLDPURPLE="\001\033[1;35m\002"
    BOLDCYAN="\001\033[1;36m\002"
    BOLDGREEN="\001\033[1;32m\002"
    COLORRESET="\001\033[0m\002"
    CURSOR_BLINK="\001\033[5 q\002"
    INFO_COLOR=$BOLDGREEN
    SUPERUSER_COLOR=$BOLDRED
    NORMALUSER_COLOR=$BOLDCYAN
    SSH_COLOR=$BOLDPURPLE
    __shellprompt ()
    {
            if [ "$(id -u)" = 0 ]; then
                    PROMPT_COLOR=$SUPERUSER_COLOR
                    PROMPT_EMBLEM='#'
            else
                    PROMPT_COLOR=$NORMALUSER_COLOR
                    PROMPT_EMBLEM='$'
            fi
            # [user@hostname]
            printf "%b%s%b" "${PROMPT_COLOR}[${INFO_COLOR}" "$(whoami 2>/dev/null || (printf "%b%s" "${BOLDRED}" "UID:$(id -u)"))" "${PROMPT_COLOR}@"
            if [ -n "${SSH_TTY}" ] || [ -n "${SSH_CLIENT}" ]; then
                    printf "%b" "$SSH_COLOR"
            else
                    printf "%b" "$INFO_COLOR"
            fi
            printf "%s%b" "$(hostname)" "${PROMPT_COLOR}]"
            # :
            printf "%b" "${COLORRESET}:"
            # (/pwd)
            printf "%b" "${PROMPT_COLOR}("
            if [ -w "$PWD" ]; then
                    printf "%b" "${INFO_COLOR}"
            else
                    printf "%b" "${BOLDRED}"
            fi
            if [ -n "$HOME" ] && [ "$HOME" != "/" ] && { [ "$PWD" = "$HOME" ] || [ "$PWD" != "${PWD#"$HOME/"}" ]; }; then
                    printf "%s" "~${PWD#"$HOME"}"
            else
                    printf "%s" "${PWD}"
            fi
            printf "%b" "${PROMPT_COLOR})${COLORRESET}"
            # :(EXITCODE)
            if [ "$1" != 0 ]; then
                    printf "%b" "${COLORRESET}:"
                    printf "%b%s%b" "${PROMPT_COLOR}(${BOLDRED}" "${1}" "${PROMPT_COLOR})${COLORRESET}"
            fi
            # ->$
            # ->#
            printf "%b" "\n${PROMPT_COLOR}->${PROMPT_EMBLEM} ${COLORRESET}${CURSOR_BLINK}"
    }
    export PS1='$(__shellprompt $?)'
    #-----PS1-----#