Easiest way to get log files back onto disk

Questions about SolydX and SolydK installation.
User avatar
ilu
Posts: 1912
Joined: 09 Oct 2013 12:45

Easiest way to get log files back onto disk

Postby ilu » 08 Oct 2017 21:39

What would be the easiest way to get some or all log files back onto disk? Just removing the correspondent tmpfs lines in fstab doesn't work because the /var/log directory structure is still missing. I fiddled with this and finally got it working but it was not straightforward. No way I could explain to somebody what I did. And I'm not sure I got the permissions right.

Any ideas?

User avatar
grizzler
Posts: 1986
Joined: 04 Mar 2013 15:45
Location: The Hague, NL

Re: Easiest way to get log files back onto disk

Postby grizzler » 09 Oct 2017 17:54

Something with a bind mount as mentioned here would seem the most sensible way to go. Using sudo mount in the terminal, remounting the real /var/log/ items outside tmpfs worked like a charm. As a test I did (on a system with all of /var/log in tmpfs):

Code: Select all

sudo mkdir -p /mnt/var
sudo mount --bind /var /mnt/var
sudo mount --bind /mnt/var/log/apt /var/log/apt
and the original /var/log/apt was visible again.

However, 'porting' that to fstab mounting simply didn't work (the bind mount became a copy of the original in tmpfs - systemd issue? - wouldn't surprise me...).

Edit
If you just want to get everything back to disk and then switch all of /var/log out of tmpfs permanently, using the first part of the manual route should be enough: bind mount the real structure to /mnt/var and then simply copy everything from /var/log to /mnt/var/log (using sudo cp in the terminal, with the right options, or you'll miss ownership and permissions). Then remove the tmpfs lines from fstab and reboot.
Frank

SolydX EE 64 - tracking Debian Testing

User avatar
grizzler
Posts: 1986
Joined: 04 Mar 2013 15:45
Location: The Hague, NL

Re: Easiest way to get log files back onto disk

Postby grizzler » 10 Oct 2017 12:22

Putting the 'manual' commands in /etc/rc.local works (no sudo, of course...). Still a bit of a hack, but at least it allows you to selectively move bits of /var/log out of tmpfs.

It may not work for everything, though. Some services may need access to logs before rc.local is run. I haven't checked this.
Frank

SolydX EE 64 - tracking Debian Testing

User avatar
ilu
Posts: 1912
Joined: 09 Oct 2013 12:45

Re: Easiest way to get log files back onto disk

Postby ilu » 11 Oct 2017 00:00

To permanently move /var/log onto disk in the end I think I did something like:

Code: Select all

sudo cp -av /var/log/* /somedir/var/log
- boot into live ISO and mount root and the partition somedir is on -
sudo cp -av /media/.../somedir/var/log/* /media/root/var/log
I took several detours so I'm not sure but that should work, shouldn't it?

kurotsugi
Posts: 2040
Joined: 09 Jan 2014 00:17

Re: Easiest way to get log files back onto disk

Postby kurotsugi » 11 Oct 2017 06:57

I usually only create the folders under the directories with correct permission and owner. the caveat would be I lost the old logs but since we're dealing with tmpfs, it shouldn't matter much. grizzler actually already gives you the easiest and straight method to do that.

Code: Select all

# this part create the necessary mount point
sudo mkdir -p /mnt/var
#this part mount the actual /var into our mount point
sudo mount --bind /var /mnt/var
#this one should works too. 
sudo mount --bind /var/log /mnt/var
after that you could copy the content of /var/log into /mnt/var/log


Return to “Installation”

Who is online

Users browsing this forum: No registered users and 1 guest