Wednesday, February 17, 2010

How To Move Linux Main Directory (such as the Var and TMP) To Another Partition Or Another Directory

This case started when I try to use APTonCD and the result is failed. APTonCD need tmp and other space where to store iso image is enough. My machine has only 450 MB on root directory that no main directory stored in the different partition except home directory.

My computer has download package and other update by synaptic package manager and apt-get more than 1 GB so I need tmp has more than 1 GB to use APTonCD.
The way is how to use another partition or directory that has enough free space to use as /tmp directory.
I try it step by step
1. Modifying the other partitions. At that time the computer has 3 operating systems on a single 40 GB hard drives, this drive divided by more than 10 partitions. My machine has 2 windows operating systems and 1 ubuntu linux. The last option is to remove the second window that use 3 GB space in NTFS. This partition than formated by GParted (gnome partition tool) become ext4 filesytem
2. Creating a new directory to mount the new partition This is optional only, eg create new directors 'relocated' in / media / so / media / Relocation
due to the root privelage it must use the sudo command: type in the terminal: cd / media mkdir Relocation Then Mount Partitisi sudo mount / dev /? / media / Relocation / dev /? is the partition that would be mounted eg / dev/sda6 (knows how to look at the following Gparted UUID in. There was her). 3. Sign in to Single User mode (init 1)
Generally in this mode, no program or service using the directory like / var / or / tmp how ?: sudo init 1
Enter to the directory / media / Relocation cd / media / Relocation create var and tmp directory mkdir var
mkdir tmp tmp folder permissions changed to readwrite chmod 1777 tmp now copy all directory in / var to / media / move / var and / tmp to / media / move / tmp how: move all the folders and files in the directory / var cd / var cp-ax * / medi / moving / var move all the folders and files in the directory / tmp cd / tmp cp-ax * / medi / relocated / tmp
4. Fstab modifications Go into normal mode let's easy, Open Gparted
Open the file / etc / fstab using the command in the terminal (must be in the root privelage) sudo / gedit / etc / fstab add a new line in fstab to mount this partition in the directory / media / Relocation example: UUID = c6c0efbd-9069-4720-897d-fdddfab9e7dd / media / Relocation ext4 defaults 0 2 to determine UUID look at Gparted partition UUID copylah it. Save and restarlah computer.
5. It's Time to Change System Directory Go into single user mode (init 1) delete tmp directory and then create a link (var symbolic link to / media / move / var and tmp to / media / Relocation / tmp) It's possible to do or not dependending these directory is locked or not.
Step by step : Removing tmp: cd / rm-r tmp (-r this is a recursive option) make a link named tmp ln-s / media / Relocation / tmp tmp The last step is how to delete / var and create a symbolic link to var / media / moving / var
Alternative 1: Deleting / var: cd / rm-r / var If successful than proceed to the final step ln-s / media / relocated / etc etc Perform alternative 2 when failing to delete / var: Boot the computer from a live CD linux, ubuntu one example, mandriva one or usblinux or other. Mount the drive containing linux installation, find the var folder and delete this folder. If possible make a link directly to the folder named var / media / moving / var or Reboot linux, enter to single user, make links by: cd / ln-s / media / Relocation / var var Restart the computer, it should be work well!

No comments:

Post a Comment