Note

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

User:Pnoecker/Undead USB Install/xfs

From Funtoo
< User:Pnoecker‎ | Undead USB Install
Revision as of 18:34, March 19, 2024 by Pnoecker (talk | contribs) (→‎clean dismount)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Buy Paul, the author of this document, a coffee, or a pint of beer!

Undead USB, a linux nomadbsd alternative

This is an install strategy to target a USB flash stick as / (root) instead of a traditional hard drive or internal solid state drive. This isn't a live cd, this is a persistent root funtoo install where changes will keep living on. Since were treating a USB stick as a root partition, it requires much more space than a live usb like area31. 32gb minimum for gnome, 16gb are ok for xfce, lxde, lxqt, & server only type builds. get a fast usb3 drive even if you don't have usb3 ports as the flash memory on them is much faster than the flash memory on usb2 keys which will improve usability. This is a speed run of the official install x86_64 no swap & add XFS but does not intend to replace the official install. this is to make a more flexible, and robust install boot media than area31. undead usb can be used to build undead usb also. If you're reading this from linux, and have a blank 32gb USB drive you can mount up, and start building funtoo immediately. This guide has traditional hard drive aliasing, however it is targeted at building USB install media, and USB development sandbox installs. The user experience is like virtualization running on bare metal. If you run into a problem you can easily unplug permanent hard drives, and let a funtoo developer vpn into your fresh build to debug hardware directly.

  • grab root:
user $ sudo su
or
user $ su
  • identify the drive for installing:
root # lsblk -o name,size,label,partlabel
  • insert the usb drive, and run the above command again.

the first rule of funtoo is funtoo rules

set udev rules to make the drive you're installing to accessible at /dev/funtoo and partitions accessible at /dev/funtoo1 /dev/funtoo2 so on.

  • ide drive 3 example:
root # echo 'KERNEL=="hdd*", SYMLINK+="funtoo%n"' > /etc/udev/rules.d/01-funtoo.rules
  • sata drive 2 example:
root # echo 'KERNEL=="sdc*", SYMLINK+="funtoo%n"' > /etc/udev/rules.d/01-funtoo.rules
  • nvme nvme drive 1 example:
root # echo 'KERNEL=="nvme1n1", SYMLINK+="funtoo"' > /etc/udev/rules.d/01-funtoo.rules
root # echo 'KERNEL=="nvme1n1p*", SYMLINK+="funtoo%n"' >> /etc/udev/rules.d/01-funtoo.rules
  • mmc drive 0 example:
root # echo 'KERNEL=="mmcblk0", SYMLINK+="funtoo"' > /etc/udev/rules.d/01-funtoo.rules
root # echo 'KERNEL=="mmcblk0p*", SYMLINK+="funtoo%n"' >> /etc/udev/rules.d/01-funtoo.rules
  • activate rules:
  • display what /dev/funtoo is tied to:
root # udevadm control --reload-rules && udevadm trigger
root # ls -al /dev/funtoo

Partition

root # cgdisk /dev/funtoo
   Note

if cgdisk doesn't work load gdisk or fdisk to wipe out bad gpt tables, and then run cfdisk or cgdisk again.

delete everything.

Command:  new ↵
First sector: 
Last sector: +2M ↵
Hex Code: EF02 ↵
Enter name: BIOS Boot ↵

scroll down to large chunk of free space:

Command: new ↵
First sector: 
Last sector: +128M ↵
Hex Code: EF00 ↵
Enter name: BOOT ↵

scroll down to large chunk of free space:

Command: new ↵
First sector: 
Last sector: 
Hex Code:  8300 ↵
Enter name: FUNTOO ↵
Disk Drive: /dev/funtoo
                            Size: 62333952, 29.7 GiB

Part. #     Size        Partition Type            Partition Name
----------------------------------------------------------------
            1007.0 KiB  free space
   1        1024.0 KiB  BIOS boot partition	  BIOS Boot
   2        256.0 MiB   EFI System                BOOT
   3        29.5 GiB    Linux filesystem          FUNTOO
