Page 1 of 1
File system is read-only but shouldn't be
Posted: Tue Feb 24, 2015 2:40 am
by marian42
Hi,
I tried to install owncloud on my rpi and somehow it failed.
Now every command I use returns some error message that says my file system is read-only.
Owncloud isn't really my priority anymore (altough it woudl be nice to have), I just want everything else to work again...
For example, apache won't start because it can't get write access to /var/log/apache2/error.log
What can I do to make apache and everything else run again?
Thanks
Re: File system is read-only but shouldn't be
Posted: Tue Feb 24, 2015 5:18 pm
by cpc464
Put your SD card into another linux system and do an fsck on it.
Re: File system is read-only but shouldn't be
Posted: Tue Feb 24, 2015 6:13 pm
by marian42
Code: Select all
fsck from util-linux 2.25.1
e2fsck 1.42.10 (18-May-2014)
ext2fs_open2: Bad magic number in super-block
fsck.ext2: Superblock invalid, trying backup blocks...
fsck.ext2: Bad magic number in super-block while trying to open /dev/mmcblk0p1
The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem. If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>
or
e2fsck -b 32768 <device>
Not sure if this was the correct device though.
Re: File system is read-only but shouldn't be
Posted: Tue Feb 24, 2015 6:20 pm
by DirkS
marian42 wrote:Not sure if this was the correct device though.
It wasn't. You checked the first partition on the sd card, and it's probably the FAT partition
Did you do as suggested and use an SD card reader in another Pi (or other Linux system)?
In that case the partition to check is most likely /dev/sda2
Re: File system is read-only but shouldn't be
Posted: Tue Feb 24, 2015 6:28 pm
by marian42
I used a laptop with ubuntu.
Code: Select all
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 238.5G 0 disk
├─sda1 8:1 0 300M 0 part
├─sda2 8:2 0 100M 0 part /boot/efi
├─sda3 8:3 0 128M 0 part
├─sda4 8:4 0 194.8G 0 part
└─sda5 8:5 0 33.9G 0 part /
mmcblk0 179:0 0 7.4G 0 disk
└─mmcblk0p1 179:1 0 3.7G 0 part
The sd card has 8GB, so by the size it should be the last one.
Re: File system is read-only but shouldn't be
Posted: Tue Feb 24, 2015 7:26 pm
by DougieLawson
It looks like something has trashed the partition table on that device.
Do you have a backup?
Re: File system is read-only but shouldn't be
Posted: Tue Feb 24, 2015 7:30 pm
by marian42
I don't have one that is up to date.
Could the pi boot with a broken partition table? (It does boot)
Re: File system is read-only but shouldn't be
Posted: Tue Feb 24, 2015 7:38 pm
by DougieLawson
Any backup is OK, we only need to look at the partition table with sudo fdisk -l to get the start & end sectors, length and format for each partition.
We can then write a new partition table to the borked card and that should fix the damage.
Re: File system is read-only but shouldn't be
Posted: Tue Feb 24, 2015 7:52 pm
by marian42
I have an .img file from December 2013, this should do it.
Re: File system is read-only but shouldn't be
Posted: Tue Feb 24, 2015 7:55 pm
by DougieLawson
You can run fdisk -l against that *.img.
Re: File system is read-only but shouldn't be
Posted: Tue Feb 24, 2015 8:13 pm
by marian42
From the image:
Code: Select all
fdisk -l rpi.img
Disk rpi.img: 3.8 GiB, 4075290624 bytes, 7959552 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000f06b6
Device Boot Start End Sectors Size Id Type
rpi.img1 2048 2466796 2464749 1.2G e W95 FAT16 (LBA)
rpi.img2 2473984 7959551 5485568 2.6G 85 Linux extended
rpi.img5 2482176 2596863 114688 56M c W95 FAT32 (LBA)
rpi.img6 2605056 7959551 5354496 2.6G 83 Linux
Without the image:
Code: Select all
sudo fdisk -l
Disk /dev/sda: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 8C1EF8C0-4264-4568-BDC1-752906F0CD69
Device Start End Sectors Size Type
/dev/sda1 2048 616447 614400 300M Windows recovery environment
/dev/sda2 616448 821247 204800 100M EFI System
/dev/sda3 821248 1083391 262144 128M Microsoft reserved
/dev/sda4 1083392 409602047 408518656 194.8G Microsoft basic data
/dev/sda5 409602048 480585727 70983680 33.9G Linux filesystem
Disk /dev/mmcblk0: 7.4 GiB, 7948206080 bytes, 15523840 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000f06b6
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 2466796 2464749 1.2G e W95 FAT16 (LBA)
/dev/mmcblk0p2 2473984 15523839 13049856 6.2G 85 Linux extended
/dev/mmcblk0p5 2482176 2596863 114688 56M c W95 FAT32 (LBA)
/dev/mmcblk0p6 2605056 15523839 12918784 6.2G 83 Linux
Not sure if the partition table is actually broken.
Re: File system is read-only but shouldn't be
Posted: Tue Feb 24, 2015 8:19 pm
by DougieLawson
You're comparing apples vs oranges.
The image is a 4GB card the broken one is an 8GB card.
But generally the start sectors are identical. So that bit is OK.
Re: File system is read-only but shouldn't be
Posted: Wed Feb 25, 2015 4:50 am
by marian42
Solution: The problem was caused by a wrong edit to the /etc/fstab file. I could gain write access by remounting /dev/sda and edited the fstab file. Now everything works fine, I could even get owncloud to work. Thank you for helping
Re: File system is read-only but shouldn't be
Posted: Wed Feb 25, 2015 9:32 am
by cpc464
Good news.
You fixed it by mounting the Pi partition on another Linux system and fixing the /etc/fstab file.
What was the fix to the file, for people having this problem in future ?
Just a note about fsck: Not sure what fsck command you used, but fsck has to be run on the partition with the suspected problem. In your case this would have been
fsck /dev/mmcblk0p2
or
fsck /dev/mmcblk0p6
The "bad magic number" messages are often caused by using the wrong device. Sometimes people typing something like fsck /dev/mmcblk0 (a devfice referring to the whole device, not the partition).
Cheers,
Jim
Re: File system is read-only but shouldn't be
Posted: Thu Feb 26, 2015 9:33 pm
by marian42
You fixed it by mounting the Pi partition on another Linux system and fixing the /etc/fstab file.
I actually did it by remounting /dev/sda on the pi itself. I first thought that this wasn't possible because I was using the mount commant wrong.
What was the fix to the file, for people having this problem in future ?
The file was fine and I broke it by adding "permissions" to the root filesystem. It should go to an entry for an NTFS hard drive.
Re: File system is read-only but shouldn't be
Posted: Thu Feb 26, 2015 9:46 pm
by ioha
see marian42, you got it finally. congrats
