Tuesday 28 April 2020

Kernel Build, Installation from Source, Disk Encryption

Kernel Build from Source


Download latest stable kernel source files from kernel.org



# unxz linux-5.6.7.tar.xz
# tar zxvf linux-5.6.7.tar
# cd linux-5.6.7
# yum group install "Development Tools"
#yum install openssl-devel

for Debian use
# apt-get install build-essential libncurses-dev bison flex libssl-dev libelf-dev



# cp -v /boot/confing-$(uname -r) .config
# make menuconfig 
make required selection and save .config



#make
Compiles source files will take lot of time
After compilation install kernel modules using

# make module_install
After installation of kernel modules install new kernel using


#make install

you will find given files
initramfs-5.6.7.img system.map-5.6.7 vmlinuz-5.6.7 in /boot

update /boot/grub2/grub.cfg using
# grub2-mkconfig -o /boot/grub2/grub.cfg
# grubby --set-default /boot/vmlinux-5.6.7
# grubby --default-index
# grubby --default-kernel
# grubby --info=ALL

for Debian use
# update-initramfs -c -k 5.6.7
# update-grub

#reboot
-------------------------------------------------------------------------------
centos - mkinitrd is a wrapper which calls dracut to generate initramfs image
debian - mkiniramfs to generate initramfs image

 mkinitrd -f -v /boot/initramfs-$(uname -r).img $(uname -r)
dracut foo.img

mkinitramfs -o  /tmp/initramfs-$(uname -r).img
cpio -i < /tmp/initramfs-$(uname -r).img

udevadm monitor

-------------------------------------------------------------------------------



Installing  software from source



Download source file, extract, and goto directory

cd Python-3.8.0
./configure --enable-optimizations
make -j 8 (compiling as per host system)
sudo make altinstall (installing the software. altinstall mean it will not overwrite existing software)
python3.8 --version

for debian
/etc/apt/source.list
example
deb http://archive.defbian.org/debain/ main non-free contrib
deb http://archive.debian.org/debian/   wheezy  main    non-free        contrib
# Line commented out by installer because it failed to verify:
deb http://archive.debian.org/debian-security/ wheezy/updates main non-free contrib

update-alternatives --config x-session-manager
dpkg-reconfigure gdm


Disk Encryption in Linux
cryptsetup -y -v luksFormat /dev/sdb
cryptsetup luksOpen /dev/sdb backup
ls -la /dev/mapper/backup
cryptsetup -v status backup
dd if=/dev/zero of=/dev/mapper/backup
mkfs.ext4 /dev/mapper/backup
mkdir /backup
mount /dev/mapper/backup /backup/
umount /backup
cryptsetup  luksClose backup
cryptsetup luksOpen /dev/sdb backup
Enter passphrase for /dev/sdb:
mount /dev/mapper/backup /backup/

Bye...