Forumi


Povratak   PC Ekspert Forum > Računala > Software > Operativni sustavi
Ime
Lozinka

Odgovori
 
Uređivanje
Staro 30.04.2024., 16:38   #3181
radi.neradi
Registered User
 
Datum registracije: May 2023
Lokacija: Mrkopalj
Postovi: 47
ima jos jedan post prije.

mozes pokusat i slozit svoj initramfs/ramdisk kako bi dosao do samog izvora problema proceduralno. tekst sam pisao za vrijeme boravka na crux distri jer sam htio nauciti vise o boot procesu i bootloaderu. na engleskom je kako bi ga ceo sve razumeo. ima par malih greskica tako da copy/paste bez razumjevanja nece radit. :-)

to learn more about linux booting process, ive inspected lilo bootloader and built a small initramfs. essentially initramfs is a minimal system that includes required dependencies for reading, mounting, decrypting, assembling software raid, assembling lvm and other actions needed to continue booting to real rootfs. we will now write a working initramfs for crux linux that will decrypt luks partition on HP DL380p Gen8 server using P420i hardware RAID-1. software raid will also be explained. kernel modules for hardware raid, software raid and other actions done on disks before mounting should be built as kernel modules which will be included in initramfs.

# partition layout
/dev/sda disk 10G
/dev/sda1 /boot
/dev/sda2 crypt_LUKS
/dev/mapper/crypt
/dev/mapper/crypt-root /
/dev/mapper/crypt-home /home
/dev/mapper/crypt-swap [swap]

start by creating required directory tree for initramfs.

# this is the main tree
$ DIR=initramfs/tree
$ VER=5.4.141
$ mkdir -p $DIR/{bin,chroot,dev,etc,lib,proc,run,sbin,sys}
$ mkdir $DIR/{dev/mapper,dev/vc}
$ mkdir $DIR/proc/mounts
$ mkdir $DIR/run/cryptsetup

# for software RAID (if used)
$ mkdir -p $DIR/dev/md

# kernel modules dir
# DAX - direct access for block devices - dependency for dm-mod
# dm-mod - device mapper driver
# dm-crypt - device mapper for encryption/decryption
# hpsa - HP smart array driver - or CCISS on older kernels
# hid-generic - to have a working keyboard on HP HTML5/JAVA remote console

$ mkdir -p $DIR/lib/modules/$VER/kernel/drivers/{dax,hid,md,scsi}

# software raid users
$ mkdir -p $DIR/lib/modules/$VER/kernel/drivers/dm

bin dir should include busybox, cryptsetup and lvm binaries. additionally mdadm if using software raid. either statically build these binaries or include required libraries for them, required libs can be checked with ldd. since building static binaries can take time, i have provided them for download - here.

$ cp /tmp/{busybox,cryptsetup,lvm} $DIR/bin/

chroot dir is where the main rootfs will be mounted.

dev dir will include block devices we need for successfull operation. if making initramfs on same system that will use the initramfs, you may use 'cp -a' method to preserve device major and minor ids, otherwise it is safer to use 'mknod' and change with appropriate. major number identifies driver user, minor identifies a device identification under that driver.

# using 'cp -a', for software RAID include device md0 or whichever is used
$ cp -a /dev/{console,null,random,urandom,sda2} $DIR/dev/


# or using 'mknod', 'c' stands for character device, 'b' for block device
$ mknod -m 666 $DIR/dev/null c 1 3
$ mknod -m 666 $DIR/dev/random c 1 8
$ mknod -m 666 $DIR/dev/urandom c 1 9
$ mknod -m 666 $DIR/dev/sda2 b 8 2
$ mknod -m 666 $DIR/dev/console c 5,1

# make mapper and vc dir, otherwise we will get warnings or errors
$ mkdir $DIR/{mapper,vc}
# and a symbolic link for console 0
$ ln -s ../console $DIR/dev/vc/0

etc contains configuration for software RAID (if used), it is easier to supply RAID array information in mdadm.conf than from the command line

$ cat $DIR/etc/mdadm.conf
ARRAY /dev/md/1 metadata=1.2 UUID=38e6c197:7f64ca70:13bd1d75:44e70864 name=crux:1
ARRAY /dev/md/0 metadata=1.2 UUID=f8aec6e3:fc7cf21c:e12283b5:b50b91ef name=crux:0

lib will include kernel modules mentioned earlier