Command: write ↵
Command: quit ↵
root # mkfs.vfat -F 32 /dev/funtoo2
root # fatlabel /dev/funtoo2 "BOOT"
root # mkfs.xfs /dev/funtoo3
root # xfs_admin -L "FUNTOO" /dev/funtoo3

Mount

root # mkdir /mnt/funtoo
root # mount /dev/funtoo3 /mnt/funtoo
root # mkdir /mnt/funtoo/boot
root # mount /dev/funtoo2 /mnt/funtoo/boot
  • if you're doing a permanent install mount any additional drives to /mnt/funtoo/var or /mnt/funtoo/home now.

Get Funtoo

You can pull your Subarches gnome tarball if you're installing to specific hardware, not moving the disk between systems, or installing to a SSD/nvme. Use generic 64 so your USB os can roam on strange hardware.

root # cd /mnt/funtoo
root # wget https://build.funtoo.org/next/x86-64bit/generic_64/gnome-latest.tar.xz
root # tar --numeric-owner --xattrs --xattrs-include='*' -xpf *gnome*
  • if you like you can put the stage tarball in the new key's mount directory so you don't need to download it again.
root # cp *gnome* /mnt/funtoo/mnt

Load Funtoo

  • mount up:
root # cd /mnt/funtoo && mount -t proc none proc
mount --rbind /sys sys
mount --rbind /dev dev
mount --rbind /run run

chroot

  • chroot in:
root # env -i HOME=/root TERM=$TERM $(which chroot) /mnt/funtoo bash -l

change ps1

Mark that you're chrooted.

root # export PS1="FUNTOO $PS1"
  • Set your password, name, dns, tz, and clock:
root # passwd
root # echo 'hostname="undead"' > /etc/conf.d/hostname
root # echo "nameserver 1.1.1.1" > /etc/resolv.conf
root # ln -sf /usr/share/zoneinfo/$(tzselect) /etc/localtime
root # rc-service busybox-ntpd restart
  • Deploy your fstab:
root # cat > /etc/fstab << "EOF"
LABEL=BOOT /boot vfat noauto,noatime 1 2
LABEL=FUNTOO / xfs noatime 0 1
tmpfs /var/tmp/portage tmpfs uid=portage,gid=portage,mode=775,noatime 0 0
EOF

compile in ram:

root # mkdir /var/tmp/portage
root # chown portage:portage /var/tmp/portage
root # mount /var/tmp/portage

or exclude compiling in ram if your machine's not powerful enough:

root # umount /var/tmp/portage
   Note

remove tmpfs line from fstab so it doesn't try to ram compile next reboot if you do not want ram compilation

merge

  • merge stuff:
root # echo "sys-kernel/linux-firmware initramfs" >> /etc/portage/package.use
root # ego sync && emerge sys-boot/shim haveged intel-microcode linux-firmware eix discord-bin firefox-bin media-fonts/noto

you can also install Package:Brave or other browsers.

  • funtoo's official chat:

https://discord.gg/BNUSpUU

  • Set your startup services:
root # rc-update del swap boot && rc-update add haveged && rc-update add busybox-ntpd && rc-update add gpm

/etc/boot.conf

  • Deploy your boot.conf:
root # cat > /etc/boot.conf << "EOF"
boot {
	generate grub
	default "Funtoo Linux"
	timeout 0
}
"Funtoo Linux" {
	kernel kernel[-v]
	initrd initramfs[-v]
	params += real_root=auto rootfstype=auto 
	params += quiet gfxpayload=auto loglevel=1 splash=silent
}
EOF

GRUB

  • Install grub in legacy mode:
root # grub-install --target=i386-pc /dev/funtoo

EFI from EFI

  • performed from a legacy boot:
root #mount -o remount,rw /sys/firmware/efi/efivars
mount: /sys/firmware/efi/efivars: mount point does not exist.
root #grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id="BOOT" --recheck /dev/funtoo
Installing for x86_64-efi platform.
EFI variables are not supported on this system.
EFI variables are not supported on this system.
Installation finished. No error reported. << this installed correctly, /boot/EFI/BOOT/grubx64.efi exists.

