Partition is adjusted when the system works:Mobile / Home
Tuesday, March 03, 2009 by rain
In this new skill concentration,Divisional position is changed on the system that if why moving,Daniel Robbins showed.At the same time he still introduced a few know-how,Make you can shrink machine down time thereby the shortest,Can avoid to make serious mistake.In this skill,He will explain how will / Home shift arrives on another partition.
/ Home partition is most one of partition that often move.Certain moment,/ the total space in Home gave out,And need increases drive of a hard disk.Another some of moment,/ the one part that Home is set to be a partition,To rise function or facilitating backup,The likelihood needs to reach its shift other place.I can explain how to move effectively in the light of every kinds of circumstance / Home.
Warning
How does the technical specification below move one or more partition.Although the design of this technology makes you can " cancel " unsuccessful partition is mobile,But the mistake that it does not avoid an user.Change character,The operation that should undertake the format turns partition or duplicate and many document only,The possibility that because input a mistake,exist and brings about mass data to be destroyed.Because of this,Intense proposal youProper measure is adopted to back up before the action all important files.
You already made good preparation now,We can begin shift / Home.The exact step that you should complete depends on / Home is to be stationed in currently stay on the partition with alone itself,Still be located in on root partition.When we complete the step below,Essential write down this (when necessary my general reminds you) .If you are in will / Home shift arrives on a new hard disk drive,Criterion this driver should install the system in you on physics now in.
1.If be necessary,Found a new partition
If you are in will / the partition that Home shift has to (it is necessary and certain to do not have it is system of Ext2 file,Want an end only advocate partition or patulous and divisional existence can) on,Criterion you can turn to measure directly 2.
If new partition is nonexistent still,Need to use Cfdisk (first selection) or Fdisk will found a new partition.If this partition is not on the first driver,Did not forget the name this equipment appoints the first parameter that is Cfdisk or Fdisk.Founding proper advocate after partition or patulous partition,So that be read correctly afresh,should start a system afresh take divisional list.This is to need exclusively to restart system when.
2.File system is established on new partition
File system should be established on new partition,The accurate equipment name that should know this new partition above all (for example,/ Dev/sda5) .If you cannot decide exact equipment name,Stop instantly please,Check carefully equipment name.Key in the following command with Root identity next:
# mkfs.ext2 /dev/--?
Above with sample of the following code in,Should replace with target partition name- - ? .After executing this order,The system of Ext2 file that target partition will include an air.
3.In / hang below Mnt hold system of this new document
Found the name is / the catalog of Mnt/newpart,Hang new partition next carry this catalog to go up:
# mount /dev/--? /mnt/newpart
4.Enter odd user mode
To make systematic usability achieves utmost,I delay this one step as far as possible,But we must enter odd user mode now,Next will / the file in Home duplicates / in Mnt/newpart.You should not let / any files in Home are in open position,And entered odd user mode to eliminate this kind of possibility:
# init 1
If appear,hint,Input Root countersign to carry out a system to maintain the job please.You should be now in Root Shell.
5.Will present list is changed for / Home,Duplicate next file
Key in the following command:
# cd /home
# cp -ax * /mnt/newpart
Ground of loop of command of Cp -ax will / the content in Home duplicates / in Mnt/newpart,Retain all file property,Also won't across any hanging hold a place.After this command is carried out,/ Mnt/newpart lieutenant general includes / the accurate carbon of all file that includes currently in Home and catalog.If original / Home is on the partition with alone itself (in / Etc/fstab is useful and alone group is listed) ,Turn to measure 6a please.Otherwise,Turn to measure 6b please.
6a.Use new partition (when original / Home is a partition when)
The specification below is applied to original / Home has been in the system on the special partition of itself.If not be this kind of circumstance,Consult please measure 6b.
Key in the following command to uninstall original partition:
# cd /
# umount /home
Next,Uninstall and hang newly again carry new partition:
# umount /mnt/newpart
# mount /dev/--? /home
Can pass now / Home visited new partition,Can throw instantly use.We are OK carry out below much user mode finally a few measure.Exit odd user mode by CTRL-D please,Such systems can be returned start moving condition.
Important step: After be being started normally in the system,Login with Root identity,Edit next / Etc/fstab,So that will / Dev/- - ? Hang automatically carry / on Home,is not to still be in this to hang carry a dot to hang carry original partition.For example,Will below this group:
/dev/hda3 /home ext2 defaults 1 2
Change for:
/dev/--? /home ext2 defaults 1 2
6b.Use new partition (when original / Home is not a partition when)
If / the partition with alone itself is absent to go up before Home (for example,If / Home is a catalog on root partition only) ,Operate by the specification below please.Execute the following order:
# cd /
# mv /home /home.old
# mkdir /home
# mount /dev/--? /home
Now,Leave odd user mode by CTRL-D please.Return when the system after starting moving condition,Editor / Etc/fstab file,Amid is added similar such group:
/dev/--? /home ext2 defaults 1 2
Such,When starting a system afresh next time,Your new partition will be hanged correctly to carry.
7.Round off works
We are designed will original / Home catalog / divisional reservation comes down,The problem appears when duplicate file in case.Be in after confirming systematic stability moves,You are OK will original / Home partition is used at other objective,Perhaps delete original / Home catalog.
Congratulation you,You had moved / Home!In a skill,We will deploy a system afresh,In order to make / Tmp and / of Var use themselves share partition.Issue a good-bye.
Textual link:Http://www-128.ibm.com/developerworks/cn/linux/l-tip-prompt/tip05/index.html