$ cp /lib/modules/5.4.141/kernel/drivers/dax/dax.ko $DIR/lib/modules/5.4.141/kernel/drivers/dax/
$ cp /lib/modules/5.4.141/kernel/drivers/hid/hid-generic.ko $DIR/lib/modules/5.4.141/kernel/drivers/hid/
$ cp /lib/modules/5.4.141/kernel/drivers/md/{dm-crypt.ko,dm-mod.ko} $DIR/lib/modules/5.4.141/kernel/drivers/md/
$ cp /lib/modules/5.4.141/kernel/drivers/scsi/hpsa.ko $DIR/lib/modules/5.4.141/kernel/drivers/scsi/
# software raid users, note there are raid1.ko, raid0.ko, raid10.ko ..
$ cp /lib/modules/5.4.141/kernel/drivers/dm/{md-mod.ko,dm-crypt.ko} $DIR/lib/modules/5.4.141/kernel/drivers/dm/

proc will contain 'mounts' dir to prevent potential issues with mounting

$ mkdir $DIR/proc/mounts

run will contain 'cryptsetup' dir to avoid warnings with cryptsetup process locking

$ mkdir $DIR/run/cryptsetup

sbin will contain a symlink back to '../init'

$ ln -s ../init $DIR/sbin/init

sys an empty 'sys' directory

$ mkdir $DIR/sys

now the more interesting part, we will be creating an init file that will run required commands to setup everything for rootfs mounting and switching boot process to it

$ cat $DIR/init
--------------
#!/bin/sh
/bin/busybox echo "# mount proc"
/bin/busybox mount -t proc none /proc
/bin/busybox mount -t sysfs none /sys

echo "# load kernel modules"
/bin/busybox modprobe dax
/bin/busybox modprobe dm-mod
/bin/busybox modprobe dm-crypt
/bin/busybox modprobe hid-generic
/bin/busybox modprobe hpsa

# software RAID
#/bin/busybox modprobe md-mod
#/bin/busybox modprobe raid1

/bin/busybox echo "# waiting for devices to settle"
/bin/busybox sleep 10

# software RAID
#/bin/mdadm --assemble --scan || exec /bin/sh

/bin/busybox echo "# open luks partition"
/bin/cryptsetup luksOpen /dev/sda2 crypt || exec /bin/sh

/bin/busybox echo "# assemble logical volumes"
/bin/lvm vgchange -ay || exec /bin/sh
/bin/lvm vgscan --mknodes || exec /bin/sh

# make sure to triple check device or logical volume for mounting, vda, md0 or other
/bin/busybox echo "# mount root volume"
/bin/busybox mount -r /dev/crypt/root /chroot || exec /bin/sh

/bin/busybox echo "# umount proc"
/bin/busybox umount /sys
/bin/busybox umount /proc

/bin/busybox echo "# chroot "
exec /bin/busybox switch_root /chroot /sbin/init $(cat /proc/cmdline)
---------------

symlinks to commands can be made
$ ln -s busybox $DIR/bin/{echo,umount,switch_root,modprobe,mount,sleep}

'|| exec /bin/sh' is used to drop to shell in case something fails to manually inspect, that is why we load hid-generic to support keyboard input

if there is no hpsa.ko, initramfs will not see your disks

$ chmod +x $DIR/init

# and to generate an initramfs
$ echo "find . | cpio -H newc -o > ../initramfs.cpio" >../generate.sh
$ sh ../generate.sh

finally, writing lilo configuration

$ cat /etc/lilo.conf
-------------
lba32
install=text
boot=/dev/sda
# to prompt
#prompt
#timeout=100
# try using if software RAID doesn't boot
#raid-extra-boot=auto
# when using vda or disks using virtio driver
#disk=/dev/vda bios=0x80 max-partitions=7`
image=/boot/vmlinuz
initrd="/boot/initramfs"
label="linux"
read-only
append="quiet lvm luks enc_root=/dev/sda2 root=/dev/crypt/root"
------------

and of course write the bootloader with 'lilo'

Zadnje izmijenjeno od: radi.neradi. 30.04.2024. u 17:48.
radi.neradi je offline   Reply With Quote
Staro 01.05.2024., 14:01   #3182
tomek@vz
Premium
Moj komp
 
tomek@vz's Avatar
 
Datum registracije: May 2006
Lokacija: München/Varaždin
Postovi: 3,359
Citiraj:
Autor radi.neradi Pregled postova
imam jedno pitanje, kakva je razlika kad imam nouveau u kernelu i kakva je poveznica imao ili nemao nouveau firmware u ramdisku?
Ovo me pitanje od tebe iskreno malo iznenadilo s obzirom na to kakve experimente radis. Jednostavan odgovor: nikakve. Ne zamaraj se time jer nemas od toga nikakvog benefita.

