One of my application creates un-necessary logs or dumps that fills my filesystem .
Say example I have only root partition "/" and other filesystems(/var/, /usr etc..) are in "/" .
Sometime one of my application creates lots of files and unwaned logs at path /var/log/mycore and that fills my root partition and my oher application stops working .
I want to give a permanent solution, but I have some limitations as below
- I don't have extra free disk block to create new partition
- I can't add any any new disk/LUN etc .
- I can't stop that application logging etc...
Here's solution that have applied on one of my server and it's working as am expected .
## Example
## I have 12 GB free space now check size of dir: /var/log/mycore
## Okay now we have 2 way
1> Define quota .. but not preferred .
2> Create a filesystem with allocated space
## Am preferring to go with way-2 as below
As have 12G free space on "/", so I will allocate 3GB to /var/log/mycore as below
## Testing
## Step-6: Don't forget to start your application and check logs and all to verify all are okay ...
Say example I have only root partition "/" and other filesystems(/var/, /usr etc..) are in "/" .
Sometime one of my application creates lots of files and unwaned logs at path /var/log/mycore and that fills my root partition and my oher application stops working .
I want to give a permanent solution, but I have some limitations as below
- I don't have extra free disk block to create new partition
- I can't add any any new disk/LUN etc .
- I can't stop that application logging etc...
Here's solution that have applied on one of my server and it's working as am expected .
## Example
# df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 72G 57G 12G 79% /
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 72G 57G 12G 79% /
## I have 12 GB free space now check size of dir: /var/log/mycore
# du -sch /var/log/mycore
2G /var/log/mycore
2G total
2G /var/log/mycore
2G total
## Okay now we have 2 way
1> Define quota .. but not preferred .
2> Create a filesystem with allocated space
## Am preferring to go with way-2 as below
As have 12G free space on "/", so I will allocate 3GB to /var/log/mycore as below
Step-1: Create a file usign dd with size 3GB
# dd if=/dev/zero of=/var/log/FS_mycore bs=1024M count=3
Step-2: Create file system as per your requirement here am going with ext4
# mkfs.ext4 /var/log/FS_mycore
Step-3: Stop your application
Step-4: Move /var/log/mycore and create a new directory (Note: Reserve the permissions as original dir has)
# mv /var/log/mycore /var/log/mycore_old
# mkdir /var/log/mycore
Step-5: Mount and copy back all files and delete /var/log/mycore_old
# mount -o loop /var/log/FS_mycore /var/log/mycore
# mount -l
# df -h /var/log/mycore/
Filesystem Size Used Avail Use% Mounted on
/var/log/FS_mycore 3.0G 68M 2.8G 2% /var/log/mycore/
# cp -rp /var/log/mycore_old/* /var/log/mycore/
# cd /var/log/mycore/ ; ls -lrth
# rm -fr /var/log/mycore_old/
## Make entry in fstab
/var/log/mycore_old /var/log/mycore ext4 defaults,loop 0 0
# dd if=/dev/zero of=/var/log/FS_mycore bs=1024M count=3
Step-2: Create file system as per your requirement here am going with ext4
# mkfs.ext4 /var/log/FS_mycore
Step-3: Stop your application
Step-4: Move /var/log/mycore and create a new directory (Note: Reserve the permissions as original dir has)
# mv /var/log/mycore /var/log/mycore_old
# mkdir /var/log/mycore
Step-5: Mount and copy back all files and delete /var/log/mycore_old
# mount -o loop /var/log/FS_mycore /var/log/mycore
# mount -l
# df -h /var/log/mycore/
Filesystem Size Used Avail Use% Mounted on
/var/log/FS_mycore 3.0G 68M 2.8G 2% /var/log/mycore/
# cp -rp /var/log/mycore_old/* /var/log/mycore/
# cd /var/log/mycore/ ; ls -lrth
# rm -fr /var/log/mycore_old/
## Make entry in fstab
/var/log/mycore_old /var/log/mycore ext4 defaults,loop 0 0
## Testing
# umount /var/log/FS_mycore # mount -a
# mount -l
# mount -l
## Step-6: Don't forget to start your application and check logs and all to verify all are okay ...