Discussion:
how to fix fstab in single user mode for bootable "Live" USB drive
Marcus
2010-08-27 12:38:57 UTC
Permalink
how to fix fstab in single user mode for bootable "Live" USB drive

http://www.openbsd.org/faq/faq14.html#flashmemLive
says:
If your target machine has an ahci(4) or SCSI interface, you will
probably find your USB drive's identifier changing. Having multiple
versions of your /etc/fstab file may make this easier to "fix" (in
single user mode).

Install OpenBSD to USB drive in a notbook. the usb drive is
recognized as "sd1"

Now put the USB drive into another PC an boot from USB. the usb dirve
is recognized as "sd0".

in the single user mode.
"fsck -p / && mount -uw /" not work
"fsck -p /usr && mount /usr" not work
"vi /etc/fstab" not work.

question:
how to mount root / writable and active vi editor?


thanks.
Antoine Jacoutot
2010-08-27 12:59:23 UTC
Permalink
Post by Marcus
how to fix fstab in single user mode for bootable "Live" USB drive
http://www.openbsd.org/faq/faq14.html#flashmemLive
If your target machine has an ahci(4) or SCSI interface, you will
probably find your USB drive's identifier changing. Having multiple
versions of your /etc/fstab file may make this easier to "fix" (in
single user mode).
Install OpenBSD to USB drive in a notbook. the usb drive is
recognized as "sd1"
Now put the USB drive into another PC an boot from USB. the usb dirve
is recognized as "sd0".
What *I* do is this:
$ sudo config -ef /bsd
-> then disable ahci.
--
Antoine
Nick Holland
2010-08-27 14:19:33 UTC
Permalink
Post by Marcus
how to fix fstab in single user mode for bootable "Live" USB drive
http://www.openbsd.org/faq/faq14.html#flashmemLive
If your target machine has an ahci(4) or SCSI interface, you will
probably find your USB drive's identifier changing. Having multiple
versions of your /etc/fstab file may make this easier to "fix" (in
single user mode).
Install OpenBSD to USB drive in a notbook. the usb drive is
recognized as "sd1"
Now put the USB drive into another PC an boot from USB. the usb dirve
is recognized as "sd0".
in the single user mode.
"fsck -p /&& mount -uw /" not work
"fsck -p /usr&& mount /usr" not work
"vi /etc/fstab" not work.
how to mount root / writable and active vi editor?
mount by the device name rather than fstab...

fsck /dev/sd0a
mount /dev/sd0a /
fsck /dev/sd0d
mount /dev/sd0d /usr # or whatever your /usr partition is
vi /etc/fstab

or... fsck and mount your root partition, and use 'ed(1)' to edit fstab.

Nick.
Paul de Weerd
2010-08-27 15:04:57 UTC
Permalink
On Fri, Aug 27, 2010 at 08:38:57PM +0800, Marcus wrote:
| how to fix fstab in single user mode for bootable "Live" USB drive
|
| http://www.openbsd.org/faq/faq14.html#flashmemLive
| says:
| If your target machine has an ahci(4) or SCSI interface, you will
| probably find your USB drive's identifier changing. Having multiple
| versions of your /etc/fstab file may make this easier to "fix" (in
| single user mode).
|
| Install OpenBSD to USB drive in a notbook. the usb drive is
| recognized as "sd1"
|
| Now put the USB drive into another PC an boot from USB. the usb dirve
| is recognized as "sd0".
|
| in the single user mode.
| "fsck -p / && mount -uw /" not work
| "fsck -p /usr && mount /usr" not work
| "vi /etc/fstab" not work.
|
| question:
| how to mount root / writable and active vi editor?

Don't. There's no need. Here's how you do it even easier (requires
recent snap / source)

[ -f /dev/diskmap ] || ( cd /dev; sudo MAKEDEV diskmap )
echo wq | disklabel -E YOURDISK
UID=`disklabel YOURDISK | grep ^uid: | cut -f2 -d' '`
{ echo ",s#/dev/YOURDISK#${UID}.#"; echo w; } | ed - /etc/fstab

Do not try this until you understand what it does. You'll have to
edit it to your needs anyway.

This new uid stuff is really cool, thanks jsing@ !

