View IT Assist in a larger map 

Easy ways to get the answers you need. Chat now or call/sms us at +678 7799677 or +6787799618.

We also provide remote support via Team Viewer.

How to Create a separate home partition in Ubuntu running in VirtualBox

Here's a working solution we used, to create a separate partition in Ubuntu running in VirtualBox and mount our /home which was running out of free space.  

We exclude the VirtualBox and Partitioning part which is obviously straight forward step and easy to figure out. But here's a brief anway.

1. In Virtual Media Manager, create a new storage type (.vdi)
2. Use a GPart bootable CD (independent environment partitioner) or login and use GPart in existing guest OS and partition the new storage. e.g. Ext3 FS
3. Complete the partitioning process and proceed to terminal
 

Go to Applications > Accessories > Terminal to launch the terminal.

Mount /dev/hda1 and /dev/hdb1 (change the partition device names to the ones appropriate for your setup):


sudo mkdir /old
sudo mount -t ext3 /dev/hda1 /old
sudo mkdir /new
sudo mount -t ext3 /dev/hdb1 /new
 
Back up the /home directory on the old partition and move it to the new partition:


cd /old/home
find . -depth -print0 | cpio --null --sparse -pvd /new/
sudo mv /old/home /old/home_backup
sudo mkdir /old/home
 

The 2nd command works for me, if it doesn't for you, you might need to preface the commands with sudo in case one of the other users has subdirectories manually marked as unreadable to the user making the move.

  
sudo find . -depth -print0 | sudo cpio --null --sparse -pvd /new/

Use the new home partition as /home:


 
sudo cp /old/etc/fstab /old/etc/fstab_backup
gksudo gedit /old/etc/fstab
 
 
Go to /etc/fstab and add in the below line at the end of the file:


 
/dev/hdb1 /home ext3 nodev,nosuid 0 2
 
 
Save the file and exit.

For editing, i use vim, there's other choices like gedit etc...

After you reboot, you should be now using your new /home partition.

If you are confident everything is working as it should be, then go ahead and delete the backup of home:


 
sudo rm -rf /home_backup


 The below issue never happened for me, but do take note of it. 

(extracted from http://psychocats.net/ubuntu/separatehome)

What if it doesn't work?

If you reboot and are unable to log in because of some errors having to do with the $HOME/.dmrc file and/or .ICEauthority file, this may help.
Boot into recovery mode (if you don't know how to do this, go to this section of another tutorial).

Once in recovery mode, type

chown -R username:username /home/username
chmod 644 /home/username/.dmrc
chmod 644 /home/username/.ICEauthority
exit
 
where username is your actual username. Obviously, you'd repeat the first three commands for all users experiencing the problem before you typed exit.

Once you've exited recovery mode, resume the normal boot and log in.
If, for some reason, no matter what you try, the separate /home doesn't work, that's why we have a live CD, so we can fix things.
Boot up the live CD, go to a terminal


sudo mkdir /recovery
sudo mount -t ext3 /dev/sda1 /recovery
sudo cp -R /recovery/home_backup /recovery/home
sudo cp /recovery/etc/fstab_backup /recovery/etc/fstab
 
Then, reboot.

Most of the text were adapted and snapshots taken from http://psychocats.net/ubuntu/separatehome.

No comments: