From nobody Mon Oct 10 19:00:15 2022 X-Original-To: freebsd-fs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MmSsb3BHyz4dmt7 for ; Mon, 10 Oct 2022 19:00:19 +0000 (UTC) (envelope-from ronald-lists@klop.ws) Received: from smtpq4.tb.mail.iss.as9143.net (smtpq4.tb.mail.iss.as9143.net [212.54.42.167]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4MmSsY580Jz3H8x for ; Mon, 10 Oct 2022 19:00:17 +0000 (UTC) (envelope-from ronald-lists@klop.ws) Received: from [212.54.42.107] (helo=smtp3.tb.mail.iss.as9143.net) by smtpq4.tb.mail.iss.as9143.net with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohy0d-00051L-3I for freebsd-fs@freebsd.org; Mon, 10 Oct 2022 21:00:15 +0200 Received: from [192.168.1.109] ([85.147.65.221]) by smtp3.tb.mail.iss.as9143.net with ESMTPA id hy0co1KrqrgF4hy0coqLbv; Mon, 10 Oct 2022 21:00:14 +0200 X-Env-Mailfrom: ronald-lists@klop.ws X-Env-Rcptto: freebsd-fs@freebsd.org X-SourceIP: 85.147.65.221 X-CNFS-Analysis: v=2.4 cv=GKEbr8BK c=1 sm=1 tr=0 ts=63446bbf cx=a_exe a=1n1117WVeNyb02ulsRzAPA==:117 a=1n1117WVeNyb02ulsRzAPA==:17 a=IkcTkHD0fZMA:10 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=0EyHQldr3sIA:10 a=T8hboYP3AAAA:8 a=pGLkceISAAAA:8 a=6I5d2MoRAAAA:8 a=3F9wsYHBOmTlwiy__LwA:9 a=QEXdDO2ut3YA:10 a=3Xhr1e3L9Km7VwPPQCJS:22 a=IjZwj45LgO3ly-622nXo:22 X-Authenticated-Sender: emnvandam@casema.nl Message-ID: Date: Mon, 10 Oct 2022 21:00:15 +0200 List-Id: Filesystems List-Archive: https://lists.freebsd.org/archives/freebsd-fs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-fs@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: UFS in a USB flash drive (ufs:/dev/da0s1a) Content-Language: en-US To: Archimedes Gaviola Cc: freebsd-fs@freebsd.org References: <1630032913.129053.1665400270350@localhost> <896114746.217581.1665409172569@localhost> From: Ronald Klop In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4xfN6J/TEzyhwhGBcCBlRjBDAZfNxGvroKex58176w+RzCzwmoVbRS8WrXt3e27Ks5ORN1+roC84aGZCr3+yJFxkUsopckBmqRyGwlgEPWYbdC4fj+5G1I HBlP3OcfFncP6V6Iz4djO6R8PcokilIvFEyfxyfmvDzfR0vmvpRuvASDbC5punEDpDN7yRvYl0cePU13IhBtLFsq8mcYXLVYjkb5zox3QghQZ5JNwAT5qV0h Mso6oneF4jj5tyuCwJ+6jw== X-Rspamd-Queue-Id: 4MmSsY580Jz3H8x X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=pass (policy=quarantine) header.from=klop.ws; spf=pass (mx1.freebsd.org: domain of ronald-lists@klop.ws designates 212.54.42.167 as permitted sender) smtp.mailfrom=ronald-lists@klop.ws X-Spamd-Result: default: False [-3.89 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_HAM_LONG(-0.99)[-0.994]; DMARC_POLICY_ALLOW(-0.50)[klop.ws,quarantine]; R_SPF_ALLOW(-0.20)[+ip4:212.54.32.0/19]; MIME_GOOD(-0.10)[text/plain]; RCVD_IN_DNSWL_LOW(-0.10)[212.54.42.167:from]; TAGGED_RCPT(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[212.54.42.107:received]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; MLMMJ_DEST(0.00)[freebsd-fs@freebsd.org]; RCPT_COUNT_TWO(0.00)[2]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; HAS_X_AS(0.00)[]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_TLS_LAST(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ASN(0.00)[asn:33915, ipnet:212.54.32.0/20, country:NL]; R_DKIM_NA(0.00)[]; RWL_MAILSPIKE_POSSIBLE(0.00)[212.54.42.167:from] X-ThisMailContainsUnwantedMimeParts: N On 10/10/22 18:15, Archimedes Gaviola wrote: > > > On Mon, Oct 10, 2022 at 9:39 PM Ronald Klop > wrote: > > *Van:* Archimedes Gaviola > > *Datum:* maandag, 10 oktober 2022 14:09 > *Aan:* Ronald Klop > > *CC:* freebsd-fs@freebsd.org > *Onderwerp:* Re: UFS in a USB flash drive (ufs:/dev/da0s1a) > > On Mon, Oct 10, 2022 at 7:11 PM Ronald Klop > wrote: > > *Van:* Archimedes Gaviola > > *Datum:* maandag, 10 oktober 2022 12:40 > *Aan:* freebsd-fs@freebsd.org > *Onderwerp:* UFS in a USB flash drive (ufs:/dev/da0s1a) > > Hi, > I have a scenario (see below) after which the FreeBSD kernel boots-up in my embedded system, it is looking for the root filesystem. Now, I want to build one from scratch based on the examples below using a UFS filesystem in a USB flash drive -> ufs:/dev/da0s1a. Are there any available step-by-step reference(s) that can help and guide me in the building process? > ... > Trying to mount root from cd9660:/dev/map/rootfs.uzip []... > mountroot: waiting for device /dev/map/rootfs.uzip... > Mounting from cd9660:/dev/map/rootfs.uzip failed with error 19. > > Loader variables: > > Manual root filesystem specification: >   : [options] >       Mount using filesystem >       and with the specified (optional) option list. > >     eg. ufs:/dev/da0s1a >         zfs:tank >         cd9660:/dev/cd0 ro >           (which is equivalent to: mount -t cd9660 -o ro /dev/cd0 /) > >   ?               List valid disk boot devices >   .               Yield 1 second (for background tasks) >      Abort manual input > > mountroot> > ... > Thanks and best regards, > Archimedes > > > > Hi, > > From your mail I don't really understand what your level of skills with FreeBSD is. I assume the scenario with cd9660 and error 19 is not your biggest concern. You just want to install on a USB flash drive. > > Does this help: https://docs.freebsd.org/en/books/handbook/bsdinstall/ ? > > Regards, > Ronald. > > Hi Ronald, > No, it's not about installing FreeBSD from scratch using a USB flash drive as I already flashed and installed the FreeBSD kernel in the SPI flash RAM using trivial FTP in the U-boot loader. What I want is mounting the root filesystem that's been created in the USB flash drive (this hardware has USB port) using the ufs:/dev/da0s1a method but before that happens, I need to create that root filesystem (/) from scratch in the USB flash drive so that it can be mounted right after the kernel is loaded. > Not sure what level I am as a FreeBSD user but I can install and setup FreeBSD system, networking, install packages and re-build or compile a kernel. > Thanks and best regards, > Archimedes > > > > Hi, > > To create the root filesystem on USB you can use several methods. 2 of them are like this: > * the "bsdinstall" tool > * or >     - fetch https://download.freebsd.org/ftp/snapshots/arm64/13.1-STABLE/base.txz (change the URL if you need a different architecture or FreeBSD version) >     - newfs /dev/da0s1a    (NB: this device name might be different depending on the devices already available in your system) >     - mount /dev/da0s1a /mnt >     - tar xf -C /mnt /base.txz >     - umount /mnt > > This is from the top of my head, so I might have forgotten something. > > Than plugin the USB on your embedded system and at the prompt type: > mountroot> ufs:/dev/da0s1a > > If it does not work type a "?" question mark to see what filesystems are available. > > If you want to persist the FS used as root filesystem it depends on the system you are running. > You can hardcode the root FS in the kernel you saved in the SPI RAM. But depending on the system it is also possible to pass the rootfs in a variable in loader.conf or some other place from which the kernel can read variables. > > What kind of system are you running? > > Hope this helps. > > Regards, > Ronald. > > > Hi Ronald, > > Thanks for sharing the information, really appreciate it! I will try the newfs (newfs /dev/da0s1a) with my USB drive and then afterwards mount it to the host system. I can't fetch the base system since I'm cross-compiling a 32-bit MIPS (mipsel) system in an older FreeBSD 11.4 x86_64 release. I just downloaded the kernel source (/usrc/src). What I have at the moment is a successful cross-build of a system using the build command below; > > cd /usr/src; make KERNCONF=RT305X TARGET=mips TARGET_ARCH=mipsel kernel-toolchain buildkernel buildworld installkernel installworld distribution DESTDIR=/tmp/rt3050 > > that instead of using the DESTDIR= /tmp/rt3050, I will try replacing it with a mounted /dev/da0s1a. And then let me also try building without the kernel. Ah, yes, with DESTDIR you will have same effect. Before you can newfs the USB drive you need to partition it using gpart. Some example usages can be found here: https://www.freebsd.org/cgi/man.cgi?gpart(8)#EXAMPLES For flash drives it is often a good idea to align on 1M by adding '-a 1M' to gpart. And GPT is often more simple to use than MBR. As you use the kernel to load the USB drive I'm pretty sure GPT is supported. > > > Than plugin the USB on your embedded system and at the prompt type: > > mountroot> ufs:/dev/da0s1a > > > > If it does not work type a "?" question mark to see what filesystems are available. > > Noted on this. > > > If you want to persist the FS used as root filesystem it depends on the system you are running. > > You can hardcode the root FS in the kernel you saved in the SPI RAM. > > This is quite interesting but does it matter with the size of the SPI RAM as this system is only having 4MB? I had a system on 11.2 which used this option in the kernel config file. options ROOTDEVNAME=\"ufs:/dev/da0s1a\" > > > But depending on the system it is also possible to pass the rootfs in a variable in loader.conf or some other > > place from which the kernel can read variables. > > > > What kind of system are you running? > > > > Hope this helps. > > Again, this is a 32-bit MIPS system based on Ralink SoC. Apologize for this one because I know the FreeBSD project already phased-out this architecture platform in the -CURRENT builds and for support and it happens that I came late on this architecture and eager to learn and explore. Yes, the one you've shared means a lot to me. Let me try and get back on the progress. > > Thanks and best regards, > Archimedes > Happy hacking. Let us know if it all works out. Regards, Ronald.