Legenda (oznaczenia używane w postach) czyli lets clean this burdel

Oznaczenia używane w postach

Zwykły tekst Czcionka Georgia

apt-get install -Komenda



-ryzyko uszkodzenia systemu


-skrypt w bashu
-Ważna informacja

=====
wycinek z loga konsoli
====

nano /etc/resolv.conf plik do edycji


czwartek, 24 listopada 2022

Debian nie montuje dysków w gui

 debian nie montuje dysków w gui


instalujemy udisks2

By jawojx https://forum.dug.net.pl/profile.php?id=8591

https://forum.dug.net.pl/viewtopic.php?pid=333548#p333548

Kod:

pkaction

A reguła podana na archwiki jest prawidłowa i z udisks2. Może coś pomyliłeś, a może zostawiłeś już inne.

Podam dla przykładu obydwie, ale ustawiać jedną wybraną. Przyjmijmy twoją podstawową grupę "grafi" (grupa pierwsza z brzegu). Podam ścieżki do tworzonych plików, chociaż to nieistotne, tutaj. Edytuj swoje, jak je zostawiłeś. Pierwsze powinno działać od razu, po ponownym uruchomieniu menadżera plików.

Kod:

/etc/polkit-1/rules.d/50-mount.rules

Nie musi być tak, może być z jedną jak na wiki arch-a.

Kod:

polkit.addRule(function(action, subject) {
    if ((action.id == "org.freedesktop.udisks2.filesystem-mount-system" ||
         action.id == "org.freedesktop.udisks2.filesystem-mount") &&
        subject.isInGroup("grafi")) {
        return polkit.Result.YES;
    }
});

A to drugie.

Kod:

/etc/polkit-1/localauthority/50-local.d/50-mount.pkla

Minimalna wersja, tyle wystarczy.

Kod:

[udisks]
Identity=unix-group:grafi
Action=org.freedesktop.udisks2.filesystem-mount-system
ResultAny=yes
ResultInactive=no
ResultActive=yes

niedziela, 23 października 2022

Debootstrap

 sudo su -
apt update

lsblk

mkfs.fat -F32 /dev/vda1
mkswap /dev/vda2
mkfs.ext4 /dev/vda3

lsblk

mount /dev/vda3 /mnt
mkdir -p /mnt/boot/efi     <-- w przypadku instalacji biosowej  tworzymy mkdir -p /mnt/boot

mount /dev/vda1 /mnt/boot/efi   <-- w przypadku instalacji biosowej montujemy mount /dev/vda1 /mnt/boot

swapon /dev/vda2

mkdir -p /mnt/home
mount /dev/vdb1 /mnt/home

apt update

apt install debootstrap

debootstrap --verbose --include linux-image-amd64,grub-efi ,locales --arch amd64 bullseye /mnt http://ftp.pl.debian.org/debian

--> jeśli instalacja bios debootstrap --verbose --include linux-image-amd64,grub-legacy,locales --arch amd64 bullseye /mnt

for dir in sys dev proc; do mount --rbind /$dir /mnt/$dir && mount --make-rslave /mnt/$dir; done

cp /etc/mtab /mnt/etc/mtab

apt install arch-install-scripts

genfstab -U /mnt >> /mnt/etc/fstab

 chroot /mnt /bin/bash

nano /etc/apt/sources.list

deb http://deb.debian.org/debian bullseye main contrib non-free

apt update

======================

opcjonalnie

=====================

Tworzymy teraz plik konfiguracyjny /etc/apt/apt.conf.d/00-no-instal-recommends i dodajemy w nim tę poniższą treść:

=========================================
APT::Install-Recommends "false";

APT::Install-Suggests "false";

APT::AutoRemove::RecommendsImportant "false";

APT::AutoRemove::SuggestsImportant "false"

===================================================
===================================================

Odchudzi to instalacje znacząco natomiast o wiele rzeczy będziemy musieli zadbać sami, może skutkować niestabilnością systemu

Zdecydowanie lepszym wyjściem jest użycie apt-get install --no-install-recommends
podczas instalacji paczek

