Some simple steps can help protect data and the integrity of the installed Oracle Linux Operating System. First, use separate disk partitions for operating system and user data (that is, separate partitions for /home, /tmp, /var/tmp, /oracle, and so on).
This strategy can prevent a “file system full” issue from impacting operations. Establishing disk quotas can also prevent a user from accidentally or intentionally filling up a file system.”
Moving /usr and /var to amother partition
1. Create two new directory:
# mkdir /var1 # mkdir /usr1
2. Plan to relocate the folders to new partitions. In this example new partitions are hda3 and hda4. First, label and then mount them on these folders.
# e2label /dev/hda3 /var1 # e2label /dev/hda4 /usr1
# mount /dev/hda3 /var1 # mount /dev/hda4 /usr1
3. Copy the content of both folders to their respective backup target folders, below is the example how to do:
# cd /var # find . -depth -print0 | sudo cpio --null --sparse -pvd /var1 # cd /usr # find . -depth -print0 | sudo cpio --null --sparse -pvd /usr1
4. Take the backup of fstab file:
# cp /etc/fstab /etc/fstab.bk
5. Edit /etc/fstab so that /usr and /var partition are not mounted on the next reboot.
# vi /etc/fstab
Comment any line that refers to /var and /usr. This is how my fstab files looks like:
/dev/mapper/vg_sys_amomv0030-lv_root / ext3 defaults,noatime,nodirat ime 1 1 LABEL=BKUP /bkup ext3 defaults,noatime,nodiratime,noauto 1 2 UUID=23591806-4117-4033-8556-4b220e072559 /boot ext3 defaults,noatime ,nodiratime 1 2 /dev/mapper/vg_sys_amomv0030-lv_home /export/home ext3 defaults,noatime ,nodiratime 1 2 /dev/mapper/vg_sys_amomv0030-lv_oem /oem ext3 defaults,noatime,nodirat ime 1 2 /dev/mapper/vg_sys_amomv0030-lv_tmp /tmp ext3 defaults,noatime,nodirat ime 1 2 #/dev/mapper/vg_sys_amomv0030-lv_var /var ext3 defaults,noatime,nodirat ime 1 2 UUID=4307676b-1ab5-4714-adf1-497469705052 swap swap defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 #/dev/mapper/vg_sys_amomv0030-lv_usr /usr/ ext3 defaults,noatime,nodirat ,hard,timeo=600,wsize=32768,rsize=32768 0 0
6. Reboot your system using rescue mode (You can use ISO/DVD). Your installation will be mounted on /mnt/sysimage.
7. Get inside the installation by issuing:
# cd /mnt/sysimage
8. make sure that /mnt/sysimage/usr and /mnt/sysimage/var are empty:
# rm /mnt/sysimage/var # rm /mnt/sysimage/usr # mv /mnt/sysimage/var1 /mnt/sysimage/var # mv /mnt/sysimage/usr1 /mnt/sysimage/usr
9. Open fstab, point /var and /usr to their new partition:
# vi /mnt/sysimage/etc/fstab /dev/mapper/vg_sys_amomv0030-lv_root / ext3 defaults,noatime,nodirat ime 1 1 LABEL=BKUP /bkup ext3 defaults,noatime,nodiratime,noauto 1 2 UUID=23591806-4117-4033-8556-4b220e072559 /boot ext3 defaults,noatime ,nodiratime 1 2 /dev/mapper/vg_sys_amomv0030-lv_home /export/home ext3 defaults,noatime ,nodiratime 1 2 /dev/mapper/vg_sys_amomv0030-lv_oem /oem ext3 defaults,noatime,nodirat ime 1 2 /dev/mapper/vg_sys_amomv0030-lv_tmp /tmp ext3 defaults,noatime,nodirat ime 1 2 #/dev/mapper/vg_sys_amomv0030-lv_var /var ext3 defaults,noatime,nodirat /dev/hda3 /var ext3 defaults,noatime,nodirat ime 1 2 UUID=4307676b-1ab5-4714-adf1-497469705052 swap swap defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 /dev/hda4 /usr/ ext3 defaults,noatime,nodirat
10. After saving the file you can reboot the server.
11. If rollback is needed in case of any failure, simply reboot the system into rescue mode again.
Modify fstab:
# cd /mnt/sysimage/etc # cp fstab fstab.bk2 # mv fstab.bk fstab
And reboot the system. /usr and /var should be mounted on the old partitions.