Help me!! /var become read only, can't able to install anything

**Hello everyone,
I am using opensuse 15.2 leap KDE. last few days i got a prob with package manager. i get this following errors when i tried to install any software.

The error i getting **

localhost:/home/geek # zypper up

Error: Subprocess failed. Error: RPM failed: error: can’t create transaction lock on /var/lib/rpm/.rpm.lock (Read-only file system)

output of .rpm.lock file permission

-rw-r–r-- 1 root root 0 Nov 4 23:24 /var/lib/rpm/.rpm.lock

When i tried to delete that file i get the following error

rm: cannot remove ‘/var/lib/rpm/.rpm.lock’: Read-only file system

**My fstab file contain these lines
**
*

cat /etc/fstab
UUID=2615b4a0-300b-4505-8910-f38caed752ac / btrfs defaults 0 0
UUID=2615b4a0-300b-4505-8910-f38caed752ac /var btrfs subvol=/@/var 0 0
UUID=2615b4a0-300b-4505-8910-f38caed752ac /usr/local btrfs subvol=/@/usr/local 0 0
UUID=2615b4a0-300b-4505-8910-f38caed752ac /tmp btrfs subvol=/@/tmp 0 0
UUID=2615b4a0-300b-4505-8910-f38caed752ac /srv btrfs subvol=/@/srv 0 0
UUID=2615b4a0-300b-4505-8910-f38caed752ac /root btrfs subvol=/@/root 0 0
UUID=2615b4a0-300b-4505-8910-f38caed752ac /opt btrfs subvol=/@/opt 0 0
UUID=2615b4a0-300b-4505-8910-f38caed752ac /home btrfs subvol=/@/home 0 0
UUID=2615b4a0-300b-4505-8910-f38caed752ac /boot/grub2/x86_64-efi btrfs subvol=/@/boot/grub2/x86_64-efi 0 0
UUID=2615b4a0-300b-4505-8910-f38caed752ac /boot/grub2/i386-pc btrfs subvol=/@/boot/grub2/i386-pc 0 0
UUID=2615b4a0-300b-4505-8910-f38caed752ac /.snapshots btrfs subvol=/@/.snapshots 0 0

**Mount command output is here
**
*

mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs (rw,nosuid,size=1950956k,nr_inodes=487739,mode=755)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
none on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/rdma type cgroup (rw,nosuid,nodev,noexec,relatime,rdma)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
/dev/sda2 on / type btrfs (rw,relatime,ssd,space_cache,subvolid=409,subvol=/@/.snapshots/83/snapshot)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,pagesize=2M)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=36,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=15729)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
/dev/sda2 on /.snapshots type btrfs (rw,relatime,ssd,space_cache,subvolid=266,subvol=/@/.snapshots)
/dev/sda2 on /srv type btrfs (rw,relatime,ssd,space_cache,subvolid=260,subvol=/@/srv)
/dev/sda2 on /var type btrfs (rw,relatime,ssd,space_cache,subvolid=257,subvol=/@/var)
/dev/sda2 on /root type btrfs (rw,relatime,ssd,space_cache,subvolid=261,subvol=/@/root)
/dev/sda2 on /tmp type btrfs (rw,relatime,ssd,space_cache,subvolid=259,subvol=/@/tmp)
/dev/sda2 on /opt type btrfs (rw,relatime,ssd,space_cache,subvolid=262,subvol=/@/opt)
/dev/sda2 on /boot/grub2/x86_64-efi type btrfs (rw,relatime,ssd,space_cache,subvolid=264,subvol=/@/boot/grub2/x86_64-efi)
/dev/sda2 on /home type btrfs (rw,relatime,ssd,space_cache,subvolid=263,subvol=/@/home)
/dev/sda2 on /boot/grub2/i386-pc type btrfs (rw,relatime,ssd,space_cache,subvolid=265,subvol=/@/boot/grub2/i386-pc)
/dev/sda2 on /usr/local type btrfs (rw,relatime,ssd,space_cache,subvolid=258,subvol=/@/usr/local)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=392320k,mode=700,uid=1000,gid=100)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=100)
tracefs on /sys/kernel/debug/tracing type tracefs (rw,relatime)
/dev/sda1 on /run/media/geek/home dont delete type ext4 (rw,nosuid,nodev,relatime,uhelper=udisks2)
/dev/sda4 on /run/media/geek/2670E26E70E24461 type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096,uhelper=udisks2)

How do i make my /var directory as read/write permissions.
someone please help me im very new to opensuse

Hi,
Welcome to openSUSE.
How long has it been since this machine was installed?
Did you use the DVD or NET installs from https://software.opensuse.org?
Were you able to install software or update your system immediately after your system was installed?
Are you touching your machine at all during the boot process?
Have you opened the YaST bootloader module at all?

BTW -
Although I don’t think it should help in this situation, you might watch my slide deck introducing openSUSE that describes the openSUSE installation and first recommended actions after installation useful

http://slides.com/tonysu/opensuse

TSU

The normal way to fix a ro file system is to boot a recovery media and run fsck on the problem drive. It might be called btrfsck.

FSCK stands for file system checker.

It works every time for ext4 - I would hope it works for btrfs as well. I hope that btrfsck does that for all the subvolumes.

“btrfsck” is deprecated.

  • Use “btrfs check /”.

But, the root (Btrfs) partition is mounted – therefore, even if one tries this from “systemctl rescue”, the “–force” option will have to be used …
[HR][/HR]The better way, is to boot the openSUSE Leap 15.2 installation medium and, select “Rescue System” – <https://doc.opensuse.org/documentation/leap/startup/html/book-opensuse-startup/cha-trouble.html#sec-trouble-data-recover-rescue&gt;.

  • Mount the Btrfs system partition – possibly /dev/sda2 – on /mnt and then perform “btrfs check /mnt/???” …

@ashwini:

What are the protections on the following directories:

  1. /var
  2. /var/lib
  3. /var/lib/rpm
  4. /usr
  5. /usr/lib
  6. /usr/lib/sysimage
  7. /usr/lib/sysimage/rpm

 # l -d /var
drwxr-xr-x 13 root root 4096 10. Nov 15:59 /var/
 # l -d /var/lib
drwxr-xr-x 71 root root 4096  9. Sep 09:36 /var/lib/
 # l -d /var/lib/rpm
lrwxrwxrwx 1 root root 26  8. Jun 2020  /var/lib/rpm -> ../../usr/lib/sysimage/rpm/
 # 
 # l -d /usr
drwxr-xr-x 11 root root 4096 20. Sep 2019  /usr/
 # l -d /usr/lib
drwxr-xr-x 94 root root 4096 26. Nov 17:30 /usr/lib/
 # l -d /usr/lib/sysimage
drwxr-xr-x 3 root root 4096 19. Aug 11:43 /usr/lib/sysimage/
 # l -d /usr/lib/sysimage/rpm
drwxr-xr-x 2 root root 4096 19. Aug 11:45 /usr/lib/sysimage/rpm/
 # 

It is possible that, the automated Btrfs balance run by a systemd service, was being executed on an almost full file system.

  • Please check the amount of free space on the Btrfs system partition – “btrfs filesystem df /

Hard to guess what went wrong without more info…
eg
Are you booted into rescue mode?
Is your Grub messed up?

In any case,
If you know when the problem first started happening, maybe a BTRFS snapshot rollback to a checkpoint before your problem appeared can work.
If you have the install DVD, maybe an “upgrade” will re-install enough that removes whatever mis-configuration exists.

TSU