By default, /etc/rc.d/root tries to mount the root filesystem as read-write, which causes startup to abort when booting from read-only media that was created using the official memstick images. Fix: On the system that creates the official FreeBSD memstick images: echo 'root_rw_mount="NO"' >> /path/to/memstick/etc/rc.conf To patch your current memstick image before creating your read-only media: 1. mdconfig -a -t vnode -u 0 -f /path/to/FreeBSD-10.0-RELEASE-amd64-memstick.img 2. mount -t ufs /dev/md0 /mnt 3. echo 'root_rw_mount="NO"' >> /mnt/etc/rc.conf 4. umount /mnt 5. mdconfig -d -u 0 How-To-Repeat: 1. Get a USB flash drive that has a write protection switch. 2. Disable write protection on the USB flash drive. 3. Connect the USB flash drive to your system. 4. dd if=/path/to/FreeBSD-10.0-RELEASE-amd64-memstick.img of=/dev/usbflashdrive 5. Enable write protection on the USB flash drive. 6. Boot your system from the USB flash drive.
Looking further at the proposed solution, I would be weary of implementing it, since there may be unexpected repercussions with regard to bsdinstall(8) and bsdconfig(8), since both require read-write parts on the install medium at certain points as far as I can tell. I would like to get feedback from nwhitehorn@ and dteske@ on this.
RE territory.
(In reply to Glen Barber from comment #1) What happens with bsdinstall(8) and bsdconfig(8) when you try to install from WORM media, such as the official CD/DVD ISO image? This type of install media is not writable, as far as I can tell. :) I would suggest looking at what's done for WORM media, and doing the same for USB media: It shouldn't be necessary to write to the install media at all! If a writable volume is required during installation, a RAM disk is probably the best solution - and if this *is* truly required, it's probably already solved in exactly this fashion with the CD/DVD media - which cannot write to CD/DVD, during the install process.
(In reply to Oliver Jones from comment #3) > (In reply to Glen Barber from comment #1) > What happens with bsdinstall(8) and bsdconfig(8) when you try to install > from WORM media, such as the official CD/DVD ISO image? This type of install > media is not writable, as far as I can tell. :) > > I would suggest looking at what's done for WORM media, and doing the same > for USB media: It shouldn't be necessary to write to the install media at > all! If a writable volume is required during installation, a RAM disk is > probably the best solution - and if this *is* truly required, it's probably > already solved in exactly this fashion with the CD/DVD media - which cannot > write to CD/DVD, during the install process. In theory, you are correct, but there are different subsystems involved here. So while speculating the behavior won't change, I would prefer an actual test to be 100% certain. (If I had one of these USB sticks, I would test myself.)
The relevant ramdisks are created automatically if / is read-only by /etc/rc. bsdinstall and bsdconfig don't (by design) know anything about memsticks vs. CDs, so read-only mounting / by any mechanism would work just fine.
(In reply to Glen Barber from comment #4) Here's one way that you can test this using a regular USB flash drive: 1. dd if=/path/to/FreeBSD-10.2-RELEASE-amd64-uefi-memstick.img of=/dev/usbflashdrive 2. dd if=/dev/usbflashdrive | sha256 > hash1.txt 3. Boot up the system using the USB flash drive, and then power it off without doing anything that you'd expect would write to the USB flash drive. 4. dd if=/dev/usbflashdrive | sha256 > hash2.txt 5. Notice that the contents of hash1.txt and hash2.txt are different. 6. Use the workaround from this bug report to patch /path/to/FreeBSD-10.2-RELEASE-amd64-uefi-memstick.img. 7. Try steps #1 to #4 again. 8. Notice that the contents of hash1.txt and hash2.txt are identical. As far as I know, it shouldn't be a problem for all FreeBSD installation images (memstick, disc 1, et cetera) to have root_rw_mount="NO" in /etc/rc.conf. I think most people don't want any changes to be made to their installation media, and for those who do, it's easy enough to temporarily mount them as read/write and/or modify /etc/rc.conf.
A commit references this bug: Author: gjb Date: Tue Jan 5 03:20:46 UTC 2016 New revision: 293188 URL: https://svnweb.freebsd.org/changeset/base/293188 Log: Prevent memstick installation medium from attempting to mount the root filesystem read-write. This causes problems booting the memstick installation medium from write-protected USB flash drives. Submitted by: A.J. Kehoe IV [1], Oliver Jones [2] PR: 187161 [1], 205886 [2] MFC after: 1 week Sponsored by: The FreeBSD Foundation Changes: head/release/amd64/make-memstick.sh head/release/arm64/make-memstick.sh head/release/i386/make-memstick.sh head/release/powerpc/make-memstick.sh
(In reply to Nathan Whitehorn from comment #5) > The relevant ramdisks are created automatically if / is read-only by > /etc/rc. bsdinstall and bsdconfig don't (by design) know anything about > memsticks vs. CDs, so read-only mounting / by any mechanism would work just > fine. Thank you for the feedback. I've committed a change that will be reflected in this week's snapshot builds, and will merge to stable/10 in 1 week.
A commit references this bug: Author: gjb Date: Tue Jan 12 02:12:41 UTC 2016 New revision: 293723 URL: https://svnweb.freebsd.org/changeset/base/293723 Log: MFC r293188: Prevent memstick installation medium from attempting to mount the root filesystem read-write. This causes problems booting the memstick installation medium from write-protected USB flash drives. PR: 187161, 205886 Sponsored by: The FreeBSD Foundation Changes: _U stable/10/ stable/10/release/amd64/make-memstick.sh stable/10/release/amd64/make-uefi-memstick.sh stable/10/release/i386/make-memstick.sh stable/10/release/powerpc/make-memstick.sh