Solved How do I modify fstab from single user mode?

clawhammer

Active Member

Reaction score: 6
Messages: 182

I am trying to get my freebsd 11.2 to boot but I need to modify the fstab file but it says its a read only file system.

I boot into single user mode from the usb install stick.

It is not booting into the system. I have CSM enabled in my bios.

Code:
       40  250069600    ada0    GPT (119G)
       40  1024         ada0p1  freebsd-boot (512k)
     1064  408576     - free -               (200M)
   409640  240762880    ada0p2  freebsd-ufs  (115G)
241172520  8388608      ada0p3  freebsd-swap (4.0G)
249561128  508512     - free -               (248M)
 

kpa

Beastie's Twin

Reaction score: 1,847
Messages: 6,318

You need to do this sequence of commands (if your filesystems are UFS):

Code:
mount -u /
mount -a -t ufs

If using ZFS the sequence changes to:

Code:
mount -u /
zfs mount -a
 
OP
clawhammer

clawhammer

Active Member

Reaction score: 6
Messages: 182

You need to do this sequence of commands (if your filesystems are UFS):

Code:
mount -u /
mount -a -t ufs

If using ZFS the sequence changes to:

Code:
mount -u /
zfs mount -a

that didnt work. Am I booting into the usb stick instead of the system on my computer?
Code:
ex/vi : Error /var/tmp/vi.recover/: Read-only file system
ex/vi : Modifications not recoverable if the session fails
ex/vi : Error : fstab: Read-only file system
ex/vi : Error : Unable to create temporary file: Read-only file system

when i
Code:
cat fstab
I get
Code:
 /dev/ufs/FreeBSD-Install / ufs ro,noatime 1 1
 

leebrown66

Well-Known Member

Reaction score: 174
Messages: 445

As you are booting from the USB, you need to mount the root partition from your HD somewhere, like:

mount /dev/ada0p2 -o rw /mnt

and now you can edit it

vi /mnt/etc/fstab
 

kpa

Beastie's Twin

Reaction score: 1,847
Messages: 6,318

Oh right, I missed the detail that the OP is booting from the USB stick.

It might turn out that the /mnt directory is read-only when booting from the USB stick and in that case you need to use the /tmp folder that is read-write:

mkdir /tmp/mnt
mount -t ufs -o rw /dev/ada0p2 /tmp/mnt
 

leebrown66

Well-Known Member

Reaction score: 174
Messages: 445

It might turn out that the /mnt directory is read-only when booting from the USB stick and in that case you need to use the /tmp folder that is read-write:[/CMD]
That doesn't matter, you can mount onto a r/o file system:

svr-varserver-rl# cat /etc/fstab
/dev/ada0p2 / ufs ro 1 1
/dev/ada1 /metrics ufs rw 2 2

svr-varserver-rl# mount
/dev/ada0p2 on / (ufs, local, read-only)
/dev/ada1 on /metrics (ufs, local)
 
OP
clawhammer

clawhammer

Active Member

Reaction score: 6
Messages: 182

Oh right, I missed the detail that the OP is booting from the USB stick.

It might turn out that the /mnt directory is read-only when booting from the USB stick and in that case you need to use the /tmp folder that is read-write:

mkdir /tmp/mnt
mount -t ufs -o rw /dev/ada0p2 /tmp/mnt
I did that and looked at the fstab file and it says
Code:
 /dev/ada0p2 / ufs  rw 1 1
/dev/ada0p3 none swap sw 0 0

but my system still wont boot.
 

leebrown66

Well-Known Member

Reaction score: 174
Messages: 445

but my system still wont boot.

Can you provide more information than "wont boot"? Do you get the bootloader? Does it load the kernel? Are any error messages displayed?

You may need to repair the filesystem, you'll need to use fsck(8) for that before you mount the fs.
 
OP
clawhammer

clawhammer

Active Member

Reaction score: 6
Messages: 182

Can you provide more information than "wont boot"? Do you get the bootloader? Does it load the kernel? Are any error messages displayed?

You may need to repair the filesystem, you'll need to use fsck(8) for that before you mount the fs.

It goes right to the bios.
 

ShelLuser

Son of Beastie

Reaction score: 2,097
Messages: 3,790

but when I install ubuntu it works.
Well, we'll just have to take your word for that then. Getting into the BIOS/CMOS settings is not something an operating system can control, that happens way before a boot process is even attempted. In more modern environments this is also often achieved through EFI but your partitioning scheme shows nothing of that.
 

leebrown66

Well-Known Member

Reaction score: 174
Messages: 445

From wikipedia (UEFI CSM booting)