Paul 'WEiRD' de Weerd
--
++++++++[<++++++++++>-]<+++++++.>+++[<------>-]<.>+++[<+
+++++++++++>-]<.>++[<------------>-]<+.--------------.[-]
http://www.weirdnet.nl/
Kenneth R Westerback
2010-08-27 15:55:16 UTC
Permalink
Post by Paul de Weerd
| how to fix fstab in single user mode for bootable "Live" USB drive
|
| http://www.openbsd.org/faq/faq14.html#flashmemLive
| If your target machine has an ahci(4) or SCSI interface, you will
| probably find your USB drive's identifier changing. Having multiple
| versions of your /etc/fstab file may make this easier to "fix" (in
| single user mode).
|
| Install OpenBSD to USB drive in a notbook. the usb drive is
| recognized as "sd1"
|
| Now put the USB drive into another PC an boot from USB. the usb dirve
| is recognized as "sd0".
|
| in the single user mode.
| "fsck -p / && mount -uw /" not work
| "fsck -p /usr && mount /usr" not work
| "vi /etc/fstab" not work.
|
| how to mount root / writable and active vi editor?
Don't. There's no need. Here's how you do it even easier (requires
recent snap / source)
[ -f /dev/diskmap ] || ( cd /dev; sudo MAKEDEV diskmap )
echo wq | disklabel -E YOURDISK
UID=`disklabel YOURDISK | grep ^uid: | cut -f2 -d' '`
{ echo ",s#/dev/YOURDISK#${UID}.#"; echo w; } | ed - /etc/fstab
Do not try this until you understand what it does. You'll have to
edit it to your needs anyway.
Paul 'WEiRD' de Weerd
--
++++++++[<++++++++++>-]<+++++++.>+++[<------>-]<.>+++[<+
+++++++++++>-]<.>++[<------------>-]<+.--------------.[-]
http://www.weirdnet.nl/
This is the correct answer. I have a USB stick I install/upgrade
to. I boot from it on systems where it appears as sd0, sd1, sd3,
sd4. Works perfectly.

All hail jsing!

..... Ken
Olivier Cherrier
2010-08-28 09:05:27 UTC
Permalink
Post by Paul de Weerd
Don't. There's no need. Here's how you do it even easier (requires
recent snap / source)
[ -f /dev/diskmap ] || ( cd /dev; sudo MAKEDEV diskmap )
echo wq | disklabel -E YOURDISK
UID=`disklabel YOURDISK | grep ^uid: | cut -f2 -d' '`
{ echo ",s#/dev/YOURDISK#${UID}.#"; echo w; } | ed - /etc/fstab
Do not try this until you understand what it does. You'll have to
edit it to your needs anyway.
Yes, it's great... especially with softraid volumes!
Thanks Joel!

$ grep '\.' /etc/fstab
08552bb5b53ec2df.a /usr ffs rw,nodev 1 2
08552bb5b53ec2df.g /usr/X11R6 ffs rw,nodev 1 2
08552bb5b53ec2df.b /usr/local ffs rw,nodev 1 2
08552bb5b53ec2df.e /usr/obj ffs rw,nodev,nosuid 1 2
08552bb5b53ec2df.h /usr/ports ffs rw,nodev,nosuid 1 2
08552bb5b53ec2df.d /usr/src ffs rw,nodev,nosuid 1 2
08552bb5b53ec2df.f /usr/xenocara ffs rw,nodev,nosuid 1 2
08552bb5b53ec2df.i /var ffs rw,nodev,nosuid 1 2
08552bb5b53ec2df.j /home ffs rw,nodev,nosuid 1 2
482c4eac2228bc96.a /data/tmp ffs rw,nodev,nosuid 1 2
482c4eac2228bc96.b /var/squid ffs rw,nodev,nosuid 1 2
c3b17d16762bcaf9.a /data/clients ffs rw 1 2
--
Olivier Cherrier - Symacx.com
mailto:***@symacx.com
Raimo Niskanen
2010-08-30 12:03:59 UTC
Permalink
Post by Olivier Cherrier
Post by Paul de Weerd
Don't. There's no need. Here's how you do it even easier (requires
recent snap / source)
[ -f /dev/diskmap ] || ( cd /dev; sudo MAKEDEV diskmap )
echo wq | disklabel -E YOURDISK
UID=`disklabel YOURDISK | grep ^uid: | cut -f2 -d' '`
{ echo ",s#/dev/YOURDISK#${UID}.#"; echo w; } | ed - /etc/fstab
Do not try this until you understand what it does. You'll have to
edit it to your needs anyway.
Yes, it's great... especially with softraid volumes!
Thanks Joel!
$ grep '\.' /etc/fstab
08552bb5b53ec2df.a /usr ffs rw,nodev 1 2
08552bb5b53ec2df.g /usr/X11R6 ffs rw,nodev 1 2
08552bb5b53ec2df.b /usr/local ffs rw,nodev 1 2
08552bb5b53ec2df.e /usr/obj ffs rw,nodev,nosuid 1 2
08552bb5b53ec2df.h /usr/ports ffs rw,nodev,nosuid 1 2
08552bb5b53ec2df.d /usr/src ffs rw,nodev,nosuid 1 2
08552bb5b53ec2df.f /usr/xenocara ffs rw,nodev,nosuid 1 2
08552bb5b53ec2df.i /var ffs rw,nodev,nosuid 1 2
08552bb5b53ec2df.j /home ffs rw,nodev,nosuid 1 2
482c4eac2228bc96.a /data/tmp ffs rw,nodev,nosuid 1 2
482c4eac2228bc96.b /var/squid ffs rw,nodev,nosuid 1 2
c3b17d16762bcaf9.a /data/clients ffs rw 1 2
This is great! I have long been missing this kind of feature,
allthough I anticipated being able to mount by label, but this
might even be better...

