Malin's notes

From MalinWiKi
Revision as of 22:23, 17 September 2023 by (talk | contribs) (→‎Boot Linux from GRUB shell)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


To change ownership of everything that's not already owned by a user

find /home/rtorrent/ ! -user rtorrent -exec chown rtorrent:rtorrent {} \; &


remove led-disco


options 8812au rtw_led_enable=0


rename Volume Group (VG)


for dev in $( lsblk | awk '/sd[a-z].*1,8T/ { print }' ); do echo =============================== $dev ============================ ; smartctl -a /dev/$dev ; done | pastebinit

mdadm --remove /dev/md0 failed # all failed devices

mdadm --remove /dev/md0 detached # failed ones that aren't in /dev anymore

ip addr add dev eth0 ; ip route add default via dev eth0

Mulig rekkefølge med forbehold om at et ikke stemmer, for å endre vg navn på vg med root-partisjon vgchange gammel-vg ny-vg vgchange -ay

endre i /etc/fstab

grub-install /dev/XxX

update-initramfs -k all -u


Crossflash Dell PERC H200 from ir to it-mode

The short answer

I slightly followed this guide:

The longer answer is. I followed the guide, this way, but did it a little different

The longer answer

Prepare a usb memory stick formatted as fat32 with two folders called P07 and P20

Step 1 download old firmware

1. Download this zip archive from dell and unzip it:

2. Extract 6GBPSAS.FW from Y2R1T_9211_FW/Firmware/6GbpsSASHBA_07.03.06.00_A10

3. Extract 2118it.bin from FY2R1T_9211_FW/Firmware/9211-8i_P7/

4. Extract sas2flash.efi from Y2R1T_9211_FW/sas2flash/p05/efi/

5. Place the three extracted files in the P07 folder

Step 2 download current firmware

1. Extract 2118it.bin from Y2R1T_9211_FW/Firmware/9211-8i/P20/

2. Download this zip

3. Extract sas2flash.efi from Installer_P20_for_UEFI/sas2flash_efi_ebc_rel/

4. Place this to extracted files in the P20 folder

Step 3 download uefi shell

1. Download an uefi shell: x86_64 UEFI SHELL I choosed version 1 as it worked for the person in the guide Direct download link

2. Extract Shell_Full.efi to the root of the memory stick. I had to rename it to Shellx64.efi to use it with my motherboard, asus P8H67_M_EVO. Check with you motherboard vendor to determine how to use efi-shell

Step 4 flashing

1. boot computer to efi shell

2. If not present with a list with devices, type

map -b

2. On my computer the memory stick is called fs0 so I typed fs0: to change prompt to the memory stick


cd P07


sas2flash -listall

will show the controller. If not, check if it is installed to a pci-e port 5.

sas2flash.efi -c 0 -list

will show controller details and take a note of the sas address number 6.

sas2flash.efi -o -e 6

will erase the old firmware and boot rom 7.

sas2flash.efi -o -f 6GBPSAS.FW

writes the dell 6gbs firmware 8.

sas2flash.efi -o -f 2118it.bin

writes the P07 firmware

9. Then I rebooted

10. boot into efi again


cd P20


sas2flash.efi -o -f 2118it.bin writes the P20 firmware


Directly copied from the source, step number changed to fit my tutorial:

1. Step 6 showed “Erasing Flash Region” and then after a while “ERROR: Erase Flash Operation Failed!”. I simply proceeded and the error did not appear to affect anything.

2. Visit source to get screenshots vit the error messages

Compile rtorrent libtorrent and xmlrpc-c



./configure --prefix=/usr --with-xmlrpc-c |tee /tmp/conf.log


  1. Merk Noe Og Trykk U For Å Få Det I Lowercase, U For Uppercase ;)
  2. stor v for visual line eller liten for visual der du må merke noe manuelt
  3. ok. jeg glemte å markere først :p
  4. oki :)
  1. iT'S cAPS lOCK DAY!
  1. trykk ~ for å endre fra stor til liten bokstav ;)
  1. legg i toppen av dokumentet for å endre inrykk, etc



Repair GRUB from Windows

To repair efi bootloader/grub from windows

Open powershell as admin and execute the following command

bcdedit.exe /set "{bootmgr}" path \EFI\{distro}\grubx64.efi

if you are running debian, it will look like this:

bcdedit.exe /set "{bootmgr}" path \EFI\debian\grubx64.efi

Repair/install GRUB on EFI from live-usb


mount /dev/sdXY /mnt

If you have seperatate boot-partition:

mount /dev/sdXX /mnt/boot

and finally mount the efi-partition under boot:

mount /dev/sdXZ /mnt/boot/efi/

Bind-mount some system partitions from the live-system:

for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done  
chroot /mnt

grub-install --target=x86_64-efi --efi-root=/dev/sdXZ

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

NOTE: Note : sdX = disk | sdXX = boot partition | sdXY = system partition | sdXZ = efi partition


EFI variables are not supported on this system.


From outside chroot:

modprobe efivarfs

From inside chroot:

 mount -t efivarfs efivarfs /sys/firmware/efi/efivars

Boot Linux from GRUB shell

Something went down the alley and you're now stuck in the grub shell, or that's what you think :)

First we need to figure out what partition our linux root-partition is on

the command ls will list all disks and partitions

to find what partition it is on, do:

cat (hd0,gpt1)/etc/issue

do this with the different disksk and partitions until you find one that outputs a line that says something about what Linux flavlour you are running. On Arch it will look like this:

Arch Linux \r (\l)

So if we say the root partition on Arch Linux was on (hd0,gpt2) you will need to run


This must be adjusted to fit your system.

Next we need to tell what kernel we will run and what device (dev) the root-partition ison:

linux /boot/vmlinuz root=/dev/nvme0n1p2

If the root-partion is on a m2-card and is on the second partition on device nvme0n1, do as above.

Use autocomplete (tab-complete) if you want a more specific kernel-version

Next we need to choose the initramfs image

inird /boot/initramfs.img

Use tab-complete to find a more specifici version to match a more specicific kernel in the previous step

Now it's time to boot:



setup new vm from a template

If you have a qcow2 vm template, clone it.:

If you clone a qcow2 in use, stop the vm first:

virsh stop {domain-vm-name}

Then clone the qcow2

virt-clone --original {Domain-Vm-Name-Here} --name {New-Domain-Vm-Name-Here} --auto-clone

Configure your VM to your likings either by virt-manager (gui) or by cli

Start the new vm and log in, either by ssh, or via virt-manager

Change hostname to match the new name of the VM

sudo -i
vi /etc/hostname

vi /etc/hosts

to match the name of the new VM

Example. change:       debian-stretch-mal.debian-stretch-mal.local    debian-stretch-mal

to    new-name-vm

Also add a line for the ip to the server who runs the VM and for the backup server if you have one, like this

192.168.X.X hostname.domain.xx      hostname

change local ip to a free address

 vi /etc/network/interfaces

and add the new ip in on the host


Make ssh keys:


go with the defaults by hit enter, when prompted for questions

copy the the public key from


If bareos is setup on the qcow2 vm template you also need to change the following line in bareos filedaemon config to match your new vm

vi /etc/bareos/bareos-fd.conf

FileDaemon {
Name = new-name-vm.domain.xx-fd 
  • sources

Batch operations on VMs

To shut down all running virtual machines, do:

for vm in $( virsh list | awk '/running/ { print $2  }' ) ; do virsh shutdown $vm ; done

To start up all virtual machines from a folder with xml-files representing an individual virtual machine, do:

for f in *.xml ; do vm=$( basename $f .xml ) ; virsh start $vm ; done

add bareos client

If you already have a bareos backup server

on the new vm or computer you want to backup to bareos

Install bareos-filedaemon on the client if it's not already installed

 apt install bareos-filedaemon
systemctl enable bareos-filedaemon.service

Then log into the bareos server and run bconsole

configure add client name=new-name-vm address=192.168.X.X password=SOME_PASSWORD

Then the config is saved to


Copy it to the client in:


  • sources


Renew ssl cert

source= To create a certificate with a domain:


From within ~/.weechat/ssl do:

openssl req -x509 -nodes -newkey rsa:2048 -keyout relay.pem -extensions san_env \
    -subj "/O=WeeChat/CN=$HOSTNAME" \
    -config <(cat /etc/ssl/openssl.cnf <(printf "\n[ san_env ]\nsubjectAltName=DNS:\${ENV::HOSTNAME}")) \
    -days 365 -out relay.pem

Then within weechat, reload to the new certificate

/relay sslcertkey

DNS with rndc

Manipulating dns with rndc

login to the computer/vm that takes care of DNS

ZONE=<domain>.<countrycode> ; rndc freeze $ZONE && vi /etc/bind/$ ; rndc thaw $ZONE ; tail -f /var/log/daemon.log

Do it like this:

rndc freeze

Edit stuff in open and you can add stuff:

<text-editor> /etc/bind/

Edit the file according to this:

<vm-domain-name-vm>   AAAA  ipv6-adr
<vm-domain-name-vm>   A     ipv4-adr

<vm-domain-name>      CNAME <vm-domain-name>


test-vm         AAAA        ipv6-adr
test-vm         A           ipv4-adr

test            CNAME       test-vm

Don't have same domain on both A/AAAA and CNAME

Before you save and exit, add serial number to zone-file format: YYYYMMDDxx

Oneliner to run. change to your domain

rndc freeze && vi /etc/bind/ ; rndc thaw ; tail -f /var/log/daemon.log

Local script to run

Open the local script and add test-vm to VM= variabel if not already present

If you don't want to wait for the script to run automatically from cron, run it with the force flag --force


Ipv4 not updated when address changes

check if you remembered to thaw the zone



vi .ssh/config

Then add lines like this:

Host <name> # space between multiple names
        user admin # optional if you want to add username to log in with
        Hostname <ipaddress>/<domain/hostname>
        Port 2022 # optional add if port is other than default 22


Host test-vm test