PartitioningHomeMoving documentation

Asked by wheelmaker

There are two parts of the documentation found at "https://help.ubuntu.com/community/Partitioning/Home/Moving" I do not understand:
1. when entering the terminal command "sudo mkdir /media/home" surely the terminal must first be changed to the newly created partition with the cd command else the new directory may be created in the wrong place?
2. having copied /home in the old partition to /media/home in the new partition and moved /home to /old_home (all understood), why then create a new /home on the new partition as this will surely be an empty folder as all of the data was copied to /media/home? It would seem logical to me to rename or move /media/home to /home i.e. "sudo mv /media/home /home" and then continue as per the documentation.
If there's something I'm not grasping please explain and put me straight as I would like to move my home to a new partition and this is what's holding me up.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Sam_
Solved:
Last query:
Last reply:
Revision history for this message
Vin Shankar (v-shankar) said :
#1

I hope the following answers help:
1) The leading "/" makes the path absolute - it's relative to the root of the file system tree, so it doesn't matter where you enter the command.
2) This is for two reasons:
   2a)mv-ing a folder with a filesystem mounted to it would likely only move the mountpoint if it allowed you to move it at all.
   2b)(related)the fstab entry which tells it where to mount the partition would still point to /media/home rather than /home, which would cause errors at boot-time and likely make the system unbootable except in recovery mode.

Revision history for this message
wheelmaker (webmaster-decorativewheels) said :
#2

I'm still not sure of this and hoping not be a pain would like additional clarification.
1. a) by entering the command "sudo mkdir /media/home" it would create the directory under root where there is already a folder named media, so how can this be located on the newly created partition?
1. b) the new partition is also not yet mounted in the documentation, so how would the system recognise the new partition?

I'm struggling to grasp how, having physically created a new unnamed and unmounted partition you actually create the name of the new partition on the new partition.

Revision history for this message
Best Sam_ (and-sam) said :
#3

/media/home is just a temporary mountpoint for the new partition in order to copy to it.
It could be also e.g.
/mnt/tmp
##this would create a folder tmp in an existing /mnt

Lets say
$fdisk -l
says the new partition is /dev/sda5
To create a temporary mountpoint and mount new partition could look like this e.g.:
$mkdir /mnt/tmp
$mount /dev/sda5 /mnt/tmp

##Only difference, the tutorial suggests to write into fstab

The final mountpoint in fstab is and has to be /home in order to boot correct and recognize /home.
Quote:
... the location should be a temporary one ...
Edit fstab so that your new home partition actually points to /home (ie. by changing /media/home to /home)
... and finally, remount the partition

##fstab final e.g.
# /dev/sda5
UUID=f72aac23-092f-4484-b35c-f222c106d716 /home ext3 defaults 0 2

##e.g.
Lets say the new partition /dev/sda5 has 8.5 GB
Test if the copy was successful e.g.:
$mount /dev/sda5 /home
$du -sh /home; mount|grep /home
##e.g. Output
8,5G /home
/dev/sda5 on /home type ext3 (rw)

Revision history for this message
wheelmaker (webmaster-decorativewheels) said :
#4

Many thanks for the support. Have only just got around to moving home successfully.
I needed a little additional information to understand this process, which turned out to be a thorough description of the "mount" command explaining that previous contents, owners and mode of $mkdir /mnt/tmp becomes invisible when the same directory name /mnt/temp is mounted on the /dev(ice).