注意:

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

User:Pnoecker/1dollartip

From Funtoo
< User:Pnoecker
Revision as of 11:31, January 5, 2021 by Pnoecker (talk | contribs) (debloat, decruft, initial import, cut the garbage, start alignment with official install/scripts.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

a 1 dollar tip at 15% calculates out to an order of $6.66.

This is the first attempts to declutter area31 and make things more readable, and ditch the extra unneeded hoop jumping while implementing maintainability.

Construction of the environment Funtoo

Get the oficial LiveCD created by Área31 Hackerspace

https://area31.net.br/downloads/iso/funtoo-livecd-area31-5.4.iso

After boot using LiveCD created by Área31 Hackerspace, create and format all partitionsː

root # mkswap /dev/sda2
root # mkfs.ext4 /dev/sda1

Activate swap and mount /mnt/custom directoryː

root # swapon /dev/sda2
root # mkdir -p /mnt/custom ; mount /dev/sda1 /mnt/custom

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

CHROOT

Configure network and use the chroot

root # cp /etc/resolv.conf /mnt/custom/customcd/files/etc/
root # mkdir -p /mnt/custom/customcd/files/var/cache/portage /mnt/custom/portage-chroot
root # mount -o bind /mnt/custom/portage-chroot /mnt/custom/customcd/files/var/cache/portage
root # mkdir -p /mnt/custom/meta-repo /mnt/custom/customcd/files/var/git
root # mount -o bind /mnt/custom/meta-repo/ /mnt/custom/customcd/files/var/git
root # cd /mnt/custom/customcd/files/ ; mount -o bind /proc/ proc ; mount -o bind /sys sys ; mount -o rbind /dev dev
root # chroot /mnt/custom/customcd/files/ /bin/bash

LiveCD configuration into CHROOT

root # . /etc/profile ; cd ; export PS1="(chroot) $PS1"

Update portage tree

root #  ego sync


Get Area31 overlay

Clone repo:

root # mkdir -p /etc/portage/localpatches /mnt/funtoo /var/overlay
root # cd /var/overlay ; git clone https://github.com/area31/area31-ebuilds.git
root # mv area31-ebuilds area31-hackerspace

Configure /etc/portage/repos.conf/overlay-area31-hackerspace.conf

[overlay-area31-hackerspace]
location = /var/overlay/area31-hackerspace
auto-sync = no
priority = 10

configure /mnt/funtoo/portage/make.conf

ACCEPT_LICENSE="*"
FEATURES="-pid-sandbox -network-sandbox -sandbox -usersandbox -ipc-sandbox -selinux -sesandbox -collision-detect -protect-owned assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync multilib-strict news parallel-fetch preserve-libs sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"

DISTDIR="/var/cache/portage/distfiles"
PKGDIR="/var/cache/portage/packages"

VIDEO_CARDS="i915 i965 vmware intel nouveau radeon vesa vmware apm ast cirrus dummy glint i128 i740 mach64 nv r128 rendition s3 savage siliconmotion sisusb tdfx trident via"
INPUT_DEVICES="evdev keyboard mouse synaptics vmmouse"

foobashrc_modules = "localpatch"
LOCALPATCH_OVERLAY="/etc/portage/localpatches"

PAX_MARKINGS="none"

L10N="en"

Update world

root # emerge -uDN @world


Install app-portage/eix

root # emerge app-portage/eix
root # eix-update


Install Area31 ebuild and dependencies to generate LiveCD

root # emerge sys-apps/sysresccd-area31 sys-kernel/linux-firmware
root # rc-update add sysresccd default

Configure hostname

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

hostname="livecd.funtoo"

Configure livecd profile

Remove systemd:

root # epro mix-ins +no-systemd

Install dependencies

Configure useflags:

root # vi /etc/portage/package.use
net-misc/tigervnc drm nls pam server xorgmodule -dri3 -gnutls -java opengl -xinerama
x11-base/xorg-server glamor ipv6 suid udev xorg xvfb
media-sound/pulseaudio X alsa alsa-plugin asyncns bluetooth caps dbus equalizer gdbm glib gnome ipv6 orc qt4 ssl tcpd udev webrtc-aec -doc -gtk -jack -libressl -libsamplerate -lirc -native-headset -neon -ofono-headset -oss -realtime -selinux -sox -system-wide -systemd -test -zeroconf
x11-libs/gtk+ X -abi_x86_32 abi_x86_64 -cups -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_ppc_32 -abi_ppc_64 -abi_s390_32 -abi_s390_64 -abi_x86_64 -abi_x86_x32 -aqua -broadway -cloudprint -colord -examples -introspection -test -vim-syntax -wayland -xinerama
>=app-text/poppler-0.57.0-r1 cairo
sys-block/gparted btrfs dmraid f2fs fat hfs jfs mdadm ntfs policykit reiser4 reiserfs xfs udf cryptsetup
sys-block/parted debug nls readline device-mapper
dev-cpp/gtkmm X
sys-boot/grub binfont device-mapper fonts grub_platforms_efi-64 grub_platforms_pc mount multislot nls themes grub_platforms_efi-32
>=dev-qt/qtgui-5.9.4-r3 egl
www-client/w3m -X
app-editors/vim -X
net-misc/openssh -X
sys-apps/groff -X 
sys-kernel/debian-sources binary custom-cflags
>=media-plugins/alsa-plugins-1.1.7-r1 pulseaudio
sys-apps/smartmontools -daemon
net-misc/ntp -zeroconf
net-dns/bind -berkdb caps idn ipv6 -ldap python ssl threads urandom xml dlz -doc -filter-aaaa -geoip -gost -gssapi -mysql -odbc -postgres -rpz -rrl -sdbldap -static-libs
sys-apps/util-linux tty-helpers
x11-terms/rxvt-unicode blink fading-colors  pixbuf  unicode3 256-color

Compile basic tools:

root # emerge app-admin/cpulimit app-admin/hddtemp app-admin/ide-smart app-admin/lib_users app-admin/mcelog app-admin/passook app-admin/procinfo-ng app-admin/sudo app-admin/syslog-ng app-admin/sysstat app-admin/testdisk app-admin/whowatch app-arch/bzip2 app-arch/cabextract app-arch/cfv app-arch/cpio app-arch/dpkg app-arch/dump app-arch/gzip app-arch/lbzip2 app-arch/libarchive app-arch/lz4 app-arch/lzlib app-arch/lzop app-arch/mt-st app-arch/ncompress app-arch/p7zip app-arch/pigz app-arch/pixz app-arch/plzip app-arch/pxz app-arch/rpm2targz app-arch/rzip app-arch/sharutils app-arch/snappy app-arch/tar app-arch/unrar app-arch/unshield app-arch/unzip app-arch/xz-utils app-arch/zip app-editors/hexcurse app-editors/hexedit app-editors/vim app-editors/zile app-forensics/foremost app-i18n/uchardet app-laptop/radeontool app-misc/screen app-pda/libimobiledevice app-pda/libplist app-pda/libusbmuxd app-portage/cpuid2cpuflags app-portage/foobashrc app-portage/genlop app-shells/zsh app-text/pastebinit app-text/tree app-text/wgetpaste media-sound/alsa-utils net-dns/bind net-dns/bind-tools net-misc/dhcp net-misc/dhcpcd net-misc/iputils net-misc/ntp net-misc/telnet-bsd net-wireless/iw sys-apps/dcfldd sys-apps/hdparm sys-apps/ipmitool sys-apps/ipmiutil sys-apps/iucode_tool sys-apps/lm_sensors sys-apps/lshw sys-apps/rescan-scsi-bus sys-block/mbuffer sys-block/nbd sys-block/open-isns sys-block/parted sys-block/thin-provisioning-tools sys-block/whdd sys-boot/gnu-efi sys-boot/grub:2 sys-boot/lilo sys-firmware/intel-microcode sys-fs/cryptsetup sys-fs/ddrescue sys-fs/fuse sys-fs/lvm2 sys-fs/mdadm sys-fs/ntfs3g sys-libs/gpm sys-power/acpi sys-process/acct sys-process/atop sys-process/audit sys-process/cronbase sys-process/glances sys-process/htop sys-process/iotop sys-process/lsof sys-process/nmon sys-process/vixie-cron net-analyzer/tcpdump net-fs/nfs-utils net-analyzer/netcat net-analyzer/nmap sys-block/partimage net-wireless/wpa_supplicant net-vpn/networkmanager-vpnc net-vpn/networkmanager-openvpn net-misc/networkmanager net-vpn/networkmanager-pptp

Create tftpboot directory:

root # mkdir /tftpboot

Graphic interface

Enable X + audio:

root # epro mix-ins +X +audio

Compile graphic tools:

root # emerge -uDN @world xorg-server net-misc/tigervnc sys-auth/consolekit x11-base/xorg-x11 x11-misc/xvkbd net-ftp/filezilla net-wireless/spectools net-print/boomaga sys-block/gparted x11-terms/xterm www-client/links net-wireless/crackle x11-wm/openbox x11-misc/rofi x11-misc/obconf x11-misc/hsetroot x11-misc/xcompmgr www-client/firefox-bin www-client/elinks x11-misc/urxvt-perls x11-terms/rxvt-unicode

Configure xinitrc:

root # cd /root ; ln -sf /etc/area31/xinitrc .xinitrc
root # touch /etc/area31/xinitrc ; chmod +x /etc/area31/xinitrc
root # vi /etc/area31/xinitrc
root #!/bin/bash
if [ -f /etc/sysconfig/keyboard ]
then
        source /etc/sysconfig/keyboard
        KEYMAP=${XKEYBOARD}

        # The keymap must be listed in the following file:
        # /usr/share/X11/xkb/rules/xorg.lst

        [ $KEYMAP = "azerty" -o $KEYMAP = "01" -o $KEYMAP = "1" ] && KEYMAP="azerty"
        [ $KEYMAP = "be" -o $KEYMAP = "02" -o $KEYMAP = "2" ] && KEYMAP="be"
        [ $KEYMAP = "bg" -o $KEYMAP = "03" -o $KEYMAP = "3" ] && KEYMAP="bg"
        [ $KEYMAP = "br-a" -o $KEYMAP = "04" -o $KEYMAP = "4" ] && KEYMAP="br"
        [ $KEYMAP = "br-abnt2" -o $KEYMAP = "04" -o $KEYMAP = "4" ] && KEYMAP="br"
        [ $KEYMAP = "br-l" -o $KEYMAP = "05" -o $KEYMAP = "5" ] && KEYMAP="br"
        [ $KEYMAP = "by" -o $KEYMAP = "06" -o $KEYMAP = "6" ] && KEYMAP="by"
        [ $KEYMAP = "cf" -o $KEYMAP = "07" -o $KEYMAP = "7" ] && KEYMAP="cf"
        [ $KEYMAP = "croat" -o $KEYMAP = "08" -o $KEYMAP = "8" ] && KEYMAP="hr"
        [ $KEYMAP = "cz" -o $KEYMAP = "09" -o $KEYMAP = "9" ] && KEYMAP="cz"
        [ $KEYMAP = "de" -o $KEYMAP = "10" ] && KEYMAP="de"
        [ $KEYMAP = "dk" -o $KEYMAP = "11" ] && KEYMAP="dk"
        [ $KEYMAP = "dvorak" -o $KEYMAP = "12" ] && KEYMAP="dvorak"
        [ $KEYMAP = "es" -o $KEYMAP = "13" ] && KEYMAP="es"
        [ $KEYMAP = "et" -o $KEYMAP = "14" ] && KEYMAP="et"
        [ $KEYMAP = "fi" -o $KEYMAP = "15" ] && KEYMAP="fi"
        [ $KEYMAP = "fr" -o $KEYMAP = "16" ] && KEYMAP="fr"
        [ $KEYMAP = "gr" -o $KEYMAP = "17" ] && KEYMAP="gr"
        [ $KEYMAP = "hu" -o $KEYMAP = "18" ] && KEYMAP="hu"
        [ $KEYMAP = "il" -o $KEYMAP = "19" ] && KEYMAP="il"
        [ $KEYMAP = "is" -o $KEYMAP = "20" ] && KEYMAP="is"
        [ $KEYMAP = "it" -o $KEYMAP = "21" ] && KEYMAP="it"
        [ $KEYMAP = "jp" -o $KEYMAP = "22" ] && KEYMAP="jp"
        [ $KEYMAP = "la" -o $KEYMAP = "23" ] && KEYMAP="latam"
        [ $KEYMAP = "lt" -o $KEYMAP = "24" ] && KEYMAP="lt"
        [ $KEYMAP = "mk" -o $KEYMAP = "25" ] && KEYMAP="mk"
        [ $KEYMAP = "nl" -o $KEYMAP = "26" ] && KEYMAP="nl"
        [ $KEYMAP = "no" -o $KEYMAP = "27" ] && KEYMAP="no"
        [ $KEYMAP = "pl" -o $KEYMAP = "28" ] && KEYMAP="pl"
        [ $KEYMAP = "pt" -o $KEYMAP = "29" ] && KEYMAP="pt"
        [ $KEYMAP = "ro" -o $KEYMAP = "30" ] && KEYMAP="ro"
        [ $KEYMAP = "ru" -o $KEYMAP = "31" ] && KEYMAP="us,ru(winkeys) -option grp:ctrl_shift_toggle,lctrl_shift_toggle"
        [ $KEYMAP = "se" -o $KEYMAP = "32" ] && KEYMAP="se"
        [ $KEYMAP = "sg" -o $KEYMAP = "33" ] && KEYMAP="sg"
        [ $KEYMAP = "sk-y" -o $KEYMAP = "34" ] && KEYMAP="sk"
        [ $KEYMAP = "sk-z" -o $KEYMAP = "35" ] && KEYMAP="sk"
        [ $KEYMAP = "slovene" -o $KEYMAP = "36" ] && KEYMAP="si"
        [ $KEYMAP = "trf" -o $KEYMAP = "37" ] && KEYMAP="tr"
        [ $KEYMAP = "trq" -o $KEYMAP = "38" ] && KEYMAP="tr"
        [ $KEYMAP = "ua" -o $KEYMAP = "39" ] && KEYMAP="ua"
        [ $KEYMAP = "uk" -o $KEYMAP = "40" ] && KEYMAP="gb"
        [ $KEYMAP = "us" -o $KEYMAP = "41" ] && KEYMAP="us"
        [ $KEYMAP = "wangbe" -o $KEYMAP = "42" ] && KEYMAP="wangbe"
        [ $KEYMAP = "fr_CH" -o $KEYMAP = "43" ] && KEYMAP="ch -variant fr"
        [ $KEYMAP = "speakup" -o $KEYMAP = "44" ] && KEYMAP="us"
        [ $KEYMAP = "cz" -o $KEYMAP = "45" ] && KEYMAP="cz"
        [ $KEYMAP = "de_CH" -o $KEYMAP = "46" ] && KEYMAP="ch"
        [ $KEYMAP = "sg-lat1" -o $KEYMAP = "47" ] && KEYMAP="ch" 
        [ $KEYMAP = "fr-bepo" -o $KEYMAP = "48" ] && KEYMAP="fr bepo"
        [ $KEYMAP = "colemak" -o $KEYMAP = "49" ] && KEYMAP="us -variant colemak"
        [ $KEYMAP = "de_neo" -o $KEYMAP = "50" ] && KEYMAP="de -variant neo"

        echo "setxkbmap -layout $KEYMAP" > /var/log/xorg-keymap.log
        setxkbmap -layout $KEYMAP >> /var/log/xorg-keymap.log 2>&1
    fi
[ -f /usr/bin/xset ] && /usr/bin/xset s off >/dev/null 2>&1 &
[ -f /usr/bin/xset ] && /usr/bin/xset r >/dev/null 2>&1 &

if [ -z "$DESKTOP_SESSION" -a -x /usr/bin/ck-launch-session ]; then
        exec ck-launch-session dbus-launch --sh-syntax --exit-with-session startlxde
else
        exec dbus-launch --exit-with-session startlxde
fi

Adjust various services on boot

Just run:

root # bash /usr/sbin/sysresccd-area31-setservices

Enable Local Patches to Ebuilds:

root # ln -s /etc/portage/foobashrc.bashrc /etc/portage/bashrc

Compile kernel

Configure ebuild

root # emerge sys-kernel/debian-sources

Configure fstab

Clear fstab:

root # echo '# Funtoo LiveCD fstab' > /etc/fstab

Configure automatic login [RECOMMENDED]

Make script bashlogin

root # touch /bin/bashlogin ; chmod +x /bin/bashlogin ; vi /bin/bashlogin

With the following content:

   /bin/bashlogin
#!/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

Configure inittab

root # vi /etc/inittab

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


root # TERMINALS
c1:12345:respawn:/sbin/agetty -nl /bin/bashlogin 38400 tty1 linux
c2:12345:respawn:/sbin/agetty -nl /bin/bashlogin 38400 tty2 linux
c3:12345:respawn:/sbin/agetty -nl /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 '/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
root #!/bin/sh
root # ============ 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

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

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

LINES=$(stty size

Install aditional locales [OPTIONAL]

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

Enable date and time on history

Add these lines on /etc/profile

export HISTTIMEFORMAT="%h/%d %H:%M:%S "
export HISTFILESIZE="1000000"
export HISTSIZE="1000000"

Exit from CHROOT

root # exit

Prepare the iso environment (Kernel + GRUB)

Download and extract the required files:

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


Prepare initram

Make backup:

root # cd /mnt/custom/customcd
root # tar cpf isoroot-bkp.tar isoroot

Configure initram created by Área31 Hackerspace

Get latest initram from Área31 Hackerspace:

root # mkdir -p /usr/src/initramfs
root # cd /usr/src/initramfs
root # rm /mnt/custom/customcd/isoroot/isolinux/initram.igz
root # wget https://area31.net.br/downloads/releases/initram-ara31-overlayfs-5.0.igz -O /usr/src/initram.igz

Unpack initram created by Área31 Hackerspace:

root # cat /usr/src/initram.igz | xz -d | cpio -id

Or unpack initram from LiveCD:

root # cat /livemnt/boot/isolinux/initram.igz | xz -d | cpio -id

Copy modules from kernel to initram

root # cp -rp /mnt/custom/customcd/files/lib/modules/* lib/modules


Repack initram

root # rm -f /usr/src/initram.igz
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/isolinux/initram.igz
root # cp /mnt/custom/customcd/files/boot/kernel-debian-sources* /mnt/custom/customcd/isoroot/isolinux/rescue64
root # mkdir -p /mnt/custom/customcd/isoroot/boot/EFI/BOOT /mnt/custom/customcd/isoroot/efi/boot
root # cp /mnt/custom/customcd/isoroot/efi/bootx64.efi /mnt/custom/customcd/isoroot/boot/EFI/BOOT/bootx64.efi
root # cp /mnt/custom/customcd/isoroot/efi/bootx64.efi /mnt/custom/customcd/isoroot/efi/boot

Remove temporary files and umount /proc, /dev, /sys

root # rm -rf /mnt/custom/customcd/files/usr/src/* /mnt/custom/customcd/files/var/tmp/portage
root # cd / ; umount /mnt/custom/customcd/files/var/cache/portage /mnt/custom/customcd/files/var/git
root # cd /mnt/custom/customcd/files/ ; umount proc sys
root # umount -l dev ; cd

Make iso file

root # sh /usr/share/sysresccd-area31/sysresccd-area31-targets make-iso

Get new iso funtoo

ISOs are always generated in the same directory:

/mnt/custom/customcd/isofile

Plug in the USB stick

Just make sure the USB stick has been plugged in, and wait a few seconds to be sure the device has been detected by the system.

Execute the installer

Now you just have to execute the installation script which is at the root of the CD-ROM. This script requires several commands to run but it won't be a problem. To be sure the script will always work, these commands are part of the CD-ROM:

root # cd /tmp/cdrom
root # bash ./usb_inst.sh

Unmount the ISO image

Now you can unmount the ISO image

root # cd ~
root # umount /tmp/cdrom