Bootable USB

From PostgreSQL_wiki
Revision as of 16:22, 14 March 2024 by Martin (talk | contribs)
Jump to: navigation, search

Debian Bootable USB

Dit is een zogenaamde non-Uefi usb boot stick. Een bootable Debian USB is goud waard in een migratie uit Windows naar Linux of bij het herstel of migreren van een Linux machine.

Stappen:

  • Partitioneer een USB met gdisk
  • Installeer Debian op een partitie met debootstrap
  • Configureer de install naar een bootable usb

https://en.wikipedia.org/wiki/BIOS_boot_partition


mount de usb root partition debootstrap stable /mnt/sdc2 http://10.68.171.11:3142/debian mount-chroot chroot /mnt/sdc2 /bin/bash

=Partitioneren USB

Gebruik gdisk voor het partitioneren van de USB.

label: gpt
label-id: 6522A0ED-ED48-4313-B710-169E0E898DC2
device: /dev/sdb
unit: sectors
first-lba: 64
last-lba: 60538817
table-length: 248
sector-size: 512

/dev/sdb1 : start=          64, size=        1984, type=21686148-6449-6E6F-744E-656564454649, uuid=327DD423-85F8-4D23-A978-522BFC43B499, name="BIOS boot partition"
/dev/sdb2 : start=        2048, size=     8388608, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=2AE9F26B-3000-43FB-9F66-7352D5C3D4A8, name="Linux filesystem"
/dev/sdb3 : start=    16779264, size=     8388608, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=1B64C33C-8F04-407D-AB5B-F3358C6B625D, name="Linux filesystem"
/dev/sdb4 : start=    25167872, size=    35370946, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=14251565-DA33-4682-946B-81F091438E4C, name="Linux filesystem"

fstab

Op de USB zijn meerdere Debian OS installs mogelijk, dus is het zinvol om een apart home partitie te gebruiken, het heeft weinig zin om een swap te definiëren.

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# systemd generates mount units based on this file, see systemd.mount(5).
# Please run 'systemctl daemon-reload' after making changes here.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/md0 during installation
UUID=eb35cee7-df6d-45ad-b2fb-9917b5630443 /               ext4    errors=remount-ro 0       1
UUID=7440423e-10a4-42a2-a61c-3881981945e2 /home           ext4    errors=remount-ro 0       2

# We don't use swap partitions

ssh user install kernel image sudo geen root passwd netwerk config exit chroot mount-chroot umount de usb root partition


   maak met unetbootin een netinstall aan op een partitie op een usb-stick
   Boot de doel machine met de usb-stick en voer de installatie uit
   Grub maakt een foutje door de devices te verwisselen, sda <-> sdb
   Herstel de fout in grub edit en boot
   Pas na de boot /etc/fstab aan en doe update-grub

De installatie is nog niet erg minimaal, maar hij werkt.

 mkfs.ext4 /dev/sdc2
1937  mkfs.ext4 /dev/sdc3
1938  mkfs.ext4 /dev/sdc4

root@host:~# apt-get clean root@host:~# apt-get install localepurge root@host:~# localepurge root@squeeze-usb-i386:~# ln -s /home/squeeze-usb-i386/var/lib/* /var root@squeeze-usb-i386:~# ln -s /home/squeeze-usb-i386/var/cache/* /var

Installeer ook nog tools om met Windows file systems te werken:

apt-get install ntfsprogs scrounge-ntfs dosfstools rsync

Op de host

Maak een file system aan voor het OS op de USB stick.

root@host:~# fdisk /dev/sdb root@host:~# mkfs.ext2 /dev/sdb1

Maak een directory aan op de host om daarin de installatie voor de usb-stick voor te bereiden.

root@host:~# mkdir /usbsystem root@host:~# debootstrap --arch i386 squeeze /usbsystem http://ftp.nl.debian.org/debian root@host:~# ./croot.sh /usbsystem

Doe eerst alle stappen uit chrooted en doe daarna:

root@host:~# umount /usbsystem/dev/ /usbsystem/sys /usbsystem/proc /usbsystem/tmp root@host:~# umount /usbsystem-amd64/dev/ /usbsystem-amd64/sys /usbsystem-amd64/proc /usbsystem-amd64/tmp

chrooted fstab

  1. UNCONFIGURED FSTAB FOR BASE SYSTEM

LABEL=USB_ROOT / ext2 defaults,errors=remount-ro,noatime 0 1 proc /proc proc defaults 0 0 tmpfs /tmp tmpfs defaults,noatime 0 0 tmpfs /var/lock tmpfs defaults,noatime 0 0 tmpfs /var/log tmpfs defaults,noatime 0 0 tmpfs /var/run tmpfs defaults,noatime 0 0 tmpfs /var/tmp tmpfs defaults,noatime 0 0