Malin's notes: Difference between revisions

From MalinWiKi
Jump to navigation Jump to search
 
(13 intermediate revisions by the same user not shown)
Line 132: Line 132:


# trykk ~ for å endre fra stor til liten bokstav ;)
# trykk ~ for å endre fra stor til liten bokstav ;)
# legg i toppen av dokumentet for å endre inrykk, etc
vim:ts=4:sw=4:sts=4:et:ai


=grub=
=grub=
Line 146: Line 149:


<pre>bcdedit.exe /set "{bootmgr}" path \EFI\debian\grubx64.efi</pre>
<pre>bcdedit.exe /set "{bootmgr}" path \EFI\debian\grubx64.efi</pre>
==Repair/install GRUB on EFI from live-usb==
source=https://askubuntu.com/questions/831216/how-can-i-reinstall-grub-to-the-efi-partition/831241#831241
<pre>mount /dev/sdXY /mnt</pre>
If you have seperatate boot-partition:
<pre>mount /dev/sdXX /mnt/boot</pre>
and finally mount the efi-partition under boot:
<pre>mount /dev/sdXZ /mnt/boot/efi/</pre>
Bind-mount some system partitions from the live-system:
<pre>for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done  </pre>
<pre>chroot /mnt</pre>
grub-install --target=x86_64-efi --efi-root=/dev/sdXZ
grub-mkconfig -o /boot/grub/grub.cfg</pre>
NOTE: Note : sdX = disk | sdXX = boot partition | sdXY = system partition | sdXZ = efi partition
===Troubleshooting===
EFI variables are not supported on this system.
source:https://bbs.archlinux.org/viewtopic.php?pid=1349414#p1349414
From outside chroot:
<pre>modprobe efivarfs</pre>
From inside chroot:
<pre> mount -t efivarfs efivarfs /sys/firmware/efi/efivars</pre>
==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:
<pre>cat (hd0,gpt1)/etc/issue</pre>
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:
<pre>Arch Linux \r (\l)</pre>
So if we say the root partition on Arch Linux was on (hd0,gpt2) you will need to run
<pre>root=(hd0,gpt2)</pre>
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:
<pre>linux /boot/vmlinuz root=/dev/nvme0n1p2</pre>
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
<pre>initrd /boot/initramfs.img</pre>
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:
<pre>boot</pre>


=libvirt=
=libvirt=
Line 208: Line 292:
*sources
*sources
https://www.cyberciti.biz/faq/how-to-clone-existing-kvm-virtual-machine-images-on-linux/
https://www.cyberciti.biz/faq/how-to-clone-existing-kvm-virtual-machine-images-on-linux/
== Batch operations on VMs ==
To shut down all running virtual machines, do:
<pre>for vm in $( virsh list | awk '/running/ { print $2  }' ) ; do virsh shutdown $vm ; done</pre>
To start up all virtual machines from a folder with xml-files representing an individual virtual machine, do:
<pre>for f in *.xml ; do vm=$( basename $f .xml ) ; virsh start $vm ; done</pre>


=add bareos client=
=add bareos client=
Line 293: Line 388:
Before you save and exit, add serial number to zone-file format: YYYYMMDDxx
Before you save and exit, add serial number to zone-file format: YYYYMMDDxx


Oneliner to run
Oneliner to run. change domain.no to your domain


<pre>rndc freeze karlsbakk.net && vi /etc/bind/karlsbakk.net.zone ; rndc thaw karlsbakk.net ; tail -f /var/log/daemon.log</pre>
<pre>rndc freeze domain.no && vi /etc/bind/karlsbakk.net.zone ; rndc thaw domain.no ; tail -f /var/log/daemon.log</pre>


==Local script to run==
==Local script to run==
Line 304: Line 399:


<pre>ddns-update.sh --force</pre>
<pre>ddns-update.sh --force</pre>
==Troubleshooting==
Ipv4 not updated when address changes
check if you remembered to thaw the zone


