Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
how do i change the location of /var/log? (solved)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
Oo.et.oO
Apprentice
Apprentice


Joined: 23 Apr 2002
Posts: 287
Location: burlington

PostPosted: Fri Mar 23, 2012 3:11 pm    Post subject: how do i change the location of /var/log? (solved) Reply with quote

i'm trying to move it to reduce writes to my sda SSD.

i have a raid array on this machine. i tried moving it there using a symbolic link.
upon reboot openRC says it can't recreate /var/log as the file already exists.

difficult to search on this. any ideas?


Last edited by Oo.et.oO on Fri Mar 23, 2012 9:36 pm; edited 1 time in total
Back to top
View user's profile Send private message
papahuhn
Guru
Guru


Joined: 06 Sep 2004
Posts: 538

PostPosted: Fri Mar 23, 2012 3:59 pm    Post subject: Reply with quote

"mount /path/to/RAID/folder --bind /var/log" or the corresponding fstab entry.
_________________
Death by snoo-snoo!
Back to top
View user's profile Send private message
Oo.et.oO
Apprentice
Apprentice


Joined: 23 Apr 2002
Posts: 287
Location: burlington

PostPosted: Fri Mar 23, 2012 4:23 pm    Post subject: Reply with quote

thanks for the reply papahuhn. let me be more detailed.

i want /var/log IN the raid array. it's 6TB. i don't need a 6TB /var/log :-)

prior, i tried just symlinking /var/log to /mnt/raid/var-log
(simplified, mine had an rsync in there to copy everything over):
Code:
cd /var && mv log log.old && ln -s /mnt/raid/var-log /var/log


good tip on --bind
Back to top
View user's profile Send private message
papahuhn
Guru
Guru


Joined: 06 Sep 2004
Posts: 538

PostPosted: Fri Mar 23, 2012 7:07 pm    Post subject: Reply with quote

Oo.et.oO wrote:
thanks for the reply papahuhn. let me be more detailed.

i want /var/log IN the raid array. it's 6TB. i don't need a 6TB /var/log :-)

prior, i tried just symlinking /var/log to /mnt/raid/var-log
(simplified, mine had an rsync in there to copy everything over):
Code:
cd /var && mv log log.old && ln -s /mnt/raid/var-log /var/log


good tip on --bind


Then bind to /mnt/raid/var-log.
_________________
Death by snoo-snoo!
Back to top
View user's profile Send private message
Oo.et.oO
Apprentice
Apprentice


Joined: 23 Apr 2002
Posts: 287
Location: burlington

PostPosted: Fri Mar 23, 2012 7:10 pm    Post subject: Reply with quote

papahuhn wrote:

Then bind to /mnt/raid/var-log.


doesn't this just make it so they are mounted in the same place? like a mirror? thus i'm writing to both drives now:

Code:
mount -o bind /var /mnt/tmp/other_var/
Back to top
View user's profile Send private message
papahuhn
Guru
Guru


Joined: 06 Sep 2004
Posts: 538

PostPosted: Fri Mar 23, 2012 7:26 pm    Post subject: Reply with quote

You can see it as some mirror if you like. Why don't you play with it a little? "mount /mnt/raid/var-log --bind /var/log" is pretty much what you want.
_________________
Death by snoo-snoo!
Back to top
View user's profile Send private message
Oo.et.oO
Apprentice
Apprentice


Joined: 23 Apr 2002
Posts: 287
Location: burlington

PostPosted: Fri Mar 23, 2012 7:40 pm    Post subject: Reply with quote

okay, so i was thinking about it backwards, but it still doesn't work. or at least it appears, not entirely

Code:
glazed var # rsync -a /var/ /mnt/tmp/other_var/ && mount /mnt/tmp/other_var/ --bind /var/

glazed var # lsof /dev/sda3 | awk '$4 ~ /(FD|[wWuU]$)/'
COMMAND     PID       USER   FD   TYPE DEVICE SIZE/OFF    NODE NAME
agnLogd    1931       root    0w   REG    8,3      681  157248 /var/log/agns/agnLog.txt
agnLogd    1931       root    1u  FIFO    8,3      0t0  157403 /var/agns/fifo/agnLogd
metalog    1968       root    8w   REG    8,3   367844  132630 /var/log/everything/current
...