Objasnjenje:

Drivere kod kompajliranja Linux kernela mozes dodat kao modul ili integrirat u sam kernel. Cim vise stvari dodas u kernel rezultira vecim kernelom i vecim memory-footprintom kernela sto iskreno u 2024 nije neki zesci problem osim ak vrtis neku specijalnu masinu sa < 1GB RAM. Dok sam vrtio Slackware na Coppermine-u sa 128GB meme pokusao sam kreirat naravno sto manji kernel i sto vise toga implementirat kao modul jer se osjetilo na performansama sustava. Tad je to imalo smisla. E sad - u slucaju da si kreirao minimalisticki kernel mozda ti na novoj masini (ili istoj) treba neki od tih drivera kod boota - inace sustav ne boota. Primjerice: ako si konfigurirao EXT4 driver ako modul moras nekako reci sustavu da taj modul uvijek loada kod boota (u ovom slucaju pre-boot stage). Tu u igru dolazi initrd (sto nije isto kao i klasican ramdisk...bar ne direktno). No u konacnici - dali implementirao driver u sam kernel , ili kao modul - na kraju imas isti memory footprint na tom kernelu na tom stroju ako moras koristiti taj driver. Problemi bi nastali kad bi to htio migrirat na drugu masinu ali necemo na tako siroko.


P.S.- za ekipu - za Boga dragoga i sve kaj je sveto nemojte koristiti Lilo u 2024. Grub2 ga je s razlogom nadomjestio , Lilo je bio OK pred 20 godina kad nije bilo alternative ali tu motiku treba zakopat.

https://www.cainfortexas.com/grub-and-lilo/
tomek@vz je offline   Reply With Quote
Staro 01.05.2024., 15:13   #3183
Dule
Premium
Moj komp
 
Dule's Avatar
 
Datum registracije: Aug 2006
Lokacija: Zagreb, Sesvetski Kraljevec
Postovi: 549
Citiraj:
Autor tomek@vz Pregled postova
P.S.- za ekipu - za Boga dragoga i sve kaj je sveto nemojte koristiti Lilo u 2024. Grub2 ga je s razlogom nadomjestio , Lilo je bio OK pred 20 godina kad nije bilo alternative ali tu motiku treba zakopat. /
*sweats in syslinux*
Dule je offline   Reply With Quote
Staro 01.05.2024., 15:46   #3184
tomek@vz
Premium
Moj komp
 
tomek@vz's Avatar
 
Datum registracije: May 2006
Lokacija: München/Varaždin
Postovi: 3,359
Citiraj:
Autor Dule Pregled postova
*sweats in syslinux*
tomek@vz je offline   Reply With Quote
Staro 02.05.2024., 13:42   #3185
radi.neradi
Registered User
 
Datum registracije: May 2023
Lokacija: Mrkopalj
Postovi: 47
hvala na pojasnjenju i utrosenom vremenu. ovo sto si napisao mi je vec jasno. trazio sam vise tehnickih informacija. procitat cu dokumentaciju i pokusat cu naci binary blobove koje kernel includa i one koji se includaju iz linux-firmware paketa u ramdisk pa vidjet jesu li uopce isti i kako se loadaju. 'ali necemo na tako siroko' - a trebali bi, to nas zanima. :-)

lilo radi i obavlja funkciju, sto mi vise treba od toga. naravno slazem se nije za svaki sistem i svaku primjenu. barem meni osobno je lakse uciti na onome sto je jednostavnije i sto sadrzi manje komponenti. zadnje sam si printao mbr hexdump i lilo bootcode pa analizirao u svrhu ucenja.

peace
radi.neradi je offline   Reply With Quote
Staro 02.05.2024., 16:05   #3186
tomek@vz
Premium
Moj komp
 
tomek@vz's Avatar
 
Datum registracije: May 2006
Lokacija: München/Varaždin
Postovi: 3,359
Citiraj:
Autor radi.neradi Pregled postova
hvala na pojasnjenju i utrosenom vremenu. ovo sto si napisao mi je vec jasno. trazio sam vise tehnickih informacija. procitat cu dokumentaciju i pokusat cu naci binary blobove koje kernel includa i one koji se includaju iz linux-firmware paketa u ramdisk pa vidjet jesu li uopce isti i kako se loadaju. 'ali necemo na tako siroko' - a trebali bi, to nas zanima. :-)

lilo radi i obavlja funkciju, sto mi vise treba od toga. naravno slazem se nije za svaki sistem i svaku primjenu. barem meni osobno je lakse uciti na onome sto je jednostavnije i sto sadrzi manje komponenti. zadnje sam si printao mbr hexdump i lilo bootcode pa analizirao u svrhu ucenja.

peace

Cijenim volju - ako je kranji cilj hobi upotreba linuxa - go for it. Ali ako mislis ista smislenije radit i negdje upotrijebit to znanje - preporucio bih ti uloziti vrijeme u nesto smislenije. Kolko god volim Slackware i *BSD Unix - vise koristi za ono malo vremena sto imam slobodno mi je bolje ulupat u razumijevanje RHEL/Debian/SLES baziranih rijesenja.
tomek@vz je offline   Reply With Quote
Staro Danas, 07:40   #3187
epvpalucard
Yare Yare Daze
Moj komp
 
epvpalucard's Avatar
 
Datum registracije: Jan 2014
Lokacija: Zagreb
Postovi: 156
Ekipa trebam pomoc,htjeo bih se prebacit sa windows na Linux.

Specs: ● CPU: Ryzen 7 2700x
● MBO: ASUS PRIME B450-PLUS
● RAM: Patriot Viper 3200Mhz 32Gb
● SSD1: 1TB Samsung 980
● SSD2: 500gb Samsung 850 evo
● GPU: MSI RTX 2070 Ventus
● PSU: Seasonic CORE GM 650 Gold
● CASE: Fractal Define 7 XL R2
● OS: Window 10 ltsc x64 edition


Za sada sam.probao debian/kde I Pop OS.Na oba dva Distro I clean installu steka mi os vise nego windows.

Dali netko imam preporuku koji distro da probam ili da jednostavno zamjenim nvidia gpu za amd?
__________________




MAIN RIG
CPU: Ryzen 7 2700x
MBO: ASUS PRIME B450-PLUS
RAM: Patriot Viper 3200Mhz 32Gb
SSD1: 1TB Samsung 980
SSD2: 500gb Samsung 850 evo
GPU: MSI RTX 2070 Ventus
PSU: Seasonic CORE GM 650 Gold
CASE: Fractal Define 7 XL R2
OS: Window 10 PRO x64 edition


NAS
CASE: CM Storm 690 II Advanced
CPU: Intel Core i5-6400
MBO: ASRock H170M PRO4S
RAM: KingstonHyperX Savage 16GB DDR4 2133MHz(2*8)
SDD: Patriot 240GB
HDD.1: Western Digital 3TB WD Red Plus
HDD.2: Western Digital 3TB WD Red Plus
HDD.3: WD Blue 1TB
HDD.4: Toshiba DT01ACA200 2tb
HDD.5: WD RED 4TB
HDD.6: ST3000DM001-1ER166 3TB
HDD.7: ST3000DM001-1ER166 3TB
OS: Debian 12

MISC
KEYBOARD: Keychron V6
MOUSE: Redragon Perdition Pro M901P
HEADSET: RED DRAGON H710
MONITOR 1: AOC 24G2U 24" FHD 144hz 1ms IPS
MONITOR 2: AOC 22V2Q 21.5" 75hz 5ms IPS


epvpalucard je offline   Reply With Quote
Staro Danas, 08:54   #3188
tomek@vz
Premium
Moj komp
 
tomek@vz's Avatar
 
Datum registracije: May 2006
Lokacija: München/Varaždin
Postovi: 3,359
Citiraj:
Autor epvpalucard Pregled postova
Ekipa trebam pomoc,htjeo bih se prebacit sa windows na Linux.

Specs: ● CPU: Ryzen 7 2700x
● MBO: ASUS PRIME B450-PLUS
● RAM: Patriot Viper 3200Mhz 32Gb
● SSD1: 1TB Samsung 980
● SSD2: 500gb Samsung 850 evo
● GPU: MSI RTX 2070 Ventus
● PSU: Seasonic CORE GM 650 Gold
● CASE: Fractal Define 7 XL R2
● OS: Window 10 ltsc x64 edition


Za sada sam.probao debian/kde I Pop OS.Na oba dva Distro I clean installu steka mi os vise nego windows.

Dali netko imam preporuku koji distro da probam ili da jednostavno zamjenim nvidia gpu za amd?