=SSH=
=SSH=
Line 329: Line 430:
== postgres ==
== postgres ==
https://stackoverflow.com/questions/32439167/psql-could-not-connect-to-server-connection-refused-error-when-connecting-to
https://stackoverflow.com/questions/32439167/psql-could-not-connect-to-server-connection-refused-error-when-connecting-to
=== backup with restic and file quotes ===
in debian you will need the package: quota
make a lv or something with a filesystem on it
in fstab block - mountpoint filesystem defaults,usrquota      0      0

Latest revision as of 08:57, 16 January 2024

gnu/linux

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

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

rtl8812AU

https://github.com/abperiasamy/rtl8812AU_8821AU_linux.git

remove led-disco

/etc/modprobe.d/8188eu-blacklist.conf

options 8812au rtw_led_enable=0

LVM

rename Volume Group (VG)

mdadm

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 192.168.0.101/24 dev eth0 ; ip route add default via 192.168.0.1 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

reboot

Crossflash Dell PERC H200 from ir to it-mode

The short answer

I slightly followed this guide:

https://blog.michael.kuron-germany.de/2014/11/crossflashing-dell-perc-h200-to-lsi-9211-8i/comment-page-1/

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: https://downloads.dell.com/FOLDER02950081M/1/Y2R1T_9211_FW.zip?uid=f06bb69a-8c88-4a54-ac7b-ee8826244140&fn=Y2R1T_9211_FW.zip

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 https://docs.broadcom.com/docs-and-downloads/host-bus-adapters/host-bus-adapters-common-files/sas_sata_6g_p20/Installer_P20_for_UEFI.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

3.

cd P07

4.

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

11.

cd P20

12.

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

Notes

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

libtorrent

rtorrent

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

vim

  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

vim:ts=4:sw=4:sts=4:et:ai

grub

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

source=https://askubuntu.com/questions/831216/how-can-i-reinstall-grub-to-the-efi-partition/831241#831241

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


Troubleshooting

EFI variables are not supported on this system.

source:https://bbs.archlinux.org/viewtopic.php?pid=1349414#p1349414

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

root=(hd0,gpt2)

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

initrd /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:

boot

libvirt

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:

127.0.1.1       debian-stretch-mal.debian-stretch-mal.local    debian-stretch-mal

to

127.0.1.1       new-name-vm.new-name-vm.local    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

/etc/hosts

Make ssh keys:

ssh-keygen

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

copy the the public key from

.ssh/id_rsa.pub

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

https://www.cyberciti.biz/faq/how-to-clone-existing-kvm-virtual-machine-images-on-linux/

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

/etc/bareos/bareos-dir-export/client/svennd/bareos-fd.d/director/bareos-dir.conf

Copy it to the client in:

/etc/bareos/bareos-fd.d/directory/bareos-dir.conf


  • sources

https://www.svennd.be/adding-a-linux-client-to-bareos/


IRC

Renew ssl cert

source= https://github.com/ubergeek42/weechat-android/wiki/Using-SSL-with-WeeChat#generating-a-self-signed-certificate= To create a certificate with a domain:

export HOSTNAME=example.org

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/$ZONE.zone ; rndc thaw $ZONE ; tail -f /var/log/daemon.log

Do it like this:

rndc freeze domain.no

Edit stuff in open and you can add stuff:

<text-editor> /etc/bind/domain.no.zone

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>

example:

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 domain.no to your domain

rndc freeze domain.no && vi /etc/bind/karlsbakk.net.zone ; rndc thaw domain.no ; tail -f /var/log/daemon.log

Local script to run

Open the local ddns-update.sh 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

ddns-update.sh --force

Troubleshooting

Ipv4 not updated when address changes

check if you remembered to thaw the zone

SSH

TAB-complete

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

Example

Host test-vm test
        Hostname test-vm.test.no

postgres

https://stackoverflow.com/questions/32439167/psql-could-not-connect-to-server-connection-refused-error-when-connecting-to

backup with restic and file quotes

in debian you will need the package: quota

make a lv or something with a filesystem on it

in fstab block - mountpoint filesystem defaults,usrquota 0 0