I try to automount new disk but end up with "readonly filesystem"

I added a disk but disk happen to be damaged. I uninstall disk and try to mount another

I formatted new disk as ext4 and try to add to automount following this manual [OpenWrt Wiki] Using storage devices but get an I/O Error and “readonly filesystem”

root@OpenWrt:~# block detect | uci import fstab
uci: I/O error

I try to fix it by e2fsck -p but with no success, cause disk is mounted. Is there a solution or I need to reinstall OpenWRT completely?

Here is

uci show fstab 

from previous disk which I can not change now, because of “I\O error”

root@OpenWrt:~# uci show fstab
fstab.@global[0]=global
fstab.@global[0].anon_swap='0'
fstab.@global[0].anon_mount='0'
fstab.@global[0].auto_swap='1'
fstab.@global[0].auto_mount='1'
fstab.@global[0].delay_root='5'
fstab.@global[0].check_fs='0'
fstab.@mount[0]=mount
fstab.@mount[0].target='/mnt/sda1'
fstab.@mount[0].uuid='931ec4f7-ff2f-4fc9-8e54-a1dda25612ca'
fstab.@mount[0].enabled='0'
fstab.@mount[1]=mount
fstab.@mount[1].target='/boot'
fstab.@mount[1].uuid='84173db5-fa99-e35a-95c6-28613cc79ea9'
fstab.@mount[1].enabled='0'
fstab.@mount[2]=mount
fstab.@mount[2].target='/'
fstab.@mount[2].uuid='ff313567-e9f1-5a5d-9895-3ba130b4a864'
fstab.@mount[2].enabled='1'

UPD: Yay! I managed to fix it!

fsck.ext4 -f /dev/sdb2

found some errors and I rebooted and then

mount -o remount,rw /

did it! I can create folders and edit files again!

You could try block umount and then e2fsck -p /dev/sda1. Or change fstab.@global[0].auto_mount to 0 and reboot, then the e2fsck.

However, are you sure the filesystem is the issue and not the disk hardware?

Finallly, I note you have fstab.@mount[2].enabled=’1’ for /. If your root filesystem has issues you should either check the root disk on a another system, or boot into failsafe mode and check the root disk there.

One final note: more complete output of logread and dmesg are likely needed to further troubleshoot.

2 Likes

Thank you. Could you please clarify should I leave my /etc/config/fstab as is with /dev/sdb1 and /dev/sdb2 or as it is shown in manual I only need /dev/sda1?

I mean system partitions are not needed to be mounted via fstab, aren’t they? So I can only keep info only on /dev/sda1 I believe?

@alive-one For clarification: are you using an extroot on /dev/sdb2 ? Also what device/architecture?

I use x86 architecture and ext4 filesystem


root@OpenWrt:~# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda      8:0    0  149G  0 disk
└─sda1   8:1    0  149G  0 part /mnt/data
sdb      8:16   1  3.8G  0 disk
├─sdb1   8:17   1   32M  0 part /boot
│                               /boot
└─sdb2   8:18   1    2G  0 part /
root@OpenWrt:~# block info
/dev/sda1: UUID="6c313ded-259f-450a-a556-e5ab93793070" VERSION="1.0" MOUNT="/mnt/data" TYPE="ext4"
/dev/sdb1: UUID="84173db5-fa99-e35a-95c6-28613cc79ea9" LABEL="kernel" VERSION="1.0" MOUNT="/boot" TYPE="ext4"
/dev/sdb2: UUID="ff313567-e9f1-5a5d-9895-3ba130b4a864" LABEL="rootfs" VERSION="1.0" MOUNT="/" TYPE="ext4"
root@OpenWrt:~#

I deleted lines on system partitions from fstab and it seems everithing works


root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 1.9G    322.4M      1.6G  16% /
tmpfs                   490.9M    240.0K    490.7M   0% /tmp
/dev/sdb1                31.5M      6.1M     24.8M  20% /boot
/dev/sdb1                31.5M      6.1M     24.8M  20% /boot
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/sda1               145.6G      2.0M    138.2G   0% /mnt/data

here is /etc/config/fstab


config global
        option anon_swap '0'
        option anon_mount '0'
        option auto_swap '1'
        option auto_mount '1'
        option delay_root '5'
        option check_fs '0'

config mount
        option target '/mnt/data'
        option uuid '6c313ded-259f-450a-a556-e5ab93793070'
        option enabled '1'

#config mount
#       option target '/boot'
#       option uuid '84173db5-fa99-e35a-95c6-28613cc79ea9'
#       option enabled '0'
#
#config mount
#       option target '/rom'
#       option uuid 'ff313567-e9f1-5a5d-9895-3ba130b4a864'
#       option enabled '1'

I guess I could create fstab manually, then use commands

/etc/init.d/fstab enable
/etc/init.d/fstab start

to enable automounting deamon?

UPD: No one answer me in prevouus topic on this matter so I would be very grateful if you clarify this: Can I use such flags as:

option options 'rw,noatime,nosuid,noexec,nodev'

for more secure mounting? I believe this flags restrict execution of command files for device and since I have only data files, may be it is my option for better security?

you can use them, but ...

what are you going to execute then ?

RTFM: https://man7.org/linux/man-pages/man8/mount.8.html

1 Like

To check the "/" (your /dev/sdb1) and "/boot" (your /dev/sdb2) filesystems, boot a live distribution and run it with the "e2fsck" utility.

for all other partitions you can do an "umount" and run "e2fsck" partitions

example for your /dev/sda1 mount /mnt/data:

umount /dev/sda1; e2fsck /dev/sda1 && mount /dev/sda1 /mnt/data

https://www.reddit.com/r/debian/comments/160222b/what_is_the_best_way_of_booting_to_run_fsck_on/

ps: I also add this to the documents that I recommend you read:

2 Likes

This may help: https://openwrt.org/docs/guide-user/storage/fstab

Also, for the available mount options in OpenWrt see: https://git.openwrt.org/?p=project/fstools.git;a=blob;f=block.c;hb=HEAD#l167 through to line 193

1 Like

I just do not want any process to be able to execute files from this device for the sake of secturity reasons. Because, well, if evil people will hack this device they will not be able to execute their evil files from this device and fail in achieving beautiful pictures of my gorgeous cat for free.

Your whole device isn't read only, only this mount.

1 Like

Anyway, here is safe (I hope) config I end up with:

config global
    option anon_swap '0'
    option anon_mount '0'
    option auto_swap '1'
    option auto_mount '1'
    option delay_root '5'
    option check_fs '0'

config mount
    option target '/mnt/data'
    option uuid '6c313ded-259f-450a-a556-e5ab93793070'
    option options 'rw,noatime,nosuid,noexec,nodev'
    option enabled '1'
1 Like