apt-get install --no-install-recommends firmware-linux  firmware-linux-nonfree sudo  network-manager vim intel-microcode (amd64-microcode) build-essential  locales localepurge console-setup console-data kbd

dpkg-reconfigure tzdata

dpkg-reconfigure locales

en_US.UTF-8, pl_PL.UTF-8 , en_US, pl_PL > Yes > Yes .

dpkg-reconfigure keyboard-configuration

Wybieramy odpowiednio: model -> Polish -> Right Alt (AltGr) -> Right Control

 dpkg-reconfigure console-setup

 UTF-8 -> Latin2 -> Terminus -> 8x16 


echo "test" > /etc/hostname

dodaj do /etc/hosts

127.0.1.1    test.localdomain test


ls /sys/class/net

enp7s0  lo  wlp6s0

tworzymy /etc/network/interfaces   według wzoru

auto lo
iface lo inet loopback

#dla dhcp:

auto eth0

allow-hotplug eth0

iface eth0 inet dhcp


Przykład dla statycznego ip: (broadcast and gateway are optional)

#

#auto eth0

#iface eth0 inet static

#   address 10.1.7.61

#   network 10.1.0.0/16

#   netmask 255.255.0.0

#   broadcast 10.1.255.255

#   gateway 10.1.255.253

podstawiająć enpXsX lub wlpXsX w miejsce eth0

apt install dhcpcd5 network-manager

passwd

useradd jan -m -U -c "Jan Kowalski" -s /bin/bash

psswd jan

usermod -aG sudo jan

grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB

lub grub-install  /dev/sdX  jeśli bios install

update-grub

Ustawienie klawiatury podczas startu systemu,  w pliku /etc/initramfs-tools/initramfs.conf ustawiamy zmienną KEYMAP=y za pomocą update-initramfs -u -k all generujemy nowy initframs. 

umount -a

exit

reboot now

logowanie do gołego systemu instalacja gui i reszty

OPENBOX

apt-get install --no-install-recommends xinit slim / wdm

htop tint2 obconf obsession wpasupplicant openbox xserver-xorg-core 

xserver-xorg-video-intel (xserver-xorg-video-radeon /xserver-xorg-video-amdgpu)  

xfonts-100dpi xfonts-75dpi 

xfonts-terminus xfonts-100dpi-transcoded xfonts-75dpi-transcoded 

xserver-xorg-input-evdev x11-xserver-utils rtkit 

x11-xkb-utils rxvt-unicode network-manager  gnome-network-nanager menu neovim 

firefox-esr policykit-1 dbus-x11 gvfs udisks2 

libreoffice-core libreoffice-l10n-pl libreoffice-help-pl libreoffice-writer libreoffice-calc 

libreoffice-impress  atril mousepad pcmanfm pulseaudio pavucontrol gsimplecal fech volumeicon-alsa

sudo apt install build-essential udev gzip bzip2 zip unzip rar unrar p7zip-full xarchiver

openbox-menu lxmenu-data


pomiędzy <menu id="root-menu" label="Openbox 3">i </menu> dodać


<menu execute="openbopenbox-menu lxde-applications.menu" id="apps" label="Applications"/>


Zciągnij i skompiluj menumaker


=====================================================================================

MINIMALNE KDE


apt-get install --no-install-recommends kde-plasma-desktop plasma-nm ark kate kcalc kde-spectacle okular


poniedziałek, 10 października 2022

Debian instalacja chroot prawie jak ARCH

chroot /target/ /bin/bash


root@debian:/home/dw# apt-get install --no-install-recommends xinit slim /wdm
htop tint2 obconf obsession wpasupplicant openbox xserver-xorg-core
xserver-xorg-video-intel (xserver-xorg-video-radeon /xserver-xorg-video-amdgpu)
xfonts-100dpi xfonts-75dpi
xfonts-terminus xfonts-100dpi-transcoded xfonts-75dpi-transcoded
xserver-xorg-input-evdev x11-xserver-utils rtkit
x11-xkb-utils rxvt-unicode network-manager gnome-network-nanager menu neovim
firefox-esr policykit-1 dbus-x11 gvfs udisks2
libreoffice-core libreoffice-l10n-pl libreoffice-help-pl libreoffice-writer libreoffice-calc
libreoffice-impress atril mousepad pcmanfm pulseaudio pavucontrol gsimplecal fech volumeicon-alsa
sudo apt install build-essential udev gzip bzip2 zip unzip rar unrar p7zip-full xarchiver
openbox-menu lxmenu-data