glazed var # lsof /dev/sdb1 | awk '$4 ~ /(FD|[wWuU]$)/'
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF      NODE NAME
smbd    2179 root    2w   REG   8,17    20949 117310278 /var/log/samba/log.smbd
smbd    2179 root    8w   REG   8,17    20949 117310278 /var/log/samba/log.smbd
...

glazed / # mount
...
/mnt/tmp/other_var on /var type none (rw,bind)

glazed var # touch yourmom
glazed var # ls
agns/   db/     lib/   log/   run/    tmp/  yourmom
cache/  empty/  lock/  mail@  spool/  www/
glazed / # ls /mnt/tmp/other_var/
agns/  cache/  db/  empty/  lib/  lock/  log/  mail@  run/  spool/  tmp/  www/



sda3 is /
sdb1 is /mnt/tmp

not sure what's going on here exactly. but now since samba has taken to writing its logs there, i can't unmount it. and some files just don't get written to both places.


Last edited by Oo.et.oO on Fri Mar 23, 2012 8:03 pm; edited 1 time in total
Back to top
View user's profile Send private message
Etal
Veteran
Veteran


Joined: 15 Jul 2005
Posts: 1633

PostPosted: Fri Mar 23, 2012 7:47 pm    Post subject: Reply with quote

Some applications are probably still holding their open file handle to the old drive. Either restart those applications or reboot (of course you'd need to add the bind entry to fstab).
_________________
“And even in authoritarian countries, information networks are helping people discover new facts and making governments more accountable.”– Hillary Clinton, Jan. 21, 2010
Back to top
View user's profile Send private message
Oo.et.oO
Apprentice
Apprentice


Joined: 23 Apr 2002
Posts: 287
Location: burlington

PostPosted: Fri Mar 23, 2012 7:55 pm    Post subject: Reply with quote

Etal wrote:
Some applications are probably still holding their open file handle to the old drive. Either restart those applications or reboot (of course you'd need to add the bind entry to fstab).


that's what i'm thinking. so they can still access files i can't see from the shell because they have the inodes?
crazy compooters... :wink:
Back to top
View user's profile Send private message
papahuhn
Guru
Guru


Joined: 06 Sep 2004
Posts: 538

PostPosted: Fri Mar 23, 2012 8:00 pm    Post subject: Reply with quote

The files in the real /var folder are still there, the --bind is just mounted above of it. However I'm confused that you see yourmom in one folder and not the other. Is it "other_var" or "glazed_var"? I see both folder names.
_________________
Death by snoo-snoo!
Back to top
View user's profile Send private message
Oo.et.oO
Apprentice
Apprentice


Joined: 23 Apr 2002
Posts: 287
Location: burlington

PostPosted: Fri Mar 23, 2012 8:04 pm    Post subject: Reply with quote

papahuhn wrote:
The files in the real /var folder are still there, the --bind is just mounted above of it. However I'm confused that you see yourmom in one folder and not the other. Is it "other_var" or "glazed_var"? I see both folder names.


yeah, sorry. it was other_var and then i switched names during part of my session i didn't paste.

yeah, i buy the inodes being able to see under the mount point. but the yourmom thing puzzles me.

[edit]. OH. i did that all while the shell was sitting in /var (under the mount point)
so i mounted on top of where i was (cwd).
when i touched the file in /var i was actually in the original, not in the bound mount.

when i cd / then cd /var and touch a file, it shows up in both places.

i setup my fstab, so i'm about to reboot....

thanks all!
Back to top
View user's profile Send private message
Oo.et.oO
Apprentice
Apprentice


Joined: 23 Apr 2002
Posts: 287
Location: burlington

PostPosted: Fri Mar 23, 2012 9:35 pm    Post subject: Reply with quote

it works! in retrospect it all seems so obvious.
it took me weeks to figure out where all the writes to my main hard drive were coming from...

now it looks like most of the repeated writes are coming from beagle and on the user level from/into .mozilla and .pulse.

i'll add details on this to the SSD wiki page.

thanks again all!

for posterity here is my applicable portions of fstab:

Code:

# raid array
/dev/md127               /mnt/raid       ext4            noatime,user_xattr  0 2
# move var to magnetic disk...
/mnt/raid/glazed_var    /var            none            defaults,bind 0 0
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum