Moving my /tmp directory to it's own partition, works great until reboot, starts in read-only

I wanted to move my /tmp directory to it’s own partition, first I checked that the systemd tmpfs wasn’t being used, which it wasn’t.

changed to Init 1
I created a new xfs partition
mounted to a temporary mount under /foo
cp -apx /tmp/. /foo
umount /foo
mv /tmp /tmp.old
mkdir /tmp
chmod 1777 /tmp
change /etc/fstab with uuid of new /tmp partition
mount -a
df -h to see if it’s there and right partition, looks good
Init 5
sddm starts fine
login to kde everything is fine
reboot

Now it comes up in tty in read-only mode, I can remount to rw, rem out my fstab change and go back to old /tmp.

Any ideas why it won’t work on reboot?

Given an fstab entry like this:

/dev/disk/by-id/ata-XXXXX-part1  /tmp    ext4    defaults,noatime,acl,user_xattr 1 2

when you “stat” the /tmp directory, it should look like this:


 # stat /tmp
  File: /tmp
  Size: 36864           Blocks: 80         IO Block: 4096   directory
Device: 821h/2081d      Inode: 2           Links: 37
Access: (1777/drwxrwxrwt)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2019-06-03 16:57:13.896425268 +0200
Modify: 2019-06-03 17:02:03.629812111 +0200
Change: 2019-06-03 17:02:03.629812111 +0200
 Birth: -
 # 

You could consider using the YaST Partitioner to move /tmp and, possibly, /var , off to their own partitions …
Documentation is here: <https://doc.opensuse.org/documentation/leap/reference/html/book.opensuse.reference/cha.expert_partitioner.html&gt;.
There’s some additional information here: <https://doc.opensuse.org/documentation/leap/startup/html/book.opensuse.startup/cha.install.html#sec.yast_install.partitioning&gt;.

I didn’t see anything in partitioner or the docs you linked about moving an existing /tmp. Before I did my almost successful attempt, I had actually tried partitioner and set a mount point to /tmp, I didn’t think it would work, because of the existing /tmp directory that is being used, and the text mode yast in init 1 gave me a ruby error when I tried to launch partitioner. It created the fstab entry but didn’t work at all, which is what I suspected to begin with.

Since most of the things I could find for moving directories followed the steps I outlined, including
https://www.suse.com/support/kb/doc/?id=7015338

So that’s what I did, though /tmp also needs the chmod.

As I said everything looks good with df -h, even the stat /tmp and everything is fine when I go to init 5, I can even hibernate and power back up completely fine. But on full reboot it comes up read-only with /tmp unmounted, if I remount the system with rw, and do a mount -a, then init 5, I’m all fine again using the new /tmp partition. I have run filesystem check on the new partition, it’s fine, I have also run smartdisk on the drive, it’s fine as well.

So what could cause it to be completely error free when doing mount -a, or power on from hibernate, but cause a problem on full reboot?

Looks like it doesn’t get mounted at all, but … normally ( on default install ) /tmp is a subvolume of btrfs, which gets mounted as a tmpfs.

Sorry I should have said, I set up my Tumbleweed as all xfs, so there is no btrfs in play. I checked to make sure before everything that it wasn’t tmpfs or setup by systemd to be tmpfs, since systemd doesn’t do it in fstab, and systemd tmp.mount was masked.

Ok fixed it, my last post made me think a bit more about systemd which I am still pretty weak on knowledge wise. The tmp.mount unit was masked probably for the default way opensuse handles /tmp with btrfs, I thought this would be fine, but masking, seems to be a hard off to /dev/null to any kind of mounting of /tmp, not just turning off systemd tmpfs /tmp. So I unmasked tmp.mount and now everything works and is mounted properly.

Yes, the systemd “tmp.mount” service, which doesn’t have a “.service” in the name, is quite surprising, especially when one takes a look at the “big (mount) picture”:


 # systemctl list-unit-files | grep -i 'mount'
