2

I've got a problem writing changes in /etc/fstab files which make system read-only.

I have two drives on my laptop - SSD and HDD. I read a lot opinions about SSD optimization, someone says that nowadays there is not necessary to worry about, but I faced a problem trying to optimize SSD usage. Adding any optimizing options to partitions in fstab makes / read only after system restart.

Here is my fstab file:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda2 during installation
UUID=b6ebbe28-8654-4919-8094-5eee18954247 /               ext4    discard, noatime, errors=remount-ro 0 1
# /boot/efi was on /dev/sda1 during installation
UUID=A5F0-7D4E  /boot/efi       vfat    umask=0077      0       1
# /home was on /dev/sda4 during installation
UUID=1e4e6052-c8ba-4548-8ffd-457a4bc460bf /home           ext4    discard, noatime, defaults 0 2
# /var was on /dev/sdb1 during installation
UUID=d1fa1a62-eca1-4e13-8bf6-f30300a01cab /var            ext4    defaults        0       2
# swap was on /dev/sda3 during installation
UUID=69c38a83-596d-4ad1-ab87-599445c4e910 none            swap    sw              0       0

# moving temporary files from SSD to RAM
tmpfs /tmp tmpfs defaults 0 0
#tmpfs /var/tmp tmpfs defaults 0 0
#tmpfs /var/lock tmpfs defaults 0 0
#tmpfs /var/spool/postfix tmpfs defaults 0 0

UUID="ec529d46-81de-43e5-ad88-d50818f93421" /sghdd ext4 defaults 0 2

# mount MEDIA partition as sghdd folder
UUID="ec529d46-81de-43e5-ad88-d50818f93421" /sghdd ext4 defaults 0 2

# moving SSD/home folders to MEDIA
/sghdd/Downloads /home/ornichola/Downloads none bind 0 0
/sghdd/Public /home/ornichola/Public none bind 0 0
/sghdd/Videos /home/ornichola/Videos none bind 0 0
/sghdd/Pictures /home/ornichola/Pictures none bind 0 0
/sghdd/Music /home/ornichola/Music none bind 0 0

With adding any option (discard, noatime, relatime) to /dev/sda2 and /dev/sda4 problem occurs after system restart. All attempts to use aptitude are blocked according to read-only filesystem.

To avoid it I should boot from liveCD, mount my / partition and remove added options from fstab. After that I execute in liveCD system:

sudo mount -o remount,rw /dev/sda2 /

reboot to installed system, execute:

sudo fsck -n -f  

and only after it I can use aptitude again.

The main purpose of changing fstab is to add discard, relatime, nodiratime (or noatime) options to SSD partions. Why system is going to read-only?

Output of blkid:

ornichola@silver:~$ sudo blkid
/dev/sda1: LABEL="EFIBOOT" UUID="A5F0-7D4E" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="9a3525d1-9e84-4a06-84d2-2b96818ac1b8"
/dev/sda2: UUID="b6ebbe28-8654-4919-8094-5eee18954247" TYPE="ext4" PARTUUID="a5cd0868-f118-40a5-9ffd-09282504722d"
/dev/sda3: UUID="69c38a83-596d-4ad1-ab87-599445c4e910" TYPE="swap" PARTUUID="9199a9cb-9656-489f-83ef-4fe2800e6706"
/dev/sda4: UUID="1e4e6052-c8ba-4548-8ffd-457a4bc460bf" TYPE="ext4" PARTUUID="4bf6d060-a7bf-491d-ae53-da80b13c838d"
/dev/sdb1: UUID="d1fa1a62-eca1-4e13-8bf6-f30300a01cab" TYPE="ext4" PARTUUID="6c06b7b5-67dd-4b39-9f63-58c3876b9cfb"
/dev/sdb2: LABEL="MEDIA" UUID="ec529d46-81de-43e5-ad88-d50818f93421" TYPE="ext4" PARTUUID="869b4d14-7a3b-4eb3-b784-e6fbe3db5514"
ornichola@silver:~$ 

and ouput of fsck while system is read-only and options added to fstab:

ornichola@silver:~$ sudo fsck -n -f
fsck from util-linux 2.27.1
fsck: /etc/fstab: parse error at line 9 -- ignore
fsck: /etc/fstab: parse error at line 13 -- ignore
fsck.fat 3.0.28 (2015-05-16)
0x41: Dirty bit is set. Fs was not properly unmounted and some data may be corrupt.
 Automatically removing dirty bit.
Leaving filesystem unchanged.
/dev/sda1: 9 files, 870/130812 clusters
e2fsck 1.42.13 (17-May-2015)
Warning!  /dev/sdb1 is mounted.
Warning: skipping journal recovery because doing a read-only filesystem check.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong (4853291, counted=4853223).
Fix? no

Free inodes count wrong (1301362, counted=1301355).
Fix? no

/dev/sdb1: 9358/1310720 files (0.4% non-contiguous), 389589/5242880 blocks
e2fsck 1.42.13 (17-May-2015)
Warning!  /dev/sdb2 is mounted.
Warning: skipping journal recovery because doing a read-only filesystem check.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
MEDIA: 16/59744256 files (0.0% non-contiguous), 3800856/238947328 blocks
e2fsck 1.42.13 (17-May-2015)
Warning!  /dev/sdb2 is mounted.
Warning: skipping journal recovery because doing a read-only filesystem check.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
MEDIA: 16/59744256 files (0.0% non-contiguous), 3800856/238947328 blocks
ornichola@silver:~$ 
2
  • (...) nowadays there is not necessary to worry about Indeed. So, save yourself the trouble and do not change it.
    – user692175
    Aug 13, 2017 at 19:24
  • discard, noatime, errors=remount-ro MUST BE discard,noatime,errors=remount-ro. No spaces. The list of mount options (see man fstab) is a comma-separated list that ends at the first blank.
    – waltinator
    Aug 13, 2017 at 20:12

1 Answer 1

0

Edit your /etc/fstab:

In terminal...

gksudo gedit /etc/fstab

Change this:

# / was on /dev/sda2 during installation
UUID=b6ebbe28-8654-4919-8094-5eee18954247 /               ext4    discard, noatime, errors=remount-ro 0 1
# /home was on /dev/sda4 during installation
UUID=1e4e6052-c8ba-4548-8ffd-457a4bc460bf /home           ext4    discard, noatime, defaults 0 2

To this:

# / was on /dev/sda2 during installation
UUID=b6ebbe28-8654-4919-8094-5eee18954247 /               ext4    discard,noatime,errors=remount-ro 0 1
# /home was on /dev/sda4 during installation
UUID=1e4e6052-c8ba-4548-8ffd-457a4bc460bf /home           ext4    discard,noatime,defaults 0 2

And, to properly fsck your system and repair errors...

To check the file system on your Ubuntu partition...

  • boot to the GRUB menu
  • choose Advanced Options
  • choose Recovery mode
  • choose Root access
  • at the # prompt, type sudo fsck -f / # check /
  • at the # prompt, type sudo fsck -f /dev/sda4 # check /home
  • at the # prompt, type sudo fsck -f /dev/sdb1 # check /var
  • repeat the fsck command if there were errors
  • type reboot
2
  • @ornichola Thanks for the update! Did the fsck work ok for you?
    – heynnema
    Aug 13, 2017 at 20:53
  • Yes, I executed it, no errors were found.
    – ornichola
    Aug 13, 2017 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.