I reckon you may have a CSM that boots only from MBR, not GPT. Or you have more options and need to select a different boot mode.

Either:
  • Try with MBR instead of GPT
  • Boot with EFI

CSM booting
To ensure backward compatibility, most UEFI firmware implementations on PC-class machines also support booting in legacy BIOS mode from MBR-partitioned disks, through the Compatibility Support Module (CSM) that provides legacy BIOS compatibility. In this scenario, booting is performed in the same way as on legacy BIOS-based systems, by ignoring the partition table and relying on the content of a boot sector.[36]

BIOS-style booting from MBR-partitioned disks is commonly called BIOS-MBR, regardless of it being performed on UEFI or legacy BIOS-based systems. Furthermore, booting legacy BIOS-based systems from GPT disks is also possible, and such a boot scheme is commonly called BIOS-GPT.

The Compatibility Support Module allows legacy operating systems and some option ROMs that do not support UEFI to still be used.[42] It also provides required legacy System Management Mode (SMM) functionality, called CompatibilitySmm, as an addition to features provided by the UEFI SMM. This is optional and highly chipset- and platform-specific. An example of such a legacy SMM functionality is providing USB legacy support for keyboard and mouse, by emulating their classic PS/2 counterparts.[42]

In November 2017, Intel announced that it planned to phase out support for CSM by 2020.[43]
 

leebrown66

Well-Known Member

Reaction score: 174
Messages: 445

That sounds like you didn't reinstall the OS as MBR. The disk scheme must match the boot scheme.
 
OP
clawhammer

clawhammer

Active Member

Reaction score: 6
Messages: 182

That sounds like you didn't reinstall the OS as MBR. The disk scheme must match the boot scheme.

Code:
 ada0 gpt
ada0p1 efi
ada0p2 freebsd-ufs
ada0p3 freebsd-swap

is that the correct way to partition for efi?

when I install as mbr after i reboot I get a message saying Reboot and select proper boot device or insert boot media in selected boot device and press a key.
 

leebrown66

Well-Known Member

Reaction score: 174
Messages: 445

Yes, that looks correct.
And the EFI partition (msdosfs) has 2 files,
[FONT=Courier New]/BOOT/BOOTX64.EFI
/BOOT/STARTUP.NSH[/FONT]
 
OP
clawhammer

clawhammer

Active Member

Reaction score: 6
Messages: 182

Yes, that looks correct.
And the EFI partition (msdosfs) has 2 files,
[FONT=Courier New]/BOOT/BOOTX64.EFI
/BOOT/STARTUP.NSH[/FONT]
is
Code:
/dev/ada0p2 / ufs rw 1 1
/dev/ada0p3 none swap sw 0 0

the correct fstab for the gpt efi?
 

leebrown66

Well-Known Member

Reaction score: 174
Messages: 445

Absolutely, you'll just need to mount the partition. Assuming you are still booting off the usb install media, go into the shell and you should be able to:

# mount -t msdosfs /dev/da0p1 /mnt
# find /mnt


If you find they are missing, you should be able to:

# umount /mnt
# dd if=/boot/boot1.efifat of=/dev/da0p1


PLEASE triple check the device name before issuing that dd command (setup steps found in the UEFI Wiki, Bootable UEFI memory stick or Hard Disk section)

Then mount it and check those files are there.
 
OP
clawhammer

clawhammer

Active Member

Reaction score: 6
Messages: 182

i mounted ada0p1 and did find /mnt and it get
Code:
/mnt
/mnt/efi/
/mnt/efi/boot/
/mnt/efi/boot/bootx64.efi
/mnt/efi/boot/startup.nsh
 

leebrown66

Well-Known Member

Reaction score: 174
Messages: 445

OK, then it *should* boot as standard EFI, compatibility mode turned off.

It's been a while since I setup an EFI system. I seem to remember having to give permission for FreeBSD to boot from the BIOS EUFI menu.
 
OP
clawhammer

clawhammer

Active Member

Reaction score: 6
Messages: 182

it goes right into the bios. i have american megatrends bios version 218.

When I do a fresh install with MBR it doesnt boot into bios but after the asus screen shows it says to insert boot media and press any key. And when I do go into the bios with MBR partition is shows my ssd as a boot option but it doesnt show it when I install with GPT.
 

leebrown66

Well-Known Member

Reaction score: 174
Messages: 445

There's a method to manually choose the boot device on startup. Try that and see if it's listed. I am about out of ideas here though, it seems you can only boot the USB stick, which doesn't make much sense.

I think the FreeBSD-hardware mailing list might be your next best stop.
 
Top