When this is rebooted in efi mode, the efivars directory exists. We can re-run the grub install command swapping in the --bootloader-id="FUNTOO" to make a funtoo uefi menu boot entry.

EFI from Legacy

  • If the first EFI install attempt failed try this:
root # mkdir /boot/EFI
root # grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id="BOOT" /boot/EFI
Installing for x86_64-efi platform.
EFI variables are not supported on this system.
EFI variables are not supported on this system.
Installation finished. No error reported.

this produces a install that will boot on legacy computers, and uefi computers when secure boot is disabled in bios.

  • install fedora's shim & ego boot update.
root # cp /usr/share/shim/* /boot/EFI/BOOT/
root # ls /boot/EFI/BOOT/
BOOTIA32.EFI  BOOTX64.EFI  grubx64.efi  mmia32.efi  mmx64.efi
root # ego boot update

Now is a good time to install Package:Fchroot & Package:Etcher so you can install to raspberry pi's from your undead media when you reboot into it.

final install size is around 15,000MB without noto. gnome can fit in a 16gb usb stick, but it's a very tight squeeze and unix file systems degrade in performance at around 80%-90% full. 32gb keys are good, 64gb are excellent, 128gb keys can emerge the world. We suggest several 32gb drives over few larger drives.

video

  • rebuild the kernel video drivers, or switch to nouveau to make your usb more universal.
root # emerge -1 x11-drivers/nvidia-kernel-modules
  • To run nouveau instead of nvidia:
root # cd /etc/modprobe.d && mkdir .backup
root # mv /etc/modprobe.d/n* .backup
root # ego profile mix-in gfxcard-nouveau
root # ego profile mix-in -gfxcard-nvidia

Profile Update

  • Set your profile before emerging world:

Funtoo_Profiles

  • The magic words to update everything:
root # emerge -avuND @world 
root # emerge -av --depclean
root # ego boot update

every so often you will want to purge sources to keep the stick as low memory usage as possible

root # rm /var/cache/portage/distfiles/*.tar.bz2
root # rm /var/cache/portage/distfiles/*.tar.xz
root # rm /var/cache/portage/distfiles/*.tar.gz

DONE!

If you used a generic stage3 now would be a good time to merge in a DE: Install/Stage3_Desktop

clean dismount

root # exit
root # cd .. && sync 
root # umount -l funtoo

uefi secure boot

  • press the f1 f2 f8 f9 f10 esc or delete to load bios.
  • set bios to load uefi usb devices first, disable secure boot, and enable legacy mode. save settings and exit.
  • press the f1 f2 f8 f9 f10 esc or delete to load your boot selection menu.
  • load EFI from file, point to /boot/EFI/BOOT/BOOTX64.EFI
  • shim will greet you with access violation warnings.
  • fiddle around to get mok manager to load up.
  • select add key
  • point to /boot/EFI/BOOT/grubx86.efi
  • press the f1 f2 f8 f9 f10 esc or delete key to load your boot selection menu.
  • load EFI from file, and again point to /boot/EFI/BOOT/BOOTX64.EFI which will now load funtoo under secure boot.

further securing

i use Package:Sudo, and disable root login.

i use Package:Dnsmasq to block advertising, and cache DNS traffic to accelerate web browsing.

i use Package:Dnscrypt to encrypt all dns requests so the vast majority of the web traffic from my undead usb is encrypted.

Admining

use Package:Eix to browse portage to see packages you can emerge.

use Package:Eselect to set various system options.

Branding

root # echo "www.funtoo.org" > /etc/motd

add fortunes piped through cowsay to the shells

root # emerge fortune-mod cowsay
root # cd && echo "fortune | cowsay" >> .bashrc

Remote Help

Package:Logmein-hamachi is a easy to setup VPN allowing friends easy access to SSH should you run into trouble.