Make your own RescueCD based on Funtoo Linux 1.3 prime
This tutorial explains howto build your own RescueCD, no need for a Linux installed on disk for that. After configuring the new system, just burn the new ISO file, using the official Área31 Hackerspace tool.
A virtual machine is strongly recommended for this procedure, including for security reasons
you need to boot with a 64bit kernel. Funtoo Linux 1.3 remove any 32-bit compatibility on your system.
Construction of the environment Funtoo
Get the RescueCD from Area31
https://www.area31.net.br/wiki/RescueCD_oficial
After boot using RescueCD from Area31, 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 ː
Ex:
root # wget https://build.funtoo.org/1.3-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
RescueCD 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 /etc/portage/make.conf
########################################################################### ## ATTENTION: THIS IS THE MAKE.CONF ON THE LIVECD ## ## PLEASE EDIT /mnt/custom/customcd/files/etc/portage/make.conf INSTEAD ## ########################################################################### #MAKEOPTS="-j5" #PORTAGE_NICENESS="19" ACCEPT_LICENSE="*" FEATURES="-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"
Remove debian-sources and update world
root # emerge -C sys-kernel/debian-sources-lts root # emerge -auDN @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 app-misc/livecd-tools sys-kernel/linux-firmware root # rc-update add sysresccd default
Configure livecd profile
Remove systemd and include others mix-ins:
root # epro mix-ins +no-systemd +lxqt +X +audio
Install dependencies
Configure useflags:
root # vi /etc/portage/package.use
sys-fs/lvm2 readline static thin udev net-misc/networkmanager dhclient modemmanager ncurses nss ppp resolvconf wext wifi elogind -consolekit net-misc/tigervnc drm nls pam server xorgmodule -dri3 -gnutls -java opengl -xinerama x11-base/xorg-server glamor ipv6 suid udev xorg xvfb media-libs/mesa classic dri3 egl gallium gbm llvm nptl video_cards_i915 video_cards_i965 video_cards_intel video_cards_nouveau video_cards_radeon video_cards_vmware xa media-libs/libepoxy X dev-libs/glib dbus mime xattr sys-kernel/aufs-sources symlink xfce-base/xfce4-meta mixer ristretto svg terminal thunar thunar-volman tumbler xfburn 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 x11-libs/cairo X glib svg xcb >=app-text/poppler-0.57.0-r1 cairo dev-cpp/cairomm X x11-libs/gdk-pixbuf X x11-libs/libxkbcommon X kde-frameworks/kwindowsystem X x11-libs/pango X 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-32 grub_platforms_pc mount multislot nls themes -grub_platforms_efi-64 lxqt-base/lxqt-meta about filemanager icons oxygen policykit admin -lightdm lximage -minimal powermanagement -sddm -ssh-askpass -sudo >=dev-qt/qtgui-5.9.4-r3 egl gnome-base/gvfs bluray cdda dnssd elogind http ios mtp udev udisks www-client/w3m -X app-editors/vim -X
Compile basic tools:
root # emerge sys-apps/rescan-scsi-bus net-misc/dhcpcd media-sound/alsa-utils net-misc/dhcp sys-fs/mdadm sys-fs/lvm2 app-editors/vim sys-fs/cryptsetup sys-libs/gpm app-portage/genlop app-portage/foobashrc app-portage/cpuid2cpuflags sys-process/htop sys-process/acct sys-process/atop sys-process/audit sys-process/cronbase sys-process/glances sys-process/iotop sys-process/lsof sys-process/nmon sys-process/vixie-cron sys-fs/ntfs3g app-editors/hexcurse app-editors/hexedit app-editors/joe sys-fs/fuse app-editors/zile sys-boot/grub-static sys-boot/grub:2 net-misc/telnet-bsd net-misc/iputils sys-apps/lshw app-arch/lz4 app-arch/unrar app-arch/p7zip app-arch/sharutils app-arch/snappy app-arch/dpkg sys-apps/ipmitool sys-apps/ipmiutil app-misc/screen sys-power/acpi sys-boot/lilo sys-boot/gnu-efi sys-block/thin-provisioning-tools sys-block/parted sys-block/open-isns sys-block/nbd sys-block/mbuffer net-wireless/iw app-shells/zsh app-text/wgetpaste app-text/pastebinit app-text/tree app-admin/syslog-ng
Compile graphic tools:
root # emerge net-misc/tigervnc sys-auth/consolekit lxqt-base/lxqt-meta x11-base/xorg-x11 x11-misc/xvkbd app-text/evince www-client/elinks www-plugins/adobe-flash net-ftp/filezilla net-wireless/spectools lxde-base/lxterminal net-print/boomaga sys-block/gparted net-wireless/bluez x11-terms/xterm www-client/links net-wireless/wpa_supplicant net-misc/networkmanager-vpnc net-misc/networkmanager-openvpn net-misc/networkmanager net-misc/networkmanager-pptp net-analyzer/nmap net-wireless/crackle
Adjust various services on boot:
root # rc-update add lvm boot root # rc-update add device-mapper boot root # rc-update add dmcrypt boot root # rc-update add mdraid boot root # rc-update add gpm sysinit root # rc-update add NetworkManager default root # rc-update add autoconfig default root # rc-update add autorun default root # rc-update add dbus default root # rc-update add dostartx default root # rc-update add load-fonts-keymaps default root # rc-update add netconfig2 default root # rc-update add tigervnc default root # rc-update add consolekit default root # rc-update add syslog-ng default root # rc-update del keymaps boot
Use VIM instead VI:
root # mv /usr/bin/vi /usr/bin/vim-legacy ; ln -s /usr/bin/vim /usr/bin/vi
Enable Local Patches to Ebuilds:
root # ln -s /etc/portage/foobashrc.bashrc /etc/portage/bashrc
Compile AUFS kernel
Configure ebuild
root # echo "sys-kernel/aufs-sources symlink" >> /etc/portage/package.use root # emerge sys-kernel/aufs-sources
Configure AUFS kernel
root # cd /usr/src/linux ; wget https://area31.net.br/downloads/isoroot-rescuecd-area31/kernel-aufs-4.14.15 -O .config
Compile and install AUFS kernel and modules
root # make oldconfig ; make ; make install ; make modules_install
ZFS support (OPTIONAL)
Unmask ZFS ebuilds
Configure useflags:
root # echo "sys-fs/zfs -rootfs" >> /etc/portage/package.use
Configure keywords:
root # vi /etc/portage/package.keywords
=sys-kernel/spl-0.7.9 ** =sys-fs/zfs-0.7.9 ** =sys-fs/zfs-kmod-0.7.9 **
Compile ZFS ebuilds
root # emerge sys-kernel/spl sys-fs/zfs-kmod sys-fs/zfs
root # rc-update add zfs-import boot root # rc-update add zfs-mount boot root # rc-update add zfs-share default root # rc-update add zfs-zed default
Install optional ebuilds
root # emerge sys-apps/iucode_tool sys-firmware/intel-microcode
Configure fstab
Clean fstab:
root # > /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/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:
# 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
/etc/localtime is used to specify the timezone that your machine is in, and defaults to UTC. If you would like your Funtoo Linux system to use local time, you should replace /etc/localtime with a symbolic link to the timezone that you wish to use.
root # ln -sf /usr/share/zoneinfo/MST7MDT /etc/localtime
or configure other Time Zone using cpː
root # cp /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime
Check using date commandː
root # date -R
Wed, 14 Feb 2018 13:52:20 -0200
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
#!/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 } VERSION="4.0" fbecho echo -e "${lc1} =========== ${lc2}RescueCD Area31 Hackerspace${lc1} ----- ver. ${VERSION} =========== ${lc2}$(basename $(tty))${dc2}/6 ${lc1}==" echo -e " ${dc1}https://www.area31.net.br${dc2}" echo echo -e "${dc1}*${lc1} Network Manager${dc2}: NetworkManager${dc2}" echo -e "${dc1}OBS:${dc2} If you want to manually configure the NetworkManager service first, NetworkManager:" echo -e " ${dc1}-${dc2} ${lc2}rc-service NetworkManager stop${dc2} (Required to 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}Opcional:${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}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.area31.net.br${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" echo -e "${dc1}*${lc1} Personalize your RescueCD Funtoo${dc2}: " echo -e " Type ${lc2}sysresccd-area31${dc2} to start the RescueCD Customization Wizard." echo -e "${dc1}OBS:${dc2} RescueCD customization is recommended in a virtualized environment." fbecho if [ -f /usr/bin/Xorg ] then echo -e "${dc1}*${lc1} Graphic nterface${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}, ${lc2}rdd${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}area31${dc2}. To access using VNC please connect to port ${lc2}5901${dc2}" echo -e "\n RescueCD ${lc1}(Funtoo Linux based)${lc2} created by Area31 Hackerspace${dc1}\n https://www.area31.net.br\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
Remove unnecessary locales [OPTIONAL]
root # emerge app-admin/localepurge
Configure /etc/locale.nopurge ː
1- Comment this line to enable localepurgeː
# NEEDSCONFIGFIRST
2- Go to end in config file, and add/remove locales. Exː
# Following locales won't be deleted from this system # for example: pt_BR en
Save config file and run localepurgeː
root # localepurge
After run, localepurge will remove unused locales, and will show some statisticsː
* localepurge: Disk space freed in /usr/share/man: 2400K * localepurge: processing man pages in /usr/local/share/man ... * Total disk space freed by localepurge: 95968K
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/isoroot-rescuecd-area31/isoroot-rescuecd-area31-3.0-part1.tar.bz2 root # wget https://area31.net.br/downloads/isoroot-rescuecd-area31/isoroot-rescuecd-area31-3.0-part2.tar.bz2 root # tar xjpf isoroot-rescuecd-area31-3.0-part1.tar.bz2 -C /mnt/custom/customcd root # tar xjpf isoroot-rescuecd-area31-3.0-part2.tar.bz2 -C /mnt/custom/customcd
Prepare new initramfs
Extract initramfs from Área31 RescueCD
root # mkdir -p /usr/src/initramfs root # cd /usr/src/initramfs
root # cat /livemnt/boot/isolinux/initram.igz | xz -d | cpio -id
Copy modules from kernel to initramfs
root # cp -rp /mnt/custom/customcd/files/lib/modules/* lib/modules
Make new initramfs
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 initramfs 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/32bits/vmlinuz-*-aufs /mnt/custom/customcd/isoroot/isolinux/rescue32 root # cp /mnt/custom/customcd/files/boot/64bits/vmlinuz-*-aufs64 /mnt/custom/customcd/isoroot/isolinux/rescue64
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
How i customize the RescueCD
- To customize the RescueCD, either to modify the kernel or add/remove software, visit the article:
https://www.area31.net.br/wiki/RescueCD_-_Personalize_o_LiveCD_e_compile_um_novo_kernel