From owner-freebsd-current@freebsd.org Wed Jun 17 18:37:11 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 D86D1357B13 for ; Wed, 17 Jun 2020 18:37:11 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [IPv6:2607:f8b0:4864:20::f2a]) (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 49nDLt3Rhyz4JcS for ; Wed, 17 Jun 2020 18:37:10 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qv1-xf2a.google.com with SMTP id p15so1524544qvr.9 for ; Wed, 17 Jun 2020 11:37:10 -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=46zAJEsk8xulCQO1EERbCte8tzVA+T03/i6/1AvNRVA=; b=AkHkW4MyJROMusOr9kgHraUplIxG3kCQW109oz2RPjoLNcWcQ3ygmrG23DwTTKUGWH FUqByNA5602l3vGAX3RZORRzERlUQD+Eyw2q85OeC+0Fudr/dl4N8aPXqeMF/hkp0JC5 PjTWcGJK3D23v6IYMSk1mxXwxoS/XhH3syyMXNf3PuzAyncnDU/QgrxdckXX0UI48u8I NU4lYx1VcfSo14hP3aXZGkhhYzG6vOsH0n8TTflmiOlf3jyDnYuc0N51Fl22eyVFxZsf WJuP8y8UWCKoWyTJo3OWE0tB7iShrR8t2pkaZIxPmRaHrgsMmCeo4jkr3N2XAMo4uhau 4jpg== 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=46zAJEsk8xulCQO1EERbCte8tzVA+T03/i6/1AvNRVA=; b=Q9dVsgwMVRRf5trvQq2ceMNdiNfK/AjDOVpgVPrO5lEtAQZluHF5f2P8pV8Y179c8/ kYl2ViVB21A5xt1eLznKSsGIZs5kIrkmcvesMnLQwYM8o6ucXD+WCrZmgslJgtk9c7FK 48GJyD7Y3xfsGNzCxq1fQ3UXJdsg9qJ/RRvLobpxK0a1borV+IuBbGjqNJ2YncaUNJ6Z qmvDC0laf/agXwfQO72pemhv8W76QyISOeoZMiM3MJmFLjrzaUJNz8lqnjJr3x4MvLpt rdmPChTLVbGGCB4HnwXZhy1rSWKTbunLEnMsQ8yJpVLxR/DsX7pXjSQPV5WcFJddHESi nMcw== X-Gm-Message-State: AOAM531MDVWhX9CXHEghPa1W+sB1aE1nm2Nyow7YxZ5Sol9UqlUr85BU qRPL40RQ2OsKzMCcWRSIlwcEXTrgyHR7Kb2JkshEPUmpFiU= X-Google-Smtp-Source: ABdhPJxFHTm73IvPAr6C48kxyvHnd9S3+Seg9ISFroSlyv3tLe+apVay7wD7LOqDaHWr8hcFzIgsBnsfD97vIWqT/os= X-Received: by 2002:a0c:910c:: with SMTP id q12mr36667qvq.22.1592419029539; Wed, 17 Jun 2020 11:37:09 -0700 (PDT) MIME-Version: 1.0 References: <202006171819.05HIJBR2086575@gndrsh.dnsmgr.net> In-Reply-To: <202006171819.05HIJBR2086575@gndrsh.dnsmgr.net> From: Warner Losh Date: Wed, 17 Jun 2020 12:36:58 -0600 Message-ID: Subject: Re: CTF: UEFI HTTP boot support To: "Rodney W. Grimes" Cc: "Simon J. Gerraty" , Miguel C , FreeBSD Current X-Rspamd-Queue-Id: 49nDLt3Rhyz4JcS X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20150623.gappssmtp.com header.s=20150623 header.b=AkHkW4My; dmarc=none; spf=none (mx1.freebsd.org: domain of wlosh@bsdimp.com has no SPF policy when checking 2607:f8b0:4864:20::f2a) smtp.mailfrom=wlosh@bsdimp.com X-Spamd-Result: default: False [-1.57 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20150623.gappssmtp.com:s=20150623]; NEURAL_HAM_MEDIUM(-0.38)[-0.377]; 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::f2a: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:~]; RCVD_COUNT_TWO(0.00)[2]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; FREEMAIL_CC(0.00)[juniper.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 18:37:11 -0000 On Wed, Jun 17, 2020 at 12:19 PM Rodney W. Grimes < freebsd-rwg@gndrsh.dnsmgr.net> wrote: > > On Wed, Jun 17, 2020 at 11:53 AM Rodney W. Grimes < > > freebsd-rwg@gndrsh.dnsmgr.net> wrote: > > > > > > Rodney W. Grimes wrote: > > > > > > The "fake cd drive" is in the kernel, loader just copies the iso > into > > > > > > memory like any other module, and by the time that's done you > just > > > > > > reboot into the newly installed system, which again uses > > > > > > > > > > > > vfs.root.mountfrom="cd9660:/dev/md0.uzip" > > > > > ^^^ > > > > > > > > > > Argh, the cd9660 confused me, I think your doing a > > > > > "root on mfs/md"? > > > > > > > > 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. > > > > > > > Looking at the code, I think MD_ROOT alone is insufficient here... > > I was a bit worried about that, but hopefull. We do work out of the > box with a NFS root as long as the NIC is found during boot. And > given that I load the loader over NFS the loader can also find my > /boot/ directory and the files in it, so that part is already solved. > Yes. If you NFS mount root, it works. But if you are loading a full image, the boot loader has to do all that and pass the right meta-data to the kernel for the kernel to know what to use for root. > > 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. > > Isnt this all handled by the loader? I think we have 2 slightly > different cases here. THe one sjg shows up, where you actually > load the md_image from a seperate file, and the case your talking > about where you actually embed the kernel and image into a single > file. > No. I'm talking about dynamically loading as well. The loader sets up the symbols that point to the image, though I didn't thread my way all the way through that. The loader sets it all up, and the kernel just uses the hints the loader gives and the md driver does at least part of the heavy lifting to make it happen. > > > 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" > > I do not think that is necessesary but I'll keep it in mind, at present > I do over ride the vfs.root.mountfrom to point to my version specific > root file system using some ipxe variables. > Usually that's enough, though when you want to use a MD device as root, it's configured in weird ways that appear from the code to be driven by ifdefs. And the default defines are for an uncompressed UFS filesystem inside that MD image. Others are possible, but I believe require compile time options. > 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. > > Thanks for exposing what may be some pointy sticks to stumble on. > Yea, There be a dragon or two here. The ZRouter folks appear to have do a reroot to the cdrom:9660:/dev/md0.uzip after dd'ing the installer image onto it.... but otherwise they don't reply on md stuff running direclty out of flash that's been uncompressed. I'd thought sure they'd worked this out for network booting, but if so it's not in the copy of the scripts I have. > 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. > > Probalby a good idea, as the usually failure mode in the diskless > word is black screens leaving little detail about what went wrong. > Yea. Having both serial and video consoles connected wouldn't hurt :) Good Luck! Warner > > Warner > -- > Rod Grimes > rgrimes@freebsd.org >