LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   removed by mistake /home any possibility to get it back? (https://www.linuxquestions.org/questions/linux-newbie-8/removed-by-mistake-home-any-possibility-to-get-it-back-643275/)

borgibo 05-19-2008 11:41 AM

removed by mistake /home any possibility to get it back?
 
newbie mistake:o

using the following instructions, I tried to move /home to a separate partition in a) Jacklab 1.0 which is based on Suse 10.2 and b) in Centos5.

The instructions following a thread by Stewe W on 03-12-08, Member

Registered: Mar 2007
Distribution: Ubuntu 7.10, Knoppix 5.1.1
Posts: 53

are by Randux post #2 the following:

Sorry but as I cannot find the #2 answer to that which is by Randux any longer to copy and paste I will type it from my printed copy of May 11, 2008 . I copy hopefully without mistakes:

As root:

mkdir /mnt/hda8 (hda is only used as an example)
mount -w /dev/hda8 /mnt/hda8
rsync -axv /home/ /mnt/hda8/
umount /dev/hda8

Now update /etc/fstab to look something like:

/dev/hda8 /home ext3 defaults 1 2

then as root:
mount /dev/hda8 /home

make sure it worked:

mount

You should see something like this:

/dev/hda8 on /home type ext3 (rw)

Well this is the first part, the formation of new /home on /dev/hda8.

The second part is deleting the original /home from root:

umount /dev/hda8
rm -rf /home
mkdir /home
chmod 755 /home
mount /dev/hda8


I tried the above on system a) Jacklab i.0 but made some mistakes. The new /home on /dev/hda8 was formed with about 470MiB of files but due to my mistakes later both it and the original root /home dissapeared.So I cannot boot any longer.

I tried the same on system b) Centos5 and I was succesful. The new /home was formed, with about 177MiB of files and I am able to boot. I could not delete the old house though as I was told that it is busy. I logged in as root to do that. Not that bad.

Now checking the files in Jacklab 1.0 with Gparted livecd I noticed that they are almost the same size before and after the /home deletion.5.03GiB
before to 4.94GiB after. Considering that 470MiB is the transferred /home
I thought that they might be "hidden" somewhere and if there is a slight possibility of resurrecting them.

Hence my question.


Thank you,


borgibo

borgibo 05-19-2008 01:22 PM

Here I found it! and I coppy and paste the part that I copied only:03-12-08, 02:00 PM #2
Randux
Senior Member

Registered: Feb 2006
Location: Siberia
Distribution: Slackware. What else is there?
Posts: 1,326


Quote:
Originally Posted by Steve W View Post
I'm looking for the best way to set up my /home directory on a separate partition to my root directory. This setup is widely recommended for any Linux distro and I understand the reasons why. I've been researching how to do this, in Linux magazines and on the internet, but I'm getting more and more confused as to the way it should be done.

Part of the problem is that some methods go into detail about creating and formatting the partition itself, as well as copying the /home directory over. This does not apply in my case as I already have a spare 17Gb partition formatted as ext3. I just need to get my stuff over and tell the system this is where my new /home is located.

Could someone please go into detail as to the exact terminal commands I will need to do this? From the different methods outlined on the internet, it seems to be done using a variety of weird and wonderful commands such as rsync and other; some just use "mv".

There is also the question of whether I need to amend fstab to take account of the new location. One method detailed in a Linux magazine makes no mention of fstab at all; is it necessary to amend it or will Ubuntu just locate and pick up the /home directory automatically?

For instance, here is one method detailed in a magazine. It assumes all your stuff is currently on hda1, and you want your new home partition to be hda2:

mkdir -p /mnt/{root,home}
mount /dev/hda1 /mnt/root
mount /dev/hda2 /mnt/home
mv /mnt/root/home/* /mnt/home/
rm -fr /mnt/root/home/*

And that's it. No mention of fstab at all. Would this work in those five lines?

Obviously, I could just try it and see, but without knowing exactly what is going to happen, I don't want to risk messing up my system as it is now...

Could someone please advise whether I should go ahead using the above method, or do they have a better way?

Steve Wylie


Hi Steve,

If you want to use the whole 17G as your home you can do something like this. Supposing your new partition is /dev/hda8 for example:

Code:

As root:

mkdir /mnt/hda8 # make a temp mountpoint for new /home
mount -w /dev/hda8 /mnt/hda8 # mount the new /home r/w
rsync -axv /home/ /mnt/hda8/ # copy everything from /home
# note trailing '/' must be present!
umount /dev/hda8 # don't need new /home at the moment

Now update /etc/fstab to look something like:

Code:

/dev/hda8 /home ext3 defaults 1 2

then as root:

Code:

mount /dev/hda8 /home

make sure it worked:

Code:

mount

You should see something like this:

Code:

/dev/hda8 on /home type ext3 (rw)

Check your files under /home to make sure everything's ok. If not, stop, go back, and find your mistake (or mine).

If everything worked your new /home is operational and you can delete home from the / partition. As root:

Code:

umount /dev/hda8 # temp unmount real /home
rm -rf /home # delete old /home under /
mkdir /home # someone else can probably do this simpler
# maybe just cd /home and rm -rf * but I tremble whenever I do
# rm * so I would do it in the steps I outlined here
chmod 755 /home # make sure perms are correct
mount /dev/hda8 # real /home now activated

If not, DO NOT delete (rm) anything until you've figure what you've done wrong (or what mistake I made here!)
__________________
Shape up, man- you're a Slacker! Do you want to be a Slacker for the rest of your life? -- Principal Strickland, BACK TO THE FUTURE!
Last edited by Randux : 03-12-08 at 02:13 PM.
Randux is offline
Tag This Post No tags yet, please tag this post - what is this?
Your Tags:
Report this post


borgibo


All times are GMT -5. The time now is 10:03 PM.