<detailed_background>
I solved the problem together with the problem of encrypting
(through softraid) as much of the installation as possible for
example system configuration files under /etc roughly like this:
* USB disk partitions for swap, / and encrypted softraid.
* Encrypted softraid disk partitions for /etc, /altroot, /var, /tmp,
/usr, /home, ...
* Hard links between /etc/{fstab,login.conf,ttys,rc,boot.conf} and
/etc.boot/ on the USB disk, to be able to fix these files after
the upcoming mount over of /etc.
* A new /etc/rc script on the USB key that:
- Open (decrypt) the softraid encrypted disk.
- fsck the softraid/etc partition
- mount the softraid/etc partition over /etc
- ed the new /etc/fstab to change the disk names into what
the boot disk and the encrypted softraid disk now are.
Use mount_mfs to create a writable /tmp in the process.
- Start a background shell with the new /etc/ directory
as working directory to protect against accidental umount.
- exec /bin/sh /etc/rc ${1+"$@"}
* A /etc/rc.shutdown script that updated /etc.boot/boot.conf on
the USB disk with the content in /etc/boot.conf on the encrypted
softraid disk.
</detailed_background>

Most of the difficult hazzle of editing /etc/fstab is hereby
unnecessary, so I can think hard about if the encryption of
/etc really is necessary for me.

Thank you very much for this usability improvement!
Post by Olivier Cherrier
--
Olivier Cherrier - Symacx.com
--
/ Raimo Niskanen, Erlang/OTP, Ericsson AB
Martin Schröder
2010-08-30 14:28:08 UTC
Permalink
Cool :-) 4.8?

Best
Martin
Paul de Weerd
2010-08-30 14:39:37 UTC
Permalink
On Mon, Aug 30, 2010 at 04:28:08PM +0200, Martin Schr?der wrote:
| 2010/8/27 Paul de Weerd <***@weirdnet.nl>:
| > This new uid stuff is really cool, thanks jsing@ !
|
| Cool :-) 4.8?

See revisions 1.161, 1.162, 1.163 and 1.164 of sbin/disklabel.c for a
smaple of some of the changes that were committed. These examples
were all ~4 months ago, so well before the lock for 4.8. Draw your
own conclusions from that :)

So, yeah, pre-order 4.8 as soon as you can !

Cheers,

Paul 'WEiRD' de Weerd

--
++++++++[<++++++++++>-]<+++++++.>+++[<------>-]<.>+++[<+
+++++++++++>-]<.>++[<------------>-]<+.--------------.[-]
http://www.undeadly.org

Bryan Irvine
2010-08-27 16:16:13 UTC
Permalink
Post by Marcus
how to fix fstab in single user mode for bootable "Live" USB drive
http://www.openbsd.org/faq/faq14.html#flashmemLive
If your target machine has an ahci(4) or SCSI interface, you will
probably find your USB drive's identifier changing. Having multiple
versions of your /etc/fstab file may make this easier to "fix" (in
single user mode).
Install OpenBSD to USB drive in a notbook. the usb drive is
recognized as "sd1"
Now put the USB drive into another PC an boot from USB. the usb dirve
is recognized as "sd0".
in the single user mode.
"fsck -p / && mount -uw /" not work
"fsck -p /usr && mount /usr" not work
"vi /etc/fstab" not work.
how to mount root / writable and active vi editor?
Without looking, I'd guess that you need to change the last step to

env TERM=vt100 vi /etc/fstab
sven falempin
2010-08-27 17:00:52 UTC
Permalink
Hello,

In older version, i used a script to modify the fstab during the boot,
something like : root_device=$(dmesg | awk '/root_device/ { print $1 });
perl -pe s/sd0/${root_device}/f -i /etc/fstab, looking for root_device in
dmesg
Sadly, we can't use root_device directly inside the fstab :(

vi won't work until you remount as read / write :mount -u

by
Post by Bryan Irvine
Post by Marcus
how to fix fstab in single user mode for bootable "Live" USB drive
http://www.openbsd.org/faq/faq14.html#flashmemLive
If your target machine has an ahci(4) or SCSI interface, you will
probably find your USB drive's identifier changing. Having multiple
versions of your /etc/fstab file may make this easier to "fix" (in
single user mode).
Install OpenBSD to USB drive in a notbook. the usb drive is
recognized as "sd1"
Now put the USB drive into another PC an boot from USB. the usb dirve
is recognized as "sd0".
in the single user mode.
"fsck -p / && mount -uw /" not work
"fsck -p /usr && mount /usr" not work
"vi /etc/fstab" not work.
how to mount root / writable and active vi editor?
Without looking, I'd guess that you need to change the last step to
env TERM=vt100 vi /etc/fstab
--
 No doubt it is one of the functions of art to replace religious faith by
the effective ingredient of beauty. At least beauty must have the power of a
poem, that is to say of a crime.
Loading...