Difference between revisions of "Funtoo:New Install Experience/LiveCD page"

From Funtoo
Jump to navigation Jump to search
Line 111: Line 111:




== Configure automatic login [RECOMMENDED] ==
== Configure automatic login ==
===Make script bashlogin===
===Install script bashlogin===
 
{{console|body=
{{console|body=
###i## touch /bin/bashlogin ; chmod +x /bin/bashlogin ; vi /bin/bashlogin
###i## emerge sys-apps/livecd-funtoo-scripts
}}
 
With the following content:
 
{{file|name=/bin/bashlogin|body=
#!/bin/sh
# ============ ENV VARS ================================
cd /root
export LANG=en_US.UTF-8
export HOME=/root
export SHELL=/bin/bash
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export MAIL=/var/mail/root
export USER=root
 
source /etc/profile
 
# ============ PRINT MESSAGE ===========================
lc1='\e[01;31m' # light red
dc1='\e[00;31m' # dark red
lc2='\e[01;37m' # white
dc2='\e[00;37m' # gray
 
# fix broken console with utf8 in the alternative-kernels
echo -n -e '\033%G'
kbd_mode -u
 
LINES=$(stty size{{!}}cut -d" " -f1)
fbecho()
{
  [ $LINES -ge 28 ] && echo
}
 
# ============ SHELL PROMPT ============================
exec $SHELL --login
}}
}}


