Note

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

Difference between revisions of "User:Pnoecker/legacy install"

From Funtoo
Jump to navigation Jump to search
(→‎GPT Partitioning: MBR is not forward compatible with uefi specification, so we force GPT on everyone, and implement backward compatibility.)
 
(11 intermediate revisions by the same user not shown)
Line 55: Line 55:
}}
}}


'''Create bios boot partition''':
'''Create bios boot partition (backwards compatibility with MBR partitioning)''':


{{console|body=
{{console|body=
Line 65: Line 65:
}}
}}


'''Create efi esp partition''':
'''Create efi esp partition (forwards compatibility with UEFI GPT partitioning)''':


{{console|body=
{{console|body=
Line 75: Line 75:
}}
}}


'''Create partition which will be our swap partition''':
'''Create a partition which will be our swap partition''':


{{console|body=
{{console|body=
Line 114: Line 114:
{{console|body=# ##i##mkswap /dev/sdX3}}
{{console|body=# ##i##mkswap /dev/sdX3}}
{{console|body=# ##i##swaplabel -L SWAP /dev/sdX3}}
{{console|body=# ##i##swaplabel -L SWAP /dev/sdX3}}
{{console|body=# ##i##swapon /dev/sdX3}}
*for ext4:
*for ext4:
{{console|body=# ##i##mkfs.ext4 /dev/sdX4}}
{{console|body=# ##i##mkfs.ext4 /dev/sdX4}}
Line 178: Line 179:
{{note|this example uses xfs}}
{{note|this example uses xfs}}
{{console|body=# ##i##cat > /etc/fstab << 'EOF'
{{console|body=# ##i##cat > /etc/fstab << 'EOF'
/dev/mapper/vg-boot /boot xfs noauto,noatime,nodiratime,defaults 0 1
LABEL=SWAP none swap sw 0 0
/dev/mapper/vg-swap none swap sw 0 0
LABEL=ROOT / xfs noatime,nodiratime,defaults 0 1
/dev/mapper/vg-root / xfs noatime,nodiratime,defaults 0 1
tmpfs /var/tmp/portage tmpfs uid=portage,gid=portage,mode=775,noatime 0 0
tmpfs /var/tmp/portage tmpfs uid=portage,gid=portage,mode=775,noatime 0 0
LABEL=EFI /boot/efi vfat umask=0077 0 1
LABEL=EFI /boot/efi vfat umask=0077 0 1
Line 201: Line 201:
{{console|body=# ##i##ego sync}}
{{console|body=# ##i##ego sync}}


'''Edit package USE-flags'''
'''Optionally add mix-ins at this point'''
{{console|body=# ##i##epro mix-in xfce}}
 
'''Edit package USE-flags to enable AMD microcode'''
{{console|body=# ##i##cat > /etc/portage/package.use <<'EOF'
{{console|body=# ##i##cat > /etc/portage/package.use <<'EOF'
*/* device-mapper lvm
sys-kernel/linux-firmware initramfs
sys-kernel/linux-firmware initramfs
EOF}}
EOF}}


'''Install necessary packages'''
'''Install necessary packages'''
{{console|body=# ##i##emerge grub haveged intel-microcode linux-firmware lvm2 genkernel iucode_tool shim mokutil}}
{{console|body=# ##i##emerge grub haveged intel-microcode linux-firmware iucode_tool shim mokutil}}
 
'''Optionally update the entire system as much as possible'''
{{note|This can be done later, and is not required for initial setup.}}
{{console|body=# ##i## emerge --keep-going -avuND @world}}
 
*for stage3 container or virtual machine generic network setup without network manager (desktop stages can skip this)
{{console|body=# ##i## echo 'config_eth0="dhcp"' >> /etc/conf.d/net
# ##i## ln -s /etc/init.d/net.lo /etc/init.d/net.eth0
# ##i## rc-update add dhcpcd
# ##i## rc-update add net.eth0}}


'''Configure services to start at boot'''
'''Configure services to start at boot'''
{{console|body=# ##i##rc-update add device-mapper sysinit}}
{{console|body=# ##i##rc-update add lvmetad sysinit}}
{{console|body=# ##i##rc-update add haveged default}}
{{console|body=# ##i##rc-update add haveged default}}
{{console|body=# ##i##rc-update add busybox-ntpd default}}
{{console|body=# ##i##rc-update add busybox-ntpd default}}


==Install a bootloader==
==Install a bootloader==
'''Configure /etc/boot.conf'''
{{Note|The UUID parameter is set to the UUID of /dev/sdX3 as found from the blkid command above.}}
{{console|body=# ##i##cat > /etc/boot.conf <<'EOF'
boot {
    generate grub
    default "Funtoo Linux"
    timeout 3
}
"Funtoo Linux" {
    kernel kernel[-v]
    initrd initramfs[-v]
    params += dolvm real_root=/dev/mapper/vg-root ro rootfstype=auto resume=/dev/mapper/vg-swap quiet
}
EOF}}
'''Install GRUB'''
'''Install GRUB'''
====For BIOS systems & UEFI legacy mode support====
====For BIOS systems & UEFI legacy mode support====
Line 239: Line 234:
====For UEFI systems====
====For UEFI systems====
{{console|body=# ##i##mount -o remount,rw /sys/firmware/efi/efivars}}
{{console|body=# ##i##mount -o remount,rw /sys/firmware/efi/efivars}}
{{note|If you boot in legacy mode you can ignore the warning of this directory not being present.  We can repair this later.}}


==Install grub & shim==
==Install grub & shim==
Line 257: Line 253:


===64bit systems===
===64bit systems===
{{console|body=# ##i##grub-install --target=x86_64-efi --sbat /usr/share/grub/sbat.csv --efi-directory=/boot/efi --bootloader-id="Funtoo" --recheck /dev/sdX}}
*For usb keys, removable drives, and legacy mode uefi install:
{{console|body=# ##i##grub-install --target=x86_64-efi --sbat /usr/share/grub/sbat.csv --efi-directory=/boot/efi --bootloader-id="BOOT" --no-nvram --recheck /dev/sdX}}


{{console|body=
{{console|body=
###i## cp /usr/share/shim/BOOTX64.EFI /usr/share/shim/mmx64.efi /boot/efi/EFI/Funtoo
###i## cp /usr/share/shim/BOOTX64.EFI /usr/share/shim/mmx64.efi /boot/efi/EFI/BOOT
}}
}}


*For usb keys & removable drives:
*For complete install with uefi entries:
{{console|body=# ##i##grub-install --target=x86_64-efi --sbat /usr/share/grub/sbat.csv --efi-directory=/boot/efi --bootloader-id="BOOT" --no-nvram --recheck /dev/sdX}}
{{console|body=# ##i##grub-install --target=x86_64-efi --sbat /usr/share/grub/sbat.csv --efi-directory=/boot/efi --bootloader-id="Funtoo" --recheck /dev/sdX}}


{{console|body=
{{console|body=
###i## cp /usr/share/shim/BOOTX64.EFI /usr/share/shim/mmx64.efi /boot/efi/EFI/BOOT
###i## cp /usr/share/shim/BOOTX64.EFI /usr/share/shim/mmx64.efi /boot/efi/EFI/Funtoo
}}
}}


===32bit systems===
===32bit systems===
{{console|body=# ##i##grub-install --target=i386-efi --sbat /usr/share/grub/sbat.csv --efi-directory=/boot/efi --bootloader-id="Funtoo" --recheck /dev/sdX}}
*For usb keys, removable drives, and legacy mode uefi install:
{{console|body=# ##i##grub-install --target=i386-efi --sbat /usr/share/grub/sbat.csv --efi-directory=/boot/efi --bootloader-id="BOOT" --no-nvram --recheck /dev/sdX}}


{{console|body=
{{console|body=
###i## cp /usr/share/shim/BOOTIA32.EFI /usr/share/shim/mmia32.efi /boot/efi/EFI/Funtoo
###i## cp /usr/share/shim/BOOTIA32.EFI /usr/share/shim/mmia32.efi /boot/efi/EFI/BOOT
}}
}}


*For usb keys & removable drives:
*For full install with uefi entries:
{{console|body=# ##i##grub-install --target=i386-efi --sbat /usr/share/grub/sbat.csv --efi-directory=/boot/efi --bootloader-id="BOOT" --no-nvram --recheck /dev/sdX}}
{{console|body=# ##i##grub-install --target=i386-efi --sbat /usr/share/grub/sbat.csv --efi-directory=/boot/efi --bootloader-id="Funtoo" --recheck /dev/sdX}}


{{console|body=
{{console|body=
###i## cp /usr/share/shim/BOOTIA32.EFI /usr/share/shim/mmia32.efi /boot/efi/EFI/BOOT
###i## cp /usr/share/shim/BOOTIA32.EFI /usr/share/shim/mmia32.efi /boot/efi/EFI/Funtoo
}}
}}


====Generate Grub menu====
====Generate Grub menu====
{{console|body=# ##i##ego boot update}}
{{console|body=# ##i##ego boot update}}
'''Generate a new initramfs'''
{{console|body=# ##i##genkernel --clean --lvm --disklabel --ramdisk-modules --fullname=$(ls /boot/initramfs-* {{!}} tail -c +17) initramfs}}


==Finishing installation==
==Finishing installation==

Latest revision as of 07:16, May 29, 2024

This howto describes how to setup a generic legacy method install. It is a standalone installation walk through, loosely based on the official installations finished product. This install will support both BIOS mode, and uEFI mode simultaneously.

   Warning
You may try this installation method at your own risk! Please note: this guide is outside of the official installation documentation, and cannot be supported. If you choose to use this, we assume you know what you are doing, and you are on your own!

Prepare the hard drive, and partitions

  • Before you begin, make sure you are partitioning the correct drive. For the rest of this tutorial, we will be using /dev/sdX as a placeholder.
root # lsblk
#NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
#sda             8:0    0  1.8T  0 disk 
#├─sdX1          8:1    0    1M  0 bios_boot
#├─sdX2          8:2    0    8G  0 esp      /efi
#└─sdX3          8:3    0  1.8T  0 part 
#  ├─main-boot 254:0    0  500G  0 lvm  /boot
#  ├─main-swap 254:0    0  500G  0 lvm  [swap]
#  ├─main-root 254:0    0  500G  0 lvm  /

link your drive to /dev/sdX

to make following this guide easier you can set udev rules and link the drive you're installing to /dev/sdX so everything is copy paste. just replace the kernel's == sda/mmc/nvme to match your target drive.

  • hda/sda drives:
root # echo 'KERNEL=="sda*", SYMLINK+="sdX%n"' > /etc/udev/rules.d/01-funtoo.rules
root # udevadm control --reload-rules
root # udevadm trigger
  • mmc/nvme drives:
root # echo 'KERNEL=="mmcblk0", SYMLINK+="sdX"' > /etc/udev/rules.d/01-funtoo.rules
root # echo 'KERNEL=="mmcblk0p*", SYMLINK+="sdX%n"' >> /etc/udev/rules.d/01-funtoo.rules
root # udevadm control --reload-rules
root # udevadm trigger
  • verify linking
root # ls -al /dev/sdX*
lrwxrwxrwx 1 root root 3 Jul 31 14:00 /dev/sdX -> sde
lrwxrwxrwx 1 root root 4 Jul 31 14:00 /dev/sdX1 -> sde1
lrwxrwxrwx 1 root root 4 Jul 31 14:00 /dev/sdX2 -> sde2

Partition

GPT Partitioning

root # gdisk /dev/sdX

Within gdisk, follow these steps:

Empty the partition table:

Command: o ↵
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y ↵

Create bios boot partition (backwards compatibility with MBR partitioning):

Command: n ↵
Partition Number: 1 ↵
First sector: 
Last sector: +1M ↵
Hex Code: EF02 ↵

Create efi esp partition (forwards compatibility with UEFI GPT partitioning):

Command: n ↵
Partition Number: 2 ↵
First sector: 
Last sector: +64M ↵
Hex Code: EF00 ↵

Create a partition which will be our swap partition:

Command: n ↵
Partition Number: 3 ↵
First sector: 
Last sector: +2G ↵ (for 2gb of swap, you may change this)
Hex Code: 8200 ↵

Create partition which will be our root

Command: n ↵
Partition Number: 4 ↵
First sector: 
Last sector:  (for the rest of the disk space)
Hex Code: 

Write Partition Table To Disk:

Command: w ↵
Do you want to proceed? (Y/N): Y ↵

The partition table will now be written to the disk and gdisk will close.

Create and mount filesystems.

Create esp filesystem

root # mkfs.vfat -F 32 /dev/sdX2
  • label esp system for fstab later on:
root # fatlabel /dev/sdX2 "EFI"

Create swap & root filesystem

  • swap:
root # mkswap /dev/sdX3
root # swaplabel -L SWAP /dev/sdX3
root # swapon /dev/sdX3
  • for ext4:
root # mkfs.ext4 /dev/sdX4
root # e2label /dev/sdX4 "ROOT"
  • for xfs:
root # mkfs.xfs /dev/sdX4
root # xfs_admin -L "ROOT" /dev/sdX4

Create directories for chroot

root # mkdir -p /mnt/funtoo

Mount filesystems

root # mount /dev/sdX4 /mnt/funtoo

Set the date

   Note

See the official Funtoo docs on setting the date.

Install the Funtoo starge tarball of your choice

   Note

These instructions will be using the generic64 next minimal stage3. You should adjust them accordingly.

or a stage more closely aligned to your hardware:

or funtoo from scratch generated stages:

root # cd /mnt/funtoo
root # wget https://build.funtoo.org/next/x86-64bit/generic_64/2022-09-13/stage3-generic_64-next-2022-09-13.tar.xz
root # tar --numeric-owner --xattrs --xattrs-include='*' -xpf *stage3*.tar.xz && rm -f *stage3*.tar.xz

Chroot into your new system

Traditional Method

root # mount -t proc none /mnt/funtoo/proc
root # mount --rbind /dev /mnt/funtoo/dev
root # mount --rbind /sys /mnt/funtoo/sys
root # env -i HOME=/root TERM=$TERM $(which chroot) /mnt/funtoo /bin/bash -l

Fchroot Method

root # fchroot .

Configure your system

Set a new root password

root # passwd

Set hostname

root # echo 'hostname="NewFuntooInstall"' > /etc/conf.d/hostname

Set up DNS resolution

   Note

We are using the Cloudflare DNS server address here. Feel free to use your own.

root # echo "nameserver 1.1.1.1" > /etc/resolv.conf

Set your timezone

root # ln -sf /usr/share/zoneinfo/$(tzselect) /etc/localtime

Note your filesystem information

root # blkid
/dev/sdX2: UUID="6453-0C55" TYPE="vfat" PARTLABEL="efi" PARTUUID="4e195c4b-f88c-4205-b9df-79a879704b2f"
/dev/sdX3: UUID="aafe709b-82e7-448f-a2cb-36adc3787dc3" TYPE="crypto_LUKS" PARTLABEL="system" PARTUUID="93d0cf9b-0b95-4d8b-919f-48cd1774996f"
/dev/mapper/root: UUID="hvz79n-I2VE-nR1c-0hDQ-PVkR-3GRb-rnuJ9C" TYPE="LVM2_member"
/dev/mapper/vg-swap: UUID="a9188bc3-7def-422b-990d-9de431825779" TYPE="swap"
/dev/mapper/vg-root: UUID="2eaf45e6-d33b-4155-b4ca-63a2fdbfb896" TYPE="ext4"

Configure /etc/fstab

   Note

this example uses xfs

root # cat > /etc/fstab << 'EOF'
LABEL=SWAP none swap sw 0 0
LABEL=ROOT / xfs noatime,nodiratime,defaults 0 1
tmpfs /var/tmp/portage tmpfs uid=portage,gid=portage,mode=775,noatime 0 0
LABEL=EFI /boot/efi vfat umask=0077 0 1
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

Portage

Download the portage tree

root # ego sync

Optionally add mix-ins at this point

root # epro mix-in xfce

Edit package USE-flags to enable AMD microcode

root # cat > /etc/portage/package.use <<'EOF'
sys-kernel/linux-firmware initramfs
EOF

Install necessary packages

root # emerge grub haveged intel-microcode linux-firmware iucode_tool shim mokutil

Optionally update the entire system as much as possible

   Note

This can be done later, and is not required for initial setup.

root #  emerge --keep-going -avuND @world
  • for stage3 container or virtual machine generic network setup without network manager (desktop stages can skip this)
root #  echo 'config_eth0="dhcp"' >> /etc/conf.d/net
root #  ln -s /etc/init.d/net.lo /etc/init.d/net.eth0
root #  rc-update add dhcpcd
root #  rc-update add net.eth0

Configure services to start at boot

root # rc-update add haveged default
root # rc-update add busybox-ntpd default

Install a bootloader

Install GRUB

For BIOS systems & UEFI legacy mode support

root # grub-install --target=i386-pc --no-floppy /dev/sdX

For UEFI systems

root # mount -o remount,rw /sys/firmware/efi/efivars
   Note

If you boot in legacy mode you can ignore the warning of this directory not being present. We can repair this later.

Install grub & shim

  • load efi directory:
root # mkdir /boot/efi
root # mount /boot/efi
  • generate a sbat file to install with grub:
root # cat > /usr/share/grub/sbat.csv << EOF
sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
grub,1,Free Software Foundation,grub,2.06,https://www.gnu.org/software/grub/
EOF

64bit systems

  • For usb keys, removable drives, and legacy mode uefi install:
root # grub-install --target=x86_64-efi --sbat /usr/share/grub/sbat.csv --efi-directory=/boot/efi --bootloader-id="BOOT" --no-nvram --recheck /dev/sdX
root # cp /usr/share/shim/BOOTX64.EFI /usr/share/shim/mmx64.efi /boot/efi/EFI/BOOT
  • For complete install with uefi entries:
root # grub-install --target=x86_64-efi --sbat /usr/share/grub/sbat.csv --efi-directory=/boot/efi --bootloader-id="Funtoo" --recheck /dev/sdX
root # cp /usr/share/shim/BOOTX64.EFI /usr/share/shim/mmx64.efi /boot/efi/EFI/Funtoo

32bit systems

  • For usb keys, removable drives, and legacy mode uefi install:
root # grub-install --target=i386-efi --sbat /usr/share/grub/sbat.csv --efi-directory=/boot/efi --bootloader-id="BOOT" --no-nvram --recheck /dev/sdX
root # cp /usr/share/shim/BOOTIA32.EFI /usr/share/shim/mmia32.efi /boot/efi/EFI/BOOT
  • For full install with uefi entries:
root # grub-install --target=i386-efi --sbat /usr/share/grub/sbat.csv --efi-directory=/boot/efi --bootloader-id="Funtoo" --recheck /dev/sdX
root # cp /usr/share/shim/BOOTIA32.EFI /usr/share/shim/mmia32.efi /boot/efi/EFI/Funtoo

Generate Grub menu

root # ego boot update

Finishing installation

From this point, you should be able to finish following the official Funtoo Linux install instructions

Rechroot

In the event of build failure, to rechroot requires unlocking the root, re-mounting, and re-chroot.

root # mount /dev/mapper/vg-root /mnt/funtoo && mount /dev/mapper/vg-boot /mnt/funtoo/boot
root # cd /mnt/funtoo
root # fchroot .

Additional links and information