Note 1: The below will assume that you have a USB stick which you used to install Ubuntu, but the same goes for using a CD. So, wherever you see "USB", it's basically "the media at which you made bootable with Ubuntu".
Note 2: Wherever you see userName
in the commands, replace it with your actual username that you use in your Ubuntu.
Okay, what we'll be doing is booting into live Ubuntu using a LiveUSB. So, if you still have the USB you used with Ubuntu on it, then just boot from it, as if you were going to install Ubuntu from scratch, except, we'll choose to Try Ubuntu, not install Ubuntu. This will boot up Ubuntu from the USB, so this is not your actual installed Ubuntu. [Too many "Ubuntu's".]
All of the following will be typed in a terminal. You can open one by Ctrl+Alt+T.
Note: If, at any point, you get an error, stop, and let us know.
sudo mkdir /media/rt
- This will create a directory called
rt
under /media
. This will be the folder that will be housing your actual Ubuntu root partition.
sudo mount /dev/sda3 /media/rt
- As apparent from the command, this will mount (make accessible)
/dev/sda3
(your root partition) on the folder /media/rt
.
- Note: if the command gives you an error about the "file system type", do
sudo mount -t ext4 /dev/sda3 /media/rt
instead.
cd /media/rt
- This will change our working directory to that directory, which is now your Ubuntu's
/
partition.
sudo chroot --userspec=userName:userName .
Don't forget, replace userName
with your Ubuntu username.
- This...well...basically, the prompt that you see now would be the same prompt you would get if you opened a terminal in your actual Ubuntu installation. Your prompt should change to
userName@hostname:$
, something like that.
sudo cp /etc/fstab /etc/fstab.bak
Note: I'm not entirely sure if this command will ask you to enter a password. But if it does, enter your username's password. This goes for all the remaining commands.
- This is taking a backup of the file
fstab
that we're going to edit in the following couple of steps.
sudo gedit /etc/fstab
- This will open up that
fstab
file, of your Ubuntu installation, in a text editor. This file is responsible for mounting the /home
partition at startup when you boot up your Ubuntu. It's also responsible for mounting the /
partition, so be careful with editing this file.
Look for the following two lines:
# /home was on /dev/sda4 during installation
UUID=<random-numbers> /home ext4 defaults 0 2
They won't be exactly the same as this. You'll probably find exactly the first line, but the second line might be slightly different. It could start with /dev/sda4
instead of UUID=<random-numbers>
. But essentially, what we're looking for are the lines that have /home
in them.
Put a #
in front of the second line of the two. So, it should look like this:
# /home was on /dev/sda4 during installation
#UUID=<random-numbers> /home ext4 defaults 0 2
Putting that #
basically means that 'this line is a comment', so we're essentially deleting it, but we're not going to actually delete it.
- Save and close the editor. This will take you back to the terminal.
ls /home
. You should not see any output. If you don't see any output, continue on with the steps. If you see your username as the output (highly unlikely), go to step 13.
- This command is basically checking if you already have a home folder. You should not see any folders there because all of your
/home
directory was mounted on a separate partition anyways.
sudo mkdir /home/userName
. Don't forget, replace userName
with your Ubuntu username.
- This is creating a new home directory for your username. But it has incorrect ownership, so we'll fix it in a while.
sudo cp /etc/skel/{e*,.[a-z]*} /home/userName
- This will copy some essential files to your new home folder.
sudo chown -R userName:userName /home/userName
- This is changing the ownership of your new home folder to be you.
Note: There might be an easier, one command method to accomplish steps 11, 12 and 13, but meh, I don't know of it.
exit
exit
This should close the terminal.
At this point, we have removed auto-mounting your /home
partition, created a new home folder for your username, copied some essential files to it, and gave it the correct permissions.
Shutdown this live Ubuntu. Remove the USB stick. Boot into your Ubuntu as you normally would. Cross your fingers. You should boot normally, and find that you have a home folder with all the subdirectories (Documents, Pictures, etc.) just like you did, but now, all of this is under one partition, the root partition.
Let's do some checks.
cat /etc/fstab
. Look for the #
that we added to that line. It should be there.
ls -l /home
. You should see something like this:
drwxr-xr-x 43 userName userName 4096 Jun 30 20:49 userName
As long as those bold words are your username, everything is good.
ls -l /home/userName
. You should see all of those subdirectories created, and all of them should have your username in place of those bold words above as well.
- Open GParted. You should not see
/home
as the mount point for that partition (/dev/sda4
) like in your screenshot.
If all of this checks out, congratulations!
At this point, your other partition (the one that used to be /home
) is now free for you to do whatever you want with. Open GParted, and delete it, format it, burn it, throw it out the airlock, whatever.
Phew.
/home
partition that you need, correct? – Alaa Ali Jun 30 '13 at 6:09/home
partition that I need, but I was under the impression that Linux needs that directory. Also, Ubuntu has placed a directory there labelled with my user name, and it contains more directories called documents, pictures etc... – timelessbeing Jun 30 '13 at 7:22/home
" folder will be in the Ubuntu partition, but your/home/userName/Documents
and all those folders will be on another partition. This other partition can be set to FAT or NTFS, so that you can access those folders through Windows for example. However, all of the files under those folders will have a fixed set of permissions and ownership in Linux. These fixed permissions can be changed, but they change the whole partition, not single files. – Alaa Ali Jun 30 '13 at 7:26/home
to the Ubuntu partition? The first set of steps for both of these solutions is the same, but I'm asking just for the sake of what to type when answering your question. – Alaa Ali Jun 30 '13 at 7:27