From owner-freebsd-current@freebsd.org Wed Jun 17 19:07:06 2020 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CBF71330D8E for ; Wed, 17 Jun 2020 19:07:06 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49nF1Q2V4dz4LKG for ; Wed, 17 Jun 2020 19:07:05 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qk1-x732.google.com with SMTP id 205so3155835qkg.3 for ; Wed, 17 Jun 2020 12:07:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fzAcB6tKVSbeDmGtm/r2aOvAlCsa/QMVCC+zn9WxqnM=; b=Mwo5nLMTp2aoH39iP6RULf86WqdzqizzoL0QmX37BGGuQGarJGI1FF1KfJhhiezCkR GCaPEpQ7eyqFdgwK+zyx9woXv9554Cha7fcDpIlbcB75ZarLTLm7VT9E93buSChHc7i+ mlbScow7e7CpxQzv6bSZ8lMptjT3S0oCBKwB0TIvfKbdPy5YosWVFpLJ2AZ64ne054kA MAYPKB71XMPbbS0aJwg+sGwcfkaHy0oOr1V9/yKH5Mt8y3AntiHqtD13zGIIZBEDPKMz o0ZvEqbpOgB0tu4qitghDHM4ZXqiIZPzxYgAe6q85ISLxN5xXiQRHgw8hr1basRoJokY 5tvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fzAcB6tKVSbeDmGtm/r2aOvAlCsa/QMVCC+zn9WxqnM=; b=L7zuMf1d1Bu0dY2DBJCjVDVIBEAPjvVuHtOrEwJ1ax+QwCEZ9j553xZz83tksgVkZS PvRxPX+0Chsu0ggRVdtGesms2Zj/uJsGCmjDUf1PdzQET2iuDbOBgGv1f8LyalIWLxRL wXIPmNUOBpVISIBOd40wucasnjX4aU2ZvvnpsEnUzFJN7hjlOpvmpVdNsIBVPGwQhldi XqOUW2tU+TJhcU8qQP0JmiyBfr++ijEgeJMiMYIBEuuGs02gkFXEkwlDHsYIXOUbEK1w 8dFbMFWLUAW4Kds3yfqIH09DqC8qU8lo1STq89t1S0Fn1TTLTRfsn738oocfc3igfcvb ufpw== X-Gm-Message-State: AOAM532+u3i9yt/BIVahoRHXN1g2MxNAEDQewKVpqvJfQSOvAou74xLp bNQOamOj2ijTvLut2FF41lXxeYSb2+tfW0en71ABrg== X-Google-Smtp-Source: ABdhPJx9mUWjx/B0uQ9gkvrHMMmuEjkn20jwHECVNfJjQohLn0FjzOM1BbmwAWqldFdiOS47XCGwsg5J3Pma5SAT+ok= X-Received: by 2002:a37:392:: with SMTP id 140mr75213qkd.495.1592420825115; Wed, 17 Jun 2020 12:07:05 -0700 (PDT) MIME-Version: 1.0 References: <46934.1592351291@kaos.jnpr.net> <202006171752.05HHqo0E086454@gndrsh.dnsmgr.net> <48054.1592420182@kaos.jnpr.net> In-Reply-To: <48054.1592420182@kaos.jnpr.net> From: Warner Losh Date: Wed, 17 Jun 2020 13:06:52 -0600 Message-ID: Subject: Re: CTF: UEFI HTTP boot support To: "Simon J. Gerraty" Cc: "Rodney W. Grimes" , Miguel C , FreeBSD Current X-Rspamd-Queue-Id: 49nF1Q2V4dz4LKG X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20150623.gappssmtp.com header.s=20150623 header.b=Mwo5nLMT; dmarc=none; spf=none (mx1.freebsd.org: domain of wlosh@bsdimp.com has no SPF policy when checking 2607:f8b0:4864:20::732) smtp.mailfrom=wlosh@bsdimp.com X-Spamd-Result: default: False [-1.57 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.38)[-0.378]; RCVD_COUNT_TWO(0.00)[2]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20150623.gappssmtp.com:s=20150623]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; NEURAL_HAM_LONG(-0.98)[-0.981]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-current@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20150623.gappssmtp.com:+]; NEURAL_HAM_SHORT(-0.21)[-0.212]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::732:from]; R_SPF_NA(0.00)[no SPF record]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; RCVD_TLS_ALL(0.00)[]; FREEMAIL_CC(0.00)[gndrsh.dnsmgr.net,gmail.com,freebsd.org] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.33 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jun 2020 19:07:06 -0000 On Wed, Jun 17, 2020 at 12:56 PM Simon J. Gerraty wrote: > Warner Losh wrote: > > > loader.conf says > > > > > > rootfs_load="yes" > > > rootfs_name="contents.izo" > > > rootfs_type="md_image" > > > vfs.root.mountfrom="cd9660:/dev/md0.uzip" > > > > > > contents.izo is uzip'd contents.iso which file(1) > > > describes as ISO 9660 CD-ROM filesystem data '' > > > > > > That's for normal boot, for the loader 'install' command > > > it expects an uncompressed iso for rootfs. > > > > Ok, now the puzzle is how much work to get from a stock FreeBSD .iso > > image to something that works with this. Obviously we need a non-stock > > /boot/loader.conf file, or to type some commands manually at a loader > > prompt. I believe the stock GENERIC kernel has the md_root support > > for this already, so it may not be that hard to do. > > So obviously we don't use the GENERIC kernel, but > I don't think we have any magic except in 4th files and loader.conf > and for the loader install command its all in the loader itself, > and I've been keeping head up todate on recent fixes/improvements there > since for UEFI I'm using loader.efi built from head. > Yea the loader will load the image, but the md driver looks for images of type md_image or md_root and will create md devices for those devices it finds. > Oh and all the scripts run by init during boot are custom. > > > Looking at the code, I think MD_ROOT alone is insufficient here... > > > > If there's no MD root provided, we look for the symbols mfs_root and > > mfs_root_end, which I think means that rootfs_ in the above example > > needs to be md_root_ instead so that we find it. > > FWIW our kernel options include > > options CD9660 > options MD_ROOT > options MD_ROOT_FSTYPE=\"cd9660\" > Yea, this lets you mout cd9660 images as root... It also drives setting rootdevnames[0] which is used to create the default mountroot script on loading the first md image. > > You may need to have a custom kernel with 'options MD_ROOT_READONLY' > because isofs is read-only. > > > > And there's a small chance you may need to define ROOTDEVNAME in the > build as well to be "cd9660:/dev/md0.uzip" > > > Every time I do stuff like this I have to re-puzzle it out, alas, but > > these should give you some guide posts. It should be better documented > > in md(4), but isn't at the moment. > > > > I'd honestly try to get this setup working first loading all the files > > off a local disk before layering in the networking on top of that. > > Agreed! Booting from say tftp://host/install.tar > is far more fragile - the tar file needs to present all the files in > correct order since we cannot seek backwards (much), and tftp sucks ;-) > > userboot is very handy for testing all this stuff, though building it to > run on host (the way we do) seems broken in head. > Yea, of course. that makes sense. I'd forgotten userboot helps a lot. The default build of it should be working, though... Warner > --sjg >