pomiędzy <menu id="root-menu" label="Openbox 3">i </menu> dodać

<menu execute="openbopenboox-menu lxde-applications.menu" id="apps" label="Applications"/>

niedziela, 11 września 2022

Iso check gpg sum

  1. gpg --verify SHA512SUMS.sign SHA512SUMS.txt 
  2. sha512sum -c SHA512SUMS.txt 2>/dev/null | grep firmware-11.5.0-amd64-netinst.iso 

firmware-11.5.0-amd64-netinst.iso: DOBRZE



niedziela, 7 sierpnia 2022

Deboostrap Debian 11

 https://github.com/aomgiwjc/Unix-Bootstrap-Installs/wiki/Debian-Bootstrap-Chroot-Install---Ext4,-one-drive

https://www.youtube.com/watch?v=oKnkOwdysNs

środa, 3 sierpnia 2022

Apt pinning

https://dug.net.pl/tekst/163/priorytety_pakietow_(apt_pinning__pin_priority)/

root@dw:~# cat /etc/apt/preferences.d/99debian-unstable 
Package: *
Pin: release a=unstable
Pin-Priority: 10
root@dw:~# 

wtorek, 12 lipca 2022

BSD zfs home na oddzielnym dysku

Going by memory since it's been a long while, this is how you do it after the fact:


zfs is datasets. the installer by default create a dataset named user/home:
zroot/usr/home 24.6G 179G 24.6G /usr/home
making sure noone is logged in or using /usr/home/username, so
as root from a console you use zfs commands to rename the existing zroot/usr/home dataset something like
zfs rename zroot/usr/home zroot/usr/home.ORIG
use zfs commands to change the mountpoint, something like
zfs set mountpoint=/usr/home.ORIG zroot/usr/home.ORIG

then assuming your second device is hooked, you use gpart to set it up, set gpt scheme on it, create a partition of type freebsd-zfs, make sure you align and label it as something like "zfs1" or something meaningful
then simply use zfs commands to create a new pool on that partition
zpool create storage gpt/zfs1 or ada1p1 (of course you use your correct label and device names)
then create your new user/home dataset:
zfs create storage/home
set the mountpoint to /usr/home
zfs set mountpoint=/usr/home storage/home

Now you have your home directories on a different device. If you have data in your existing user directories, many ways to copy it over a simple way would be to use tar piping through stdout/stdin. Or rsync or cp -R /usr/home.ORIG /usr/home.
One could also use zfs send/zfs receive if desired. I find that for a home user system with a single or couple of users, cp or tar works good enough.

The installer you would need to drop to a shell at some point and do the partitioning and zpool and dataset creation by hand, pay attention to the mount points, lots of things to keep track of.
That is why people suggested do the install on a single disk, do not create a user, simply get the system up and running. Then you do what I've outlined here, since there are no user directories yet, nothing to copy.

ZFS I learned you want to get yourself copies of the following books by Michael W Lucas:
FreeBSD Mastery: Storage Essentials
FreeBSD Mastery: ZFS (with Allan Jude)
FreeBSD Mastery: Advanced ZFS (with Allan Jude)
Pretty much any "How do I do this" question on ZFS I've ever had are answered in them.

sobota, 12 marca 2022

Wyświetlanie danych na ekran i do pliku (tee)

The command you want is named tee:

foo | tee output.file

For example, if you only care about stdout:

ls -a | tee output.file

If you want to include stderr, do:

program [arguments...] 2>&1 | tee outfile

2>&1 redirects channel 2 (stderr/standard error) into channel 1 (stdout/standard output), such that both is written as stdout. It is also directed to the given output file as of the tee command.

Furthermore, if you want to append to the log file, use tee -a as:

