Bootable Linux USB stick: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
Line 12: Line 12:
'''Some more details'''
'''Some more details'''


# we always create a few-GB FAT32 partition because that makes file exchange with Windows and Macs very simple. The FAT32 partition should be the first partition on the stick; 2GB is enough for us. Then comes the Linux partition, with 13.9GB, so that the sum of the two partitions is slightly below 16GB. The third partition is then a 16.1GB /data partition. This scheme has the advantage that the image of the stick can just as well be copied (with dd or better ddrescue) to a 16GB stick; the /data partition then does not fit and cannot be used on that stick, but the operating system will then work on the small stick just as well. This requires that the /data partition is not fsck'ed automatically from /etc/fstab (0 in the 6th field).
# we always create a few-GB FAT32 partition because that makes file exchange with Windows and Macs very simple. The FAT32 partition should be the first partition on the stick; 2GB is enough for us. Then comes a biosboot partition (1MB; required for booting bios system from a GPT disk), an efi partition (e.g. 250MB; required for UEFI/EFI boot on PC's/MAC's) and the Linux partition, with 13.9GB, so that the sum of the four partitions is slightly below 16GB. The third partition is then a 16.1GB /data partition. This scheme has the advantage that the image of the stick can just as well be copied (with dd or better ddrescue) to a 16GB stick; the /data partition then does not fit and cannot be used on that stick, but the operating system will then work on the small stick just as well. This requires that the /data partition is not fsck'ed automatically from /etc/fstab (0 in the 6th field).
# it is a good idea to give easy root access to the one user you create because certainly some packages will have to be installed or updated when the stick is in use
# it is a good idea to give easy root access to the one user you create because certainly some packages will have to be installed or updated when the stick is in use
# it is a good idea to save an image of the stick whenever you made a successful change; otherwise you might need to start from scratch if you mess something up.
# it is a good idea to save an image of the stick whenever you made a successful change; otherwise you might need to start from scratch if you mess something up.
Line 31: Line 31:
The example shows a 32 GB Sandisk Extreme:
The example shows a 32 GB Sandisk Extreme:
  Part 1: +1G VFAT            (0700) (Windows needs it to be the first partition)  
  Part 1: +1G VFAT            (0700) (Windows needs it to be the first partition)  
  Part 2: +1M Biosboot       (ef02)
  Part 2: +1M BIOSBOOT       (ef02)
  Part 3: +250M EFI          (ef00)
  Part 3: +250M EFI          (ef00)
  Part 4: +13500M /          (0083)
  Part 4: +13500M /          (0083)
Line 37: Line 37:
For performance, make sure that the big partitions are aligned to 8192-sector boundaries; gdisk default is 2048-sector boundaries - the default can be adjusted. If you use the above sizes and the + sign for specifying them, this happens to work out automatically.
For performance, make sure that the big partitions are aligned to 8192-sector boundaries; gdisk default is 2048-sector boundaries - the default can be adjusted. If you use the above sizes and the + sign for specifying them, this happens to work out automatically.


=== Install Fedora23 on an UEFI machine (UEFI enabled; LegacyBoot / CSM disabled) ===
=== Install Fedora23 on an UEFI machine (UEFI enabled ; LegacyBoot / CSM disabled) ===
Whenever you see a ?, you must fill in the appropriate drive letter (e.g. c or d).  
Whenever you see a ?, you must fill in the appropriate drive letter (e.g. c or d).  
  sd?3: efi         /boot/efi
  sd?3: efi         /boot/efi
  sd?4: ext4            /  
  sd?4: ext4            /  
  sd?5: ext4            /mnt/data
  sd?5: ext4            /mnt/data
Line 45: Line 45:
=== adjust the USB-stick for UEFI/EFI boot (before reboot from chroot environment) ===
=== adjust the USB-stick for UEFI/EFI boot (before reboot from chroot environment) ===


chroot:
chroot to the installed system:
  chroot /mnt/sysimage
  chroot /mnt/sysimage


install Fedora updates:
install Fedora updates:
  dnf -y update    # dnf on FC23 is successor to yum
  dnf -y update    # dnf on FC23 is successor to yum


configure grub2 for (U)EFI systems:
configure grub2 for (U)EFI systems:
Line 58: Line 59:
  grub2-mkconfig -o /etc/grub2-efi.cfg
  grub2-mkconfig -o /etc/grub2-efi.cfg
(last step automatically puts UUID's to recognise the boot device in grub2-efi.cfg ; default after fresh Fedora installation is the device name which might be different on another computer)
(last step automatically puts UUID's to recognise the boot device in grub2-efi.cfg ; default after fresh Fedora installation is the device name which might be different on another computer)


Performance tuning (not strictly required):
Performance tuning (not strictly required):
Line 68: Line 70:
  mkfs.vfat /dev/sd?1
  mkfs.vfat /dev/sd?1
  dosfslabel /dev/sd?1 VFAT
  dosfslabel /dev/sd?1 VFAT
 
shutdown or reboot
  exit
  exit
  systemctl poweroff (or reboot for testing)
  systemctl poweroff (or reboot for testing)
Line 81: Line 84:
  chroot /mnt
  chroot /mnt


Install grub2 for BIOS boot and configure it:
install grub2 for BIOS boot and configure it:
  rm /boot/grub2/grubenv
  rm /boot/grub2/grubenv
(symlink to /boot/efi/EFI/fedora/grubenv in grub2-efi.rpm; binary file in grub2.rpm)
  grub2-install /dev/sd?
  grub2-install /dev/sd?
(also creates a new /boot/grub2/grubenv
  grub2-mkconfig -o /etc/grub2.cfg
  grub2-mkconfig -o /etc/grub2.cfg
(on UEFI systems /boot/grub2/grubenv is a symlink to /boot/efi/EFI/fedora/grubenv (from package grub2-efi.rpm). The symlink has to be removed before grub2-install can finish successfully, it automatically creates a new file /boot/grub2/grubenv (as in package grub2.rpm)


check /etc/grub2.cfg and if needed, change at all positions
 
check /etc/grub2.cfg and if needed, change at all positions:
“linuxefi” to “linux16”, and
“linuxefi” to “linux16”, and
“intrdefi” to “intrd16”
“intrdefi” to “intrd16”


=== Problems on old BIOS hardware ===
=== Problems on old BIOS hardware ===
some old computers still might not boot (they don't support booting from GPT).
Some old computers still might not boot since they don't support booting from GPT.
This can be fixed but the stick afterwards cannot boot on EFI/UEFI systems anymore.
This can be fixed to boot on such old hardware, however the stick afterwards cannot boot on EFI/UEFI systems anymore:
a) set the boot flag (active) on the single 0xEE partition in the protective MBR by using fdisk version <= 2.22 (versions 1.23 and newer have GPT support and thus don't make changes to the protective MBR but to the GPT) (I used fdisk (util-linux-ng 2.17.2) on a ScientificLinux 6.7 machine)
 
*set the boot flag (active) on the single 0xEE partition in the protective MBR by using fdisk version <= 2.22 (versions 1.23 and newer have GPT support and thus don't make changes to the protective MBR but to the GPT) (I used fdisk (util-linux-ng 2.17.2) on a ScientificLinux 6.7 machine)
  fdisk /dev/sd?  
  fdisk /dev/sd?  
  a
  a
  part 1
  part 1
  w
  w
b) recompute CHS values using option “h” in gdisk's expert menu:
 
*recompute CHS values using option “h” in gdisk's expert menu:
  gdisk /dev/sd?
  gdisk /dev/sd?
  x
  x
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu