TMP tricks

From Cheatsheet
Revision as of 12:57, 25 December 2010 by Admin (talk | contribs)
Jump to navigation Jump to search
(07:43:29 AM) Dan Wells: I have a fun one for you
(07:43:42 AM) Dan Wells: how to resize /tmp on a server that is using /securetmp
(07:44:01 AM) Mike: like your gonna show me how?
(07:44:08 AM) Mike: or you have one right now?
(07:44:18 AM) Dan Wells: on some servers you will see them remount /tmp on something like /usr/tmpDSK
(07:44:25 AM) Dan Wells: this is common on our storm servers
(07:44:29 AM) Mike: ok
(07:44:40 AM) Mike: explain in great detail please
(07:45:04 AM) Dan Wells: because of the way it only sets up a '/' partition, it mounts /tmp on a file-based loop filesystem
(07:45:08 AM) Dan Wells: got a storm server handy?
(07:45:18 AM) Mike: hrmmmmmm.....
(07:45:20 AM) Mike: one sec
(07:45:57 AM) Dan Wells: anyways I had a customer who needed more space for /tmp
(07:46:10 AM) Dan Wells: normally its not possible to resize it because its actually a disk partition
(07:46:21 AM) Dan Wells: but when they are mounting a file like that, you can
(07:46:47 AM) Mike: https://billing.int.liquidweb.com/mysql/content/admin/account/?accnt=185323
(07:47:03 AM) Mike: he said i can check on these when ever
(07:47:06 AM) Mike: i needed to 
(07:47:14 AM) Mike: or i can make one whenever
(07:47:38 AM) Dan Wells: ok, se ehow its remounting /tmp as a flat file?
(07:47:52 AM) Dan Wells: tmpDSK ? 
(07:48:21 AM) Mike: [root@cpanelclone.ngamber.ca] ~ >> df -l
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/xvda3           152783008   8357432 136664576   6% /
/dev/xvda1              101086     26298     69569  28% /boot
tmpfs                   879040         0    879040   0% /dev/shm
/usr/tmpDSK             495844     10639    459605   3% /tmp

(07:48:25 AM) Mike: yeah
(07:48:28 AM) Mike: i see it there
(07:48:29 AM) Dan Wells: make the new file:
dd if=/dev/zero of=/usr/tmpDSK2 bs=4096 count=(new size in number of 4k blocks)
format it:
mkfs.ext3 /usr/tmpDSK2
(07:48:57 AM) Dan Wells: mkdir  /tmp2 
rsync -av /tmp /tmp2 

(07:49:03 AM) Dan Wells: er wait
(07:49:05 AM) Dan Wells: skipped a step
(07:49:24 AM) Dan Wells: mkdir  /tmp2 
mount -o loop  /usr/tmpDSK2 /tmp2
rsync -av /tmp /tmp2 
(07:49:56 AM) Dan Wells: then umount /tmp2 , shut down services until it well let you umount /tmp 
move tmpDSK to tmpDSK.old and and tmpDSK2 to tmpDSK and reboot
(07:51:10 AM) Mike: ok do you know what service those would be mainly?
(07:51:19 AM) Dan Wells: pretty much everything
(07:51:20 AM) Mike: i assume httpd, mysql
(07:51:27 AM) Dan Wells: mysql, apache, courier, 
(07:51:29 AM) Dan Wells: lsof | grep /tmp 
(07:51:31 AM) Mike: cpanel
(07:51:34 AM) Dan Wells: that too
(07:51:47 AM) Dan Wells: it may be simpler to just update /etc/fstab and reboot 
(07:51:57 AM) Mike: basicaly tell the cutomer that we have to reboot it?
(07:52:13 AM) Mike: alot simpler
(07:52:19 AM) Mike: ok one more question
(07:52:27 AM) Mike: dd if=/dev/zero of=/usr/tmpDSK2 bs=4096 count=(new size in number of 4k blocks)
(07:52:34 AM) Mike: i dont understand that to well
(07:52:44 AM) Mike: dd if=/dev/zero of=/usr/tmpDSK2 bs=4096 count=20
(07:53:07 AM) Mike: that would make 20*4096b  right?
(07:53:37 AM) Dan Wells: yes
(07:53:41 AM) Dan Wells: thats only 80k though
(07:53:49 AM) Mike: so it would make a file that is 4kb * 20?
(07:53:54 AM) Mike: lol
(07:54:10 AM) Dan Wells: its in bytes, yes
(07:54:23 AM) Mike: so i will have to use math to figure this all out then lol
(07:54:28 AM) Dan Wells: thats also how you can make a file of arbitrary length too
(07:54:44 AM) Dan Wells: technically theres no reason you can set bs=1 and do it in one byes multiples
(07:55:06 AM) Dan Wells: but that will cause a lot of disk load while it runs and more likely to create it non-sequential
(07:55:08 AM) Mike: would use alot more inodes that way wouldnt it
(07:55:08 AM) Mike: ?
(07:55:14 AM) Dan Wells: 4096 is usual actual disk-block size
(07:55:27 AM) Dan Wells: so asking for a disk block of that size will write it to disk and fill a block
(07:56:20 AM) Mike: ok i am gonna paste this into a wiki so i can edit it later lol