From d6f76dbfdc6158d4f7b505f9d2be2472b39dc05d Mon Sep 17 00:00:00 2001 From: r00t Date: Mon, 19 Dec 2016 01:16:09 -0500 Subject: [PATCH] finishing up booting/burning/flashing docs for netboot --- bdisk/ipxe.py | 4 +- docs/manual/boot/HOWTO.adoc | 94 ++++++++++++++- docs/manual/user/GETTING_STARTED.adoc | 8 +- extra/pre-build.d/etc/mkinitcpio.conf | 2 +- extra/pre-build.d/root/iso.pkgs.both | 1 + extra/pre-build.d/root/pre-build.sh | 2 +- extra/pre-build.d/usr/lib/initcpio/hooks/ssh | 67 ----------- .../pre-build.d/usr/lib/initcpio/install/ssh | 111 ------------------ 8 files changed, 101 insertions(+), 188 deletions(-) delete mode 100644 extra/pre-build.d/usr/lib/initcpio/hooks/ssh delete mode 100644 extra/pre-build.d/usr/lib/initcpio/install/ssh diff --git a/bdisk/ipxe.py b/bdisk/ipxe.py index aeed10a..6e8bd01 100755 --- a/bdisk/ipxe.py +++ b/bdisk/ipxe.py @@ -133,8 +133,8 @@ def genISO(conf): os.makedirs(os.path.dirname(efiboot_img), exist_ok = True) # FAT32 embedded EFI dir os.makedirs('{0}/EFI/boot'.format(bootdir), exist_ok = True) # EFI bootloader binary dir # Inner dir (miniboot.img file) - #sizetotal = 2097152 # 2MB wiggle room. increase this if we add IA64. - sizetotal = 34603008 # 33MB wiggle room. increase this if we add IA64. + sizetotal = 2097152 # 2MB wiggle room. increase this if we add IA64. + #sizetotal = 34603008 # 33MB wiggle room. increase this if we add IA64. sizetotal += os.path.getsize(innerefi64) sizefiles = ['HashTool', 'PreLoader'] for f in sizefiles: diff --git a/docs/manual/boot/HOWTO.adoc b/docs/manual/boot/HOWTO.adoc index 79744cd..e184fa7 100644 --- a/docs/manual/boot/HOWTO.adoc +++ b/docs/manual/boot/HOWTO.adoc @@ -12,7 +12,7 @@ Once downloaded, you can follow the appropriate steps based on your operating sy Simply put a blank CD/DVD-R (or RW, RW+, etc.) in your optical media drive. Find where you downloaded the above file (it should be named `bdisk-mini.iso`). Right-click and select *Burn disc image*. ==== USB -You'll most likely want to https://svwh.dl.sourceforge.net/project/usbwriter/USBWriter-1.3.zip[download] a program caled https://sourceforge.net/projects/usbwriter/[USBWriter]. Unzip it (or just open it via double-clicking) and copy the USBWriter.exe program somewhere you'll remember- your desktop, for instance. +You'll most likely want to https://svwh.dl.sourceforge.net/project/usbwriter/USBWriter-1.3.zip[download] a program caled https://sourceforge.net/projects/usbwriter/[USBWriter]. Unzip it (or just open it via double-clicking) and copy the `USBWriter.exe` program somewhere you'll remember- your desktop, for instance. Next, make sure your USB stick is inserted in your computer and https://support.microsoft.com/en-us/help/17418/windows-7-create-format-hard-disk-partition[formatted/"initialized"] already. @@ -29,11 +29,101 @@ Booting differs depending on each and every hardware, but *typically* you should === Mac OS X/macOS ==== CD/DVD +Unfortunately, the OS X/macOS Disk Utility doesn't work with hybrid ISOs (what `bdisk-mini.iso` is). At all. You're out of luck, I'm afraid, unless you happen have a spare USB thumbdrive handy. + ==== USB +We'll need to get a little messy with this one. + +Open Applications => Utilities => Terminal. A black box should pop up. + +Insert your USB stick now (if you haven't already) and run the following command: + + diskutil list + +You should see an entry, probably near the bottom, that looks something like this: + + ... + /dev/disk42 (external, physical): + #: TYPE NAME SIZE IDENTIFIER + 0: *8.2 GB disk42 + ... + +CAUTION: *Be sure* to find the disk that matches the size of your thumbdrive! If you use the wrong disk identifier, it will break your OS X/macOS install at best and delete all your data at worst! + +Now that you've found which disk your USB device is (the `/dev/disk__#__` part), we can continue. Make sure that it is the disk ID *right above* the line that contains your flash drive size! For our example, I will use `/dev/disk__42__` as an example as it's highly unlikely you'll have that many disk IDs, but be sure to replace this in the following commands with the proper disk ID you found above. + +Then we need to unmount the disk, in case it's already mounted. + + diskutil unmountDisk /dev/disk42 + +Assuming you saved BDisk Mini to your Desktop, you can do: + + sudo dd if=~/Desktop/bdisk-mini.iso of=/dev/disk42 + +NOTE: the above command may prompt you for a password. This is the same password you use to log into your Mac (and unlock the screensaver, etc.). No characters will show up when you type (for security reasons, in case someone is behind you watching your screen) so it may take you a couple tries. + +This will run for a couple seconds. When it finishes, you should see something similar to (but not necessarily the same numbers as) this: + + 0+1 records in + 0+1 records out + 169 bytes transferred in 0.000530 secs (318865 bytes/sec) + +At this point you _may_ get a popup warning you _"The disk you inserted was not readable by this computer."_ If you do, just click the *Ignore* button. + +One last step. Still in Terminal: + + diskutil eject /dev/disk42 + +You can then close Terminal. + ==== Booting -The instructions here don't differ too much than from Windows, though it's always the same key. For OS X/macOS hardware, I believe it's the *c* key or the *b* key. From it being in a shutdown state, power on your Macbook Pro (or whatever it is you have) and hold the *c* key if it's CD/DVD. The *b* key should bring up a boot menu that will let you select a USB device to boot from. +The instructions here don't differ too much than from Windows, though it's always the same key. For OS X/macOS hardware, I believe it's the *c* key or the *b* key. From it being in a shutdown state, power on your Macbook Pro (or whatever it is you have) and hold the *c* key if it's CD/DVD. The *b* key should bring up a boot menu that will let you select a USB device to boot from (I believe the *"b" menu* will let you boot from a CD/DVD as well). + +Strangely enough, you should still be able to _boot_ a BDisk Mini CD/DVD, you just can't *burn* one. I'm tempted to make a cheap dig at Apple, but I'll refrain. === GNU/Linux ==== CD/DVD +Easy. Most (if not all) of https://wiki.archlinux.org/index.php/Optical_disc_drive#Burning[these] should support burning `bdisk-mini.iso` to disc (I'm partial to _cdrecord_). If you prefer a GUI, try some of https://wiki.archlinux.org/index.php/Optical_disc_drive#Burning_CD.2FDVD.2FBD_with_a_GUI[these] instead (I like _k3b_). + ==== USB +Very similar to OS X/macOS in approach. First open a terminal emulator- the ways of navigating to it depends on your window manager/desktop environment, but it's usually under a System or Utilities menu. + +Now we need to find which disk our USB thumbdrive is. + + sudo fdisk -l + +You should see a device matching your USB thumbdrive's size. In our example, I use */dev/sdz* as it's unlikely you have that many disks attached to a system, but be sure to replace this in the following commands with the proper disk ID you find. + + ... + + Disk /dev/sdz: 7.6 GiB, 8178892800 bytes, 15974400 sectors + Units: sectors of 1 * 512 = 512 bytes + Sector size (logical/physical): 512 bytes / 512 bytes + I/O size (minimum/optimal): 512 bytes / 512 bytes + + ... + +CAUTION: *Be sure* to find the disk that matches the size of your thumbdrive! If you use the wrong disk identifier, it will break your GNU/Linux install (or possibly Windows install if you're dual-booting, etc.) at best and delete all your data at worst! + +Make sure it isn't mounted: + + umount /dev/sdz + +You should get a message that says `umount: /dev/sdz: not mounted`. If it was mounted before, it's unmounted now. + +Next, simply dd over the ISO file. + + sudo dd if=~/Desktop/bdisk-mini.iso of=/dev/sdz + +NOTE: the above command may prompt you for a password. This is the same password you use to log in (and unlock the screensaver, etc.). No characters will show up when you type (for security reasons, in case someone is behind you watching your screen) so it may take you a couple tries. + +This will run for a couple seconds. When it finishes, you should see something similar to (but not necessarily the same numbers as) this: + + 75776+0 records in + 75776+0 records out + 38797312 bytes (39 MB, 37 MiB) copied, 9.01915 s, 4.3 MB/s + +If you get a popup from your desktop environment (assuming you're using one) about not being able to mount a disk, or that it's unformatted, etc. and it prompts you to format, ignore/cancel/close it- do *not* format it! This would erase the BDisk Mini image on it. + ==== Booting +Exactly the same as those for Windows. (Unless you're running GNU/Linux on Mac hardware, in which case follow the booting instructions for Mac instead.) diff --git a/docs/manual/user/GETTING_STARTED.adoc b/docs/manual/user/GETTING_STARTED.adoc index 14b02f7..66c6feb 100644 --- a/docs/manual/user/GETTING_STARTED.adoc +++ b/docs/manual/user/GETTING_STARTED.adoc @@ -7,11 +7,11 @@ image::fig1.1.png[cgit,align="center"] If you know the tag of the commit you want, you can use curl: -`curl -sL -o bdisk.tar.xz https://git.square-r00t.net/BDisk/snapshot/BDisk-3.11.tar.xz` + curl -sL -o bdisk.tar.xz https://git.square-r00t.net/BDisk/snapshot/BDisk-3.11.tar.xz or wget: -`wget -O bdisk.tar.xz https://git.square-r00t.net/BDisk/snapshot/BDisk-3.11.tar.xz` + wget -O bdisk.tar.xz https://git.square-r00t.net/BDisk/snapshot/BDisk-3.11.tar.xz You can use `https://git.square-r00t.net/BDisk/snapshot/BDisk-master.tar.xz` for the URL if you want the latest working version. If you want a snapshot of a specific commit, you can use e.g. `https://git.square-r00t.net/BDisk/snapshot/BDisk-5ac510762ce00eef213957825de0e6d07186e7f8.tar.xz` and so on. @@ -21,11 +21,11 @@ TIP: If you're new to git and want to learn more, I highly recommend the book ht You can clone via https: -`git clone https://git.square-r00t.net/BDisk` + git clone https://git.square-r00t.net/BDisk or native git protocol: -`git clone git://git.square-r00t.net/bdisk.git BDisk` + git clone git://git.square-r00t.net/bdisk.git BDisk The git protocol is much faster, but at a cost of lessened security. diff --git a/extra/pre-build.d/etc/mkinitcpio.conf b/extra/pre-build.d/etc/mkinitcpio.conf index e123bfd..70ab017 100644 --- a/extra/pre-build.d/etc/mkinitcpio.conf +++ b/extra/pre-build.d/etc/mkinitcpio.conf @@ -51,7 +51,7 @@ FILES="/usr/bin/pkill" #HOOKS="base udev autodetect modconf block filesystems keyboard fsck" #HOOKS="base udev memdisk archiso_shutdown archiso modconf net ssh archiso_loop_mnt archiso_pxe_common archiso_pxe_nbd archiso_pxe_http archiso_pxe_nfs archiso_kms block pcmcia filesystems keyboard livecd" #HOOKS="base udev memdisk archiso_shutdown archiso-custom modconf net ssh archiso_loop_mnt archiso_pxe_common archiso_pxe_nbd archiso_http_custom archiso_pxe_nfs archiso_kms block pcmcia filesystems keyboard livecd" -HOOKS="base udev memdisk archiso_shutdown archiso modconf net ssh archiso_loop_mnt archiso_pxe_common archiso_pxe_nbd archiso_pxe_http archiso_pxe_nfs archiso_kms block pcmcia filesystems keyboard livecd" +HOOKS="base udev memdisk archiso_shutdown archiso modconf net archiso_loop_mnt archiso_pxe_common archiso_pxe_nbd archiso_pxe_http archiso_pxe_nfs archiso_kms block pcmcia filesystems keyboard livecd" #HOOKS="base memdisk systemd archiso_shutdown archiso modconf ssh archiso_loop_mnt archiso_pxe_common archiso_pxe_nbd archiso_pxe_http archiso_pxe_nfs archiso_kms block pcmcia filesystems keyboard livecd" # COMPRESSION diff --git a/extra/pre-build.d/root/iso.pkgs.both b/extra/pre-build.d/root/iso.pkgs.both index 053f90e..438b191 100644 --- a/extra/pre-build.d/root/iso.pkgs.both +++ b/extra/pre-build.d/root/iso.pkgs.both @@ -23,6 +23,7 @@ lz4 lzo lzop mkinitcpio-nfs-utils +mkinitcpio-utils ms-sys mtools net-tools diff --git a/extra/pre-build.d/root/pre-build.sh b/extra/pre-build.d/root/pre-build.sh index d55c2c6..1e0e687 100755 --- a/extra/pre-build.d/root/pre-build.sh +++ b/extra/pre-build.d/root/pre-build.sh @@ -177,8 +177,8 @@ then rm -f /root/pre-build.arch.sh fi # Cleanup -#yes | pacman -Scc # doesn't parse yes(1) output correctly, it seems. # TODO: look into https://wiki.archlinux.org/index.php/Pacman/Tips_and_tricks#Removing_unused_packages_.28orphans.29 +mkinitcpio -p linux paccache -rk0 localepurge-config localepurge diff --git a/extra/pre-build.d/usr/lib/initcpio/hooks/ssh b/extra/pre-build.d/usr/lib/initcpio/hooks/ssh deleted file mode 100644 index 2595634..0000000 --- a/extra/pre-build.d/usr/lib/initcpio/hooks/ssh +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/ash - -run_hook () -{ - local line i address netmask gateway dns0 dns1 rootserver rootpath defaultrootpath defaultserver - - : > /ip_opts - - if [ -z "${ip}" -a -n "${nfsaddrs}" ]; then - ip="${nfsaddrs}" - fi - - if [ -n "${ip}" ]; then - # setup network and save some values - ipconfig "ip=${ip}" | while read line; do - if [ "${line#"IP-Config:"}" != "${line}" ]; then - continue - fi - - line="$(echo ${line} | sed -e 's/ :/:/g;s/: /=/g')" - - for i in ${line}; do - case "${i}" in - address=*) - echo "${i}" >> /ip_opts - ;; - netmask=*) - echo "${i}" >> /ip_opts - ;; - gateway=*) - echo "${i}" >> /ip_opts - ;; - dns0=*) - echo "${i}" >> /ip_opts - ;; - dns1=*) - echo "${i}" >> /ip_opts - ;; - rootserver=*) - echo "${i}" >> /ip_opts - ;; - rootpath=*) - echo "${i}" >> /ip_opts - ;; - esac - done - done - - echo "device=$(echo ${ip} | cut -d: -f6)" >> /ip_opts - fi - - . /ip_opts - - echo "IP-Config: ${address}/${netmask}" - echo "IP-Config: gw: ${gateway} dns0: ${dns0} dns1: ${dns1}" - - [ -d /dev/pts ] || mkdir -p /dev/pts - mount -t devpts devpts /dev/pts - - echo "Starting dropbear" - /usr/sbin/dropbear -E -} - -run_cleanuphook () -{ - pkill -9 dropbear -} diff --git a/extra/pre-build.d/usr/lib/initcpio/install/ssh b/extra/pre-build.d/usr/lib/initcpio/install/ssh deleted file mode 100644 index 14a3049..0000000 --- a/extra/pre-build.d/usr/lib/initcpio/install/ssh +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/bash - -get_fingerprint() { - local keyfile="$1" - dropbearkey -y -f "${keyfile}" | sed -n '/^Fingerprint:/ {s/Fingerprint: *//; p}' -} - -display_fingerprints() { - local keyfile - - for keyfile in "/etc/dropbear/dropbear_dss_host_key" "/etc/dropbear/dropbear_rsa_host_key" ; do - if [ ! -r "${keyfile}" ] ; then - return 1 - fi - echo "$(basename "${keyfile}") : $(get_fingerprint "${keyfile}")" - done -} - -copy_openssh_keys() { - local osshrsa="/etc/ssh/ssh_host_rsa_key" - local osshdsa="/etc/ssh/ssh_host_dsa_key" - - local dbpre="/etc/dropbear/dropbear_" - - [ -f "$osshrsa" ] && [ -f "$osshdsa" ] || return 1 - - dropbearconvert openssh dropbear $osshrsa ${dbpre}rsa_host_key - dropbearconvert openssh dropbear $osshdsa ${dbpre}dss_host_key -} - -generate_keys() { - local keyfile keytype - for keytype in dss rsa ; do - keyfile="/etc/dropbear/dropbear_${keytype}_host_key" - echo "Generating ${keytype} host key for dropbear ..." - dropbearkey -t "${keytype}" -f "${keyfile}" - done -} - -make_etc_passwd() { - echo 'root:x:0:0:root:/:/bin/ash' > "${TMPDIR}"/passwd -} - -build () -{ - # - # Begin real processing - # - - # Are we even needed? - if [ ! -e "/etc/dropbear/root_key" ]; then - echo "There is no root key in /etc/dropbear/root_key existent; exit" - return 0 - fi - - # if TMPDIR is set leave it alone otherwise set - [ -z $TMPDIR ] && TMPDIR='/tmp/dropbear_initrd_encrypt' - - # check if TMPDIR exsists if not make it - [ -d $TMPDIR ] || mkdir -p $TMPDIR - - umask 0022 - - [ -d /etc/dropbear ] && mkdir -p /etc/dropbear - - display_fingerprints || copy_openssh_keys || generate_keys - - [ -e "${TMPDIR}/passwd" ] && ( grep -q -e '^root:' "${TMPDIR}/passwd" ) || make_etc_passwd - - add_checked_modules "/drivers/net/" - add_binary "/usr/bin/rm" - add_binary "/usr/bin/dropbear" - add_binary "/usr/bin/killall" - add_binary "/usr/bin/pkill" - - echo '/bin/ash' > "${TMPDIR}"/shells - add_file "${TMPDIR}/shells" "/etc/shells" - - cat /etc/dropbear/root_key > "${TMPDIR}"/authorized_keys - - add_dir "/.ssh" - add_file "${TMPDIR}/authorized_keys" "/.ssh/authorized_keys" - add_file "${TMPDIR}/passwd" "/etc/passwd" - add_dir "/etc/dropbear" - add_file "/etc/dropbear/dropbear_rsa_host_key" - add_file "/etc/dropbear/dropbear_dss_host_key" - add_file "/lib/libnss_files.so.2" - add_binary "ip" "/sbin/ip" - add_dir "/var/run" - - touch "${TMPDIR}"/lastlog - add_dir "/var/log" - add_file "${TMPDIR}/lastlog" "/var/log/lastlog" - add_binary "/usr/lib/initcpio/ipconfig" "/bin/ipconfig" - - # cleanup - rm "${TMPDIR}/shells" - rm "${TMPDIR}/authorized_keys" - rm "${TMPDIR}/passwd" - rm "${TMPDIR}/lastlog" - - add_runscript - -} - -help () -{ - cat<