Nisi instalirao nvidia driver. Zato si imao probleme. S obzirom da si apsolutni pocetnik > kreni sa Ubuntu/Kubuntu i prouci tutorial.
tomek@vz je offline   Reply With Quote
Staro Danas, 10:38   #3189
kopija
DIY DILETANT
 
kopija's Avatar
 
Datum registracije: Jan 2009
Lokacija: Čistilište
Postovi: 3,066
Kubuntu je IMHO najbezbolniji prijelaz.
Mislim da čak i po defaultu ima Nvidia driver.
kopija je offline   Reply With Quote
Staro Danas, 12:32   #3190
mkey
Premium
Moj komp
 
Datum registracije: Sep 2018
Lokacija: tu
Postovi: 1,948
Što znači "šteka"?
__________________
Citiraj:
Autor George Carlin
But there’s a reason. There’s a reason. There’s a reason for this, there’s a reason education sucks, and it’s the same reason that it will never, ever, ever be fixed. It’s never gonna get any better. Don’t look for it. Be happy with what you got. Because the owners of this country don't want that. I'm talking about the real owners now, the real owners, the big wealthy business interests that control things and make all the important decisions. Forget the politicians. The politicians are put there to give you the idea that you have freedom of choice. You don't. You have no choice. You have owners. They own you. They own everything. They own all the important land. They own and control the corporations. They’ve long since bought and paid for the senate, the congress, the state houses, the city halls, they got the judges in their back pockets and they own all the big media companies so they control just about all of the news and information you get to hear. They got you by the balls. They spend billions of dollars every year lobbying, lobbying, to get what they want. Well, we know what they want. They want more for themselves and less for everybody else, but I'll tell you what they don’t want: They don’t want a population of citizens capable of critical thinking. They don’t want well informed, well educated people capable of critical thinking. They’re not interested in that. That doesn’t help them. Thats against their interests. Thats right. They don’t want people who are smart enough to sit around a kitchen table to figure out how badly they’re getting f*cked by a system that threw them overboard 30 f*cking years ago. They don’t want that. You know what they want? They want obedient workers. Obedient workers. People who are just smart enough to run the machines and do the paperwork, and just dumb enough to passively accept all these increasingly shittier jobs with the lower pay, the longer hours, the reduced benefits, the end of overtime and the vanishing pension that disappears the minute you go to collect it, and now they’re coming for your Social Security money. They want your retirement money. They want it back so they can give it to their criminal friends on Wall Street, and you know something? They’ll get it. They’ll get it all from you, sooner or later, 'cause they own this f*cking place. It's a big club, and you ain’t in it. You and I are not in the big club. And by the way, it's the same big club they use to beat you over the head with all day long when they tell you what to believe. All day long beating you over the head in their media telling you what to believe, what to think and what to buy. The table is tilted folks. The game is rigged, and nobody seems to notice, nobody seems to care. Good honest hard-working people -- white collar, blue collar, it doesn’t matter what color shirt you have on -- good honest hard-working people continue -- these are people of modest means -- continue to elect these rich c*cksuckers who don’t give a f*ck about them. They don’t give a f*ck about you. They don’t give a f*ck about you. They don't care about you at all -- at all -- at all. And nobody seems to notice, nobody seems to care. That's what the owners count on; the fact that Americans will probably remain willfully ignorant of the big red, white and blue dick that's being jammed up their assholes everyday. Because the owners of this country know the truth: it's called the American Dream, because you have to be asleep to believe it.
mkey je offline   Reply With Quote
Staro Danas, 16:49   #3191
Dule
Premium
Moj komp
 
Dule's Avatar
 
Datum registracije: Aug 2006
Lokacija: Zagreb, Sesvetski Kraljevec
Postovi: 549
Za početnike ja bi preporučio Linux Mint, iz razloga što je po mom mišljenju distribucija sa najmanje mušica out-of-the-box.
Dule je offline   Reply With Quote
Staro Danas, 17:34   #3192
strikoo
Premium
 
strikoo's Avatar
 
Datum registracije: Nov 2004
Lokacija: HR
Postovi: 748
Citiraj:
Autor Dule Pregled postova
Za početnike ja bi preporučio Linux Mint, iz razloga što je po mom mišljenju distribucija sa najmanje mušica out-of-the-box.
+1
strikoo je offline   Reply With Quote
Odgovori



Pravila postanja
Vi ne možete otvarati nove teme
Vi ne možete pisati odgovore
Vi ne možete uploadati priloge
Vi ne možete uređivati svoje poruke

BB code je Uključeno
Smajlići su Uključeno
[IMG] kod je Uključeno
HTML je Isključeno

Idi na