proc-sys-fs-binfmt_misc.automount                                static         
-.mount                                                          generated      
dev-hugepages.mount                                              static         
dev-mqueue.mount                                                 static         
home.mount                                                       generated      
home01.mount                                                     generated      
proc-fs-nfsd.mount                                               static         
proc-sys-fs-binfmt_misc.mount                                    static         
srv.mount                                                        generated      
sys-fs-fuse-connections.mount                                    static         
sys-kernel-config.mount                                          static         
sys-kernel-debug.mount                                           static         
tmp.mount                                                        generated      
var-lib-machines.mount                                           static         
var-lib-nfs-rpc_pipefs.mount                                     static         
var-lock.mount                                                   static         
var-run.mount                                                    static         
var.mount                                                        generated      
dracut-mount.service                                             static         
dracut-pre-mount.service                                         static         
nfs-mountd.service                                               static         
systemd-remount-fs.service                                       static         
umount.target                                                    static         
 # 

Taking a look at the “generated” services reveals:


 # systemctl status -- -.mount tmp.mount var.mount srv.mount home.mount home01.mount
● -.mount - Root Mount
   Loaded: loaded (/etc/fstab; generated; vendor preset: disabled)
   Active: active (mounted) since Thu 2019-06-06 08:03:24 CEST; 1h 50min ago
    Where: /
     What: /dev/sda1
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/-.mount

Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

● tmp.mount - /tmp
   Loaded: loaded (/etc/fstab; generated; vendor preset: disabled)
   Active: active (mounted) since Thu 2019-06-06 08:03:27 CEST; 1h 50min ago
    Where: /tmp
     What: /dev/sdc1
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)
  Process: 754 ExecMount=/usr/bin/mount /dev/disk/by-id/ata-ST3500418AS_Z2AENPNG-part1 /tmp -t ext4 -o defaults,noatime>
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/tmp.mount

Jun 06 08:03:27 XXX systemd[1]: Mounting /tmp...
Jun 06 08:03:27 XXX systemd[1]: Mounted /tmp.

● var.mount - /var
   Loaded: loaded (/etc/fstab; generated; vendor preset: disabled)
   Active: active (mounted) since Thu 2019-06-06 08:03:27 CEST; 1h 50min ago
    Where: /var
     What: /dev/sdb1
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)
  Process: 688 ExecMount=/usr/bin/mount /dev/disk/by-id/ata-WDC_WD10EZEX-60M2NA0_WD-WCC3F5AYCJL7-part1 /var -t ext4 -o >
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/var.mount

Jun 06 08:03:27 XXX systemd[1]: Mounting /var...
Jun 06 08:03:27 XXX systemd[1]: Mounted /var.

● srv.mount - /srv
   Loaded: loaded (/etc/fstab; generated; vendor preset: disabled)
   Active: active (mounted) since Thu 2019-06-06 08:03:27 CEST; 1h 50min ago
    Where: /srv
     What: /dev/sdc2
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)
  Process: 686 ExecMount=/usr/bin/mount /dev/disk/by-id/ata-ST3500418AS_Z2AENPNG-part2 /srv -t ext4 -o defaults,noatime>
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/srv.mount

Jun 06 08:03:27 XXX systemd[1]: Mounting /srv...
Jun 06 08:03:27 XXX systemd[1]: Mounted /srv.

● home.mount - /home
   Loaded: loaded (/etc/fstab; generated; vendor preset: disabled)
   Active: active (mounted) since Thu 2019-06-06 08:03:27 CEST; 1h 50min ago
    Where: /home
     What: /dev/sdc3
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)
  Process: 690 ExecMount=/usr/bin/mount /dev/disk/by-id/ata-ST3500418AS_Z2AENPNG-part3 /home -t xfs -o defaults,noquota>
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/home.mount

Jun 06 08:03:27 XXX systemd[1]: Mounting /home...
Jun 06 08:03:27 XXX systemd[1]: Mounted /home.

● home01.mount - /home01
   Loaded: loaded (/etc/fstab; generated; vendor preset: disabled)
   Active: active (mounted) since Thu 2019-06-06 08:03:28 CEST; 1h 50min ago
    Where: /home01
     What: /dev/sdb2
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)
  Process: 692 ExecMount=/usr/bin/mount /dev/disk/by-id/ata-WDC_WD10EZEX-60M2NA0_WD-WCC3F5AYCJL7-part2 /home01 -t xfs ->
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/home01.mount

Jun 06 08:03:27 XXX systemd[1]: Mounting /home01...
Jun 06 08:03:28 XXX systemd[1]: Mounted /home01.
 # 

Meaning that, if you move away from the default Btrfs system partition, you’ll have to remember to unmask the “*.mount” systemd services to enable the systemd mounts generated from “/etc/fstab” …

  • Or, install without setting up with a Btrfs system partition …