Change home directory?

arvygasp

New Member
Joined
Feb 27, 2021
Messages
4
Reaction score
0
Credits
68
Good day!

I have faced a certain issue with my Ubuntu system, so I decided to reinstall. The idea was to also keep the home directory as it is.

I might have done something wrong during the installation, my /home folder has changed.

When I open /home now, I can see all the regular folders (Documents, Downloads, Pictures, etc) BUT THEY ARE EMPTY. I can also seee hidden files (.bashrc, .profile) ....

I thought alright.. my previous home directory is gone. I somehow formatted it during the fresh install.

I tried to reinstall Ubuntu again, and then I saw that my sdb drive (1TB drive that was mounted with /home before) has 200gb of its space used. Thought aha! My files are not deleted, I just can not see them.



I installed Ubuntu once more, trying to assign /home to that 1TB drive, hoping it would link to the original home directory.

But by doing that I simply just created a new "user?" or a new "home directory?".

Because when I "cd /home" now, I see:

dir1 - my current directory
dir2 - the one all my files are in
dir3 - new dir created after second install
dir4 - new dir created after third install

What I would like to do is to REMOVE dir1, dir3, dir4, because they are empty and unnecessary
and MAKE my CURRENT directory with the contents of the "dir2".

Thank you

Arvydas
 


A fresh installation wouldn't provide you with everything that you had in your /home directory.
If you made a separate partition for /home than you would need to mount it to access it:-
-:::-That's provided that you didn't delete that partition during the fresh installation.-:::-

In order to keep everything in your home directory you would have to do 1 of 2 things.
Either back up your system onto an external device <or> use Timeshift to make and save a snapshot of your entire system.

Do you just want to take all that was in your home directory and place all of those items in your fresh installation?

Please provide a screenshot of all of your partitions in gparted.
 
I didn't solve the problem for now, simply reinstalled ubuntu and that's it. Didn't have the time and patience to try to recover the things from home directory. This thread can be closed, since I do not know how..
 
Don't give up so easy arvygasp and try to learn from your mistakes.

Always, always, always back up your files and everything in your home directory before performing a fresh installation.

If you could open gparted and post a picture of your partitions I can help you.
IF you didn't delete that /home partition it's probably still there.:)
 
Myself and others are working on a Terminal command to move the /home from your sdb drive back to your sda drive

The gparted info asked for by @Alexzee will be of Great value.....in fact it is crucial.

As a matter of interest, how did you initially move the /home from sda1 to sdb. ......?
 
as @Alexzee says, dont give up and analyze the lessons learned. One way to master linux is to dig into he problems, you will screw things up from time to time but thats one of the better ways to learn, the only key is to understand the mistakes.

Here some tips from the future:

When installing:
- Create the /home partition in a different disk
- Make /home as LVM volume, this will let you increase the space as needed (when more disks/partitions are available ).
- As general rule, I always use /dev/sda for OS and /dev/sdb for personal data.

Cheers,
 
An interesting and relatively unknown tidbit is that some distros will let you do a reinstall and let you keep not only your files and (some) settings, but will also let you keep your installed applications. You can do this without even having a dedicated /home partition. During the installation, select 'something else', set the right flags, and make sure to set it to NOT format the partitions during the installation - you also need to use the same username.
 
An interesting and relatively unknown tidbit is that some distros will let you do a reinstall and let you keep not only your files and (some) settings, but will also let you keep your installed applications. You can do this without even having a dedicated /home partition. During the installation, select 'something else', set the right flags, and make sure to set it to NOT format the partitions during the installation - you also need to use the same username.

interesting.. I've never noticed that option. Definitively will pay more attention and give it a try
 
Give it a shot with Ubuntu or an Ubuntu derivative. I'm not sure what others will let you do it that way.

I last used it about a week ago when I hosed my testing Ubuntu VM and needed to reset it without a snapshot.
 
@KGIII ....why didn't you tell me that a week or so ago ??!!

(Oh.....that's right....I didn't ask !)
 
An interesting and relatively unknown tidbit is that some distros will let you do a reinstall and let you keep not only your files and (some) settings, but will also let you keep your installed applications. You can do this without even having a dedicated /home partition. During the installation, select 'something else', set the right flags, and make sure to set it to NOT format the partitions during the installation - you also need to use the same username.

I hope you are reading this @arvygasp
 
I could probably make it into an article. Though it'd mostly just be screenshots.

That would be a more than useful idea ! :cool:

Screenshots are all people need to follow
 
If the OP is interested, we can likely achieve the desired outcome with as little as 15 to 20 lines at Terminal, but we would need to know his partition layout first, eg GParted shots.

I've just done it on my Ubuntu GNOME (desktop) 20.04.

sudo mount /dev/sda38 /mnt
sudo cp -rp /home/* /mnt
cd /mnt
ls
sudo rm -rf lost+found
ls
cd chris
ls
ls -a
cd ~
pwd
sudo umount /mnt
sudo mount /dev/sda38 /home/
df /dev/sda38
sudo cp /etc/fstab /etc/fstab.orig
sudo nano -m /etc/fstab

In my case, my Ubuntu is on /dev/sdb1, where it had a Home folder.

On my other drive, I have created /dev/sda38 formatted to EXT4, size 60 GB.

Works fine.

I can outline further if the OP comes back, or if others are interested.

BTW I just used a customised abbreviation of Dave McKay's HTG article here

https://www.howtogeek.com/442101/how-to-move-your-linux-home-directory-to-another-hard-drive/

... which is current as of 24th February, following my pointing out to him a small error which he has addressed.

Cheers

Wiz

BTW2 I like that tip from David @KGIII , :) though I have no particular need of it as I can just do a Timeshift Restore for any of my needs.
 
sudo nano -m /etc/fstab

I should have said that the line I entered into fstab at the bottom reads

/dev/sda38 /home ext4 defaults 0 0

You could just as easily replace /dev/sda38 with the UUID of that partition (which I prefer, as they do not change as frequently)

Save your fstab, reboot and Bob's Your Uncle.

Wiz
 
As long as he's not my Aunty.....
 

Members online

No members online now.

Latest posts

Top