Line 163: Line 127:
{{file|name=/etc/inittab|body=
{{file|name=/etc/inittab|body=
# TERMINALS
# TERMINALS
c1:12345:respawn:/sbin/agetty -nl /bin/bashlogin 38400 tty1 linux
c1:12345:respawn:/sbin/agetty -nl /usr/bin/bashlogin 38400 tty1 linux
c2:12345:respawn:/sbin/agetty -nl /bin/bashlogin 38400 tty2 linux
c2:12345:respawn:/sbin/agetty -nl /usr/bin/bashlogin 38400 tty2 linux
c3:12345:respawn:/sbin/agetty -nl /bin/bashlogin 38400 tty3 linux
c3:12345:respawn:/sbin/agetty -nl /usr/bin/bashlogin 38400 tty3 linux
c4:12345:respawn:/sbin/agetty --noclear 38400 tty4 linux
c4:12345:respawn:/sbin/agetty --noclear 38400 tty4 linux
c5:2345:respawn:/sbin/agetty 38400 tty5 linux
c5:2345:respawn:/sbin/agetty 38400 tty5 linux
Line 185: Line 149:


{{console|body=
{{console|body=
###i## echo '/bin/bashlogin-banner' >> /etc/bash/bashrc
###i## echo '/usr/bin/bashlogin-banner' >> /etc/bash/bashrc
}}
}}



Revision as of 18:05, May 13, 2022

This tutorial explains Howto build your own LiveCD Funtoo Linux using oficial stage3. After configure the new system using CHROOT, just burn the new ISO file, using the official Área31 Hackerspace tool.

The LiveCD Funtoo Linux, basically a system recovery disk, available as a bootable DVD or USB device to administer or repair your system after an accident. Your goal is to provide an easy way to perform administrative tasks on your computer, such as repairing, creating, and editing your hard disk partitions. It comes with a lot of Open Source software such as system tools (parted, partimage, photorec, foremost, dcfldd, ddrescue, hdparm, and others) and basic tools (editors, browsers, network tools). The LiveCD can be used for both Linux, Mac OS and Windows computers, as well as desktops or servers. This LiveCD does not require installation as it can be booted from a DVD drive or USB device. The kernel supports the most commonly used file systems (ext2 / ext3 / ext4, ReiserFS, Btrfs, XFS, JFS, VFAT, NTFS via ntfs-3g) as well as network file systems (Samba and NFS) encrypted (LUKS).

   Warning

It is highly recommended to create a new separate partition on your system, to store the /mnt/custom directory data

Mount /mnt/custom directory (optional)ː

root # mkdir -p /mnt/custom ; mount /dev/sdb1 /mnt/custom


Emerge on your host funtoo system tools for cd mastering:

root # emerge cdrtools squashfs-tools isomaster libisoburn mtools


Get and extract stage3 (64bits) from https://www.funtoo.org/Generic_64 ː

root # wget https://build.funtoo.org/1.4-release-std/x86-64bit/generic_64/stage3-latest.tar.xz -P /mnt/custom
root # mkdir -p /mnt/custom/customcd/files ; tar xpf /mnt/custom/stage3-latest.tar.xz -C /mnt/custom/customcd/files


Create some directories to mount them as bind, to keep the livecd directory as clean as possible:

root # mkdir -p /mnt/custom/customcd/files/var/cache/portage /mnt/custom/portage-chroot
root # mkdir -p /mnt/custom/meta-repo /mnt/custom/customcd/files/var/git
root # rm -rf /mnt/custom/customcd/files/usr/src ; mkdir -p /mnt/custom/kernel-usr-src /mnt/custom/customcd/files/usr/src
root # mount -o bind /mnt/custom/portage-chroot /mnt/custom/customcd/files/var/cache/portage
root # mount -o bind /mnt/custom/meta-repo/ /mnt/custom/customcd/files/var/git
root # mount -o bind /mnt/custom/kernel-usr-src /mnt/custom/customcd/files/usr/src
root # cd /mnt/custom/customcd/files/ ; mount -o bind /proc/ proc ; mount -o bind /sys sys ; mount -o rbind /dev dev


Into CHROOT

Configure network and use the chroot

root # cp /etc/resolv.conf /mnt/custom/customcd/files/etc/
root # chroot /mnt/custom/customcd/files/ /bin/bash


LiveCD configuration into CHROOT

Update portage tree

root #  ego sync


Update world

root # emerge -uDN @world


Configure livecd profile

Remove systemd:

root # epro mix-ins +no-systemd

Configure useflags

root # echo '>=media-libs/gd-2.3.0 fontconfig truetype png jpeg' >> /etc/portage/package.use
root # echo 'sys-boot/grub **' >> /etc/portage/package.accept_keywords
root # echo 'sys-apps/openrc **' >> /etc/portage/package.accept_keywords
root # echo '=sys-apps/openrc-0.41.2-r4' >> /etc/portage/package.mask

Emerge essential ebuilds

root # emerge sys-kernel/linux-firmware app-misc/livecd-tools app-admin/testdisk app-arch/unrar app-arch/zip app-backup/fsarchiver app-editors/hexcurse app-editors/hexedit app-editors/joe app-editors/vim app-editors/zile app-misc/jq app-portage/genlop dev-libs/libxml2 net-analyzer/netcat net-analyzer/nmap net-analyzer/tcpdump net-dns/bind-tools net-misc/networkmanager net-misc/telnet-bsd sys-apps/fchroot sys-apps/haveged sys-apps/iucode_tool sys-block/parted sys-boot/grub sys-boot/syslinux sys-firmware/intel-microcode sys-fs/btrfs-progs sys-fs/cryptsetup sys-fs/ddrescue sys-fs/dfc sys-fs/f2fs-tools sys-fs/ntfs3g sys-fs/zfs sys-kernel/debian-sources sys-kernel/linux-firmware sys-process/htop www-client/elinks www-client/links www-client/w3m app-crypt/chntpw

Configure fstab

root # echo '# Funtoo LiveCD fstab' > /etc/fstab
root # echo 'tmpfs   /                                       tmpfs   defaults        0 0' >> /etc/fstab


Configure hostname

Edit /etc/conf.d/hostname and insert:

hostname="livecd.funtoo"

Set root password and permit login using SSH

root # echo -e "root\nroot" | passwd root
root # echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config


Include essential services on boot

root # rc-update add NetworkManager sysinit
root # rc-update add autoconfig default
root # rc-update add haveged default
root # rc-update add sshd default
root # rc-update add fixinittab default


Configure automatic login

Install script bashlogin

root # emerge sys-apps/livecd-funtoo-scripts


Configure inittab

root # vi /etc/inittab

Change the lines below the comment '# TERMINALS' 'to the following pattern:

   /etc/inittab
# TERMINALS
c1:12345:respawn:/sbin/agetty -nl /usr/bin/bashlogin 38400 tty1 linux
c2:12345:respawn:/sbin/agetty -nl /usr/bin/bashlogin 38400 tty2 linux
c3:12345:respawn:/sbin/agetty -nl /usr/bin/bashlogin 38400 tty3 linux
c4:12345:respawn:/sbin/agetty --noclear 38400 tty4 linux
c5:2345:respawn:/sbin/agetty 38400 tty5 linux
c6:2345:respawn:/sbin/agetty 38400 tty6 linux

That way we will automatically log in to TTY's from 1 to 3.


Configure Time Zone

Configure to UTCː

root # ln -sf /usr/share/zoneinfo/UTC /etc/localtime

Make automatic post-login banner [OPTIONAL]

Include banner on /etc/bash/bashrc:

root # echo '/usr/bin/bashlogin-banner' >> /etc/bash/bashrc

Create the script with the following content:

root # touch /bin/bashlogin-banner ; chmod +x /bin/bashlogin-banner ; vi /bin/bashlogin-banner
   /bin/bashlogin-banner
#!/bin/sh
# ============ ENV VARS ================================
cd /root
export LANG=en_US.UTF-8
export HOME=/root
export SHELL=/bin/bash
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export MAIL=/var/mail/root
export USER=root

source /etc/profile

# ============ PRINT MESSAGE ===========================
lc1='\e[01;31m' # light red
dc1='\e[00;94m' # light blue
lc2='\e[01;37m' # white
dc2='\e[00;37m' # gray

# fix broken console with utf8 in the alternative-kernels
echo -n -e '\033%G'
kbd_mode -u

LINES=$(stty size|cut -d" " -f1)
fbecho() 
{
  [ $LINES -ge 28 ] && echo
}

VERSION="7.0"

fbecho
echo -e "${lc1} =========== ${lc2}Funtoo LiveCD ${lc1} ----- ${dc1} ${VERSION} ${lc1} =========== ${lc2}$(basename $(tty))${dc2}/6 ${lc1}=="
echo -e "              ${dc1}https://www.funtoo.org${dc2}"
echo
echo -e "${dc1}*${lc1} Network${dc2}: NetworkManager${dc2}"
echo -e "${dc1}OBS:${dc2} If you want to manually configure the Network card, first stop NetworkManager service:"
echo -e "   ${dc1}-${dc2} ${lc2}rc-service NetworkManager stop${dc2} (recommended using static IP configuration)"
echo -e "   ${dc1}-${dc2} ${lc2}ifconfig eth0 192.168.x.a${dc2} (static IP)"
echo -e "   ${dc1}-${dc2} ${lc2}route add default gw 192.168.x.b${dc2} (Gateway default)"
echo -e "${dc1}Optional:${dc2} If you prefer, type ${lc2}net-setup eth0${dc2} to configure network."
fbecho
echo -e "${dc1}*${lc1} Available Text Editors${lc2}: vim${dc2}, ${lc2}vi${dc2}, ${lc2}nano${dc2}, ${lc2}zile${dc2}, ${lc2}joe${dc2}"
echo -e "${dc1}*${lc1} Available HEX Editors: ${lc2}hexcurse${dc2}, ${lc2}hexedit${dc2}\n"
echo -e "${dc1}*${lc1} Web browsers CLI: ${lc2}elinks${dc2}, ${lc2}w3m${dc2}, ${lc2}links${dc2}"
echo -e "   ${dc1}-${dc2} ${lc2}w3m https://www.funtoo.org${dc2}"
fbecho
echo -e "${dc1}*${lc1} Ntfs-3g${dc2}: If you need write on disk using NTFS, try Ntfs-3g."
echo -e "   Mount disk using ntfs-3g: ${lc2}ntfs-3g /dev/sda1 /mnt/windows${dc2}\n"
fbecho
if [ -f /usr/bin/Xorg ]
then
        echo -e "${dc1}*${lc1} Graphic interface${dc2}: "
        echo -e "   Type ${lc2}startx${dc2} to start graphic interface"
        echo -e "   ${dc1}-${dc2} Partition manager:..${lc2}gparted${dc2}"
        echo -e "   ${dc1}-${dc2} Web browsers:.......${lc2}firefox-bin${dc2}"
        #echo -e "   ${dc1}-${dc2} Graphic Text Editor:.......${lc2}gvim${dc2} e ${lc2}geany${dc2}\n"
        echo -e "${dc1}*${lc1} Tools${dc2}: "
        echo -e "   ${dc1}-${dc2} Diagnostic: ${lc2}glances${dc2}, ${lc2}htop${dc2}, ${lc2}whdd${dc2}, ${lc2}hdparm${dc2}, ${lc2}iostat${dc2}, ${lc2}iotop${dc2}, ${lc2}lsof${dc2}"
        echo -e "   ${dc1}-${dc2} Forensic / Recover: ${lc2}photorec${dc2}, ${lc2}foremost${dc2}, ${lc2}dcfldd${dc2}, ${lc2}ddrescue${dc2}"
        echo -e "\n${lc1} ==================================================================================${lc2}"
echo -e "   Default password for root is ${lc2}root${dc2}. To change the root password, type: ${lc2}passwd${dc2}"
echo -e "   Default password for VNC is ${lc2}funtoo${dc2}. To access using VNC please connect to port ${lc2}5901${dc2}"
        echo -e "\n   Funtoo LiveCD ${lc1}(64bit)${lc2}Created by Funtoo Core Team${dc1}\n                                   \n\n${dc2}Have a lot of fun..${dc2}"
fbecho
fi
fbecho


Install aditional locales [OPTIONAL]

root # echo 'pt_BR.UTF-8 UTF-8' >> /etc/locale.gen
root # locale-gen


Exit from CHROOT

root # exit


Out of CHROOT

Isoroot

Get and extract Funtoo isoroot:

root # wget https://area31.net.br/downloads/ebuilds/releases/isoroot-livecd-funtoo-7.0.tar.bz2 -P /mnt/custom
root # tar xjpf /mnt/custom/isoroot-livecd-funtoo-7.0.tar.bz2 -C /mnt/custom/customcd


Initramfs

Unpack initram Funtoo:

root # mkdir /usr/src/initramfs ; cd /usr/src/initramfs
root # cat /mnt/custom/customcd/isoroot/boot/funtoo.igz | xz -d | cpio -id


Copy kernel modules and firmwares into initram:

root # cp -rp /mnt/custom/customcd/files/lib/modules/* /usr/src/initramfs/lib/modules
root # cp -rp /mnt/custom/customcd/files/lib/firmware /usr/src/initramfs/lib


Repack initram Funtoo:

root # cd /usr/src/initramfs
root # find . | cpio -H newc -o | xz --check=crc32 --x86 --lzma2 > /usr/src/initram.igz


Copy new initram and kernel to isoroot dir

root # cp /usr/src/initram.igz /mnt/custom/customcd/isoroot/boot/funtoo.igz
root # cp /mnt/custom/customcd/files/boot/kernel-debian-sources* /mnt/custom/customcd/isoroot/boot/gentoo


Remove temporary files

root # rm -rf /mnt/custom/customcd/files/var/cache/portage/distfiles/*
root # rm -rf /mnt/custom/customcd/files/var/tmp/portage/*
root # rm -rf /mnt/custom/customcd/files/root/nohup.* /mnt/custom/customcd/files/root/.bash_history /mnt/custom/customcd/files/root/.viminfo /mnt/custom/customcd/files/root/.bash_history
root # rm -rf /mnt/custom/customcd/files/var/log/messages /mnt/custom/customcd/files/var/log/wtmp /mnt/custom/customcd/files/var/log/Xorg.0.log* /mnt/custom/customcd/files/var/log/dmesg /mnt/custom/customcd/files/var/log/rc.log
root # rm -rf /mnt/custom/customcd/files/etc/ssh/*key*
root # rm -rf /mnt/custom/customcd/files/root/.gitconfig
root # mkdir -p /mnt/custom/customcd/files/root/.ssh
root # rm -rf /mnt/custom/customcd/files/etc/skel
root # cp -rp /mnt/custom/customcd/files/root /mnt/custom/customcd/files/etc/skel
root # rm -rf /mnt/custom/customcd/files/tmp
root # mkdir /mnt/custom/customcd/files/tmp
root # chmod 777 /mnt/custom/customcd/files/tmp


umount /proc, /dev, /sys and others partitions

root # umount -v /mnt/custom/customcd/files/proc /mnt/custom/customcd/files/sys /mnt/custom/customcd/files/var/cache/portage /mnt/custom/customcd/files/var/git /mnt/custom/customcd/files/usr/src
root # umount -lv /mnt/custom/customcd/files/dev

Create squashfs

root # touch "/mnt/custom/customcd/files/customized"
root # touch "/mnt/custom/customcd/isoroot/customized"
root # mksquashfs /mnt/custom/customcd/files/ /mnt/custom/customcd/isoroot/image.squashfs
root # cd /mnt/custom/customcd/isoroot/ ; md5sum image.squashfs > image.squashfs.md5
root # chmod 666 /mnt/custom/customcd/isoroot/image.{squashfs,md5}


Create ISO image

root # mkdir -p /mnt/custom/customcd/isofile
root # xorriso -as mkisofs -joliet -rock -omit-version-number -disable-deep-relocation -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e EFI/BOOT/BOOTX64.EFI -no-emul-boot -o /mnt/custom/customcd/isofile/funtoo-livecd-$(date +%Y%m%d-%H%M).iso -volid funtoo-livecd /mnt/custom/customcd/isoroot


Get new iso funtoo

ISOs are always generated in the same directory:

/mnt/custom/customcd/isofile