program [arguments...] 2>&1 | tee -a outfile

czwartek, 10 marca 2022

Shrinking images on Linux

 

Shrinking images on Linux

When creating images from existing ISOs you often need to allocate a number of MB for the image to at least fit the files that are in the ISO. Predicting the exact size of the image is hard, even for a program. In this case you will create an image that is larger than actually needed: the image is much larger than the files on the image are combined.

This post will show how to shrink an existing image to a more optimal size. We will do this on Linux, since all required tools are available there: GParted, fdisk and truncate.

Requirements

  • A Linux PC
  • Some knowledge how the terminal works will helps
  • The unoptimal image (myimage.img in this example)

Creating loopback device

GParted is a great application that can handle partition tables and filesystems quite well. In this tutorial we will use GParted to shrink the filesystem (and its accompaning partition in the partition table).

GParted operates on devices, not simple files like images. This is why we first need to create a device for the image. We do this using the loopback-functionality of Linux.

First we will enable loopback if it wasn't already enabled:

$ sudo modprobe loop

Now we can request a new (free) loopback device:

$ sudo losetup -f

This will return the path to a free loopback device. In this example this is /dev/loop0.

Next we create a device of the image:

$ sudo losetup /dev/loop0 myimage.img

Now we have a device /dev/loop0 that represents myimage.img. We want to access the partitions that are on the image, so we need to ask the kernel to load those too:

$ sudo partprobe /dev/loop0

This should give us the device /dev/loop0p1, which represents the first partition in myimage.img. We do not need this device directly, but GParted requires it.

Resize partition using GParted

Next we can load the device using GParted:

$ sudo gparted /dev/loop0

This should show a window similar to the following:

Now notice a few things:

  • There is one partition.
  • The partition allocates the entire disk/device/image.
  • The partition is filled partly.

We want to resize this partition so that is fits it content, but not more than that.

Select the partition and click Resize/Move. A window similar to the following will popup:

Drag the right bar to the left as much as possible.

Note that sometimes GParted will need a few MB extra to place some filesystem-related data. You can press the up-arrow at the New size-box a few times to do so. For example, I pressed it 10 times (=10MiB) for FAT32 to work. For NTFS you might not need to at all.

Finally press Resize/Move. You will return to the GParted window. This time it will look similar to the following:

Notice that there is a part of the disk unallocated. This part of the disk will not be used by the partition, so we can shave this part off of the image later. GParted is a tool for disks, so it doesn't shrink images, only partitions, we have to do the shrinking of the image ourselves.

Press Apply in GParted. It will now move files and finally shrink the partition, so it can take a minute or two, most of the time it finishes quickly. Afterwards close GParted.

Now we don't need the loopback-device anymore, so unload it:

$ sudo losetup -d /dev/loop0

Shaving the image

Now that we have all the important data at the beginning of the image it is time to shave of that unallocated part. We will first need to know where our partition ends and where the unallocated part begins. We do this using fdisk:

$ fdisk -l myimage.img

Here we will see an output similar to the following:

Disk myimage.img: 6144 MB, 6144000000 bytes, 12000000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000ea37d

      Device Boot      Start         End      Blocks   Id  System
myimage.img1            2048     9181183     4589568    b  W95 FAT32

Note two things in the output:

  • The partition ends on block 9181183 (shown under End)
  • The block-size is 512 bytes (shown as sectors of 1 * 512)

We will use these numbers in the rest of the example. The block-size (512) is often the same, but the ending block (9181183) will differ for you. The numbers mean that the parition ends on byte 9181183*512 of the file. After that byte comes the unallocated-part. Only the first 9181183*512 bytes will be useful for our image.

Next we shrink the image-file to a size that can just contain the partition. For this we will use the truncate command (thanks uggla!). With the truncate command need to supply the size of the file in bytes. The last block was 9181183 and block-numbers start at 0. That means we need (9181183+1)*512 bytes. This is important, else the partition will not fit the image. So now we use truncate with the calculations:

$ truncate --size=$[(9181183+1)*512] myimage.img

Now copy the new image over to your phone, where it should act exactly the same as the old/big image.