move my /home directory from it's own parition back to /root/home

This probably doesn’t get requested much but for now I need to move my home partition out of its own partition and into the /root directory. I need an extra primary partition on the drive to create an extended partition. Later I could move /home back to a new partition in the extended, but for now I need it in /root.

I could just delete the partition in gparted, but I am afraid that would mess up my installation since fstab will be looking to mount /home at boot time. At this point, I have everything in the /home directory backed up elsewhere, so there is no need to copy anything. The current /home can just go away if necessary.

Can I just remove the /home entry from fstab and manually mkdir a new home directory in /? If that would work, how do I tell opensuse where my new home directory is?

LMHmedchem

Here’s what I would do:

I would first logout as an ordinary user. I would then use CTRL-ALT-F1 to get a terminal session, and login there as root.

Now, as the root user at a terminal:e


# mount --bind / /mnt
# cd /mnt/home
# ls      #### a check to make sure that this is an empty directory.
######### now a tar pipe, to copy over "home":
# ( cd /home && tar cf - . ) | tar xpf -
#### a check -- you should still be at "/mnt/home" but now you should see all of the files.

Note: The above assumes that there is sufficent free space in the root directory to copy “/home” to there.


# cd /
# umount /mnt    #### undo that bind mount

Next, edit “/etc/fstab” (I would use “vi” but you might prefer a different editor). Find the line for “/home”, and comment it out (insert “#” at the beginning of the line).

Finally, reboot. If all goes well, the system should look almost as before, except that the partition for “/home” is not mounted and the files have all been copied to the root directory.

If that looks good, then you can safely delete the partition with whatever tool you find congenial.

I don’t see anywhere where /mnt/home gets created. There is currently no /home in /mnt. Is that something that gets created at boot time? There are several other directories in /mnt for my shared ntfs folder and such but no /home. It seems as if the cd command would fail unless /home is added during boot. So I need to manually create /home in /mnt with sudo mkdir?

LMHmedchem

I should have given more explanation.

The first command is a bind mount. It mounts the root file system at “/mnt”. Or, if you like, it logically binds “/” to “/mnt”. However, it does not carry with it other mounts. So what you should see at “/mnt” (after that bind mount), is really your root file system but without any other mounted file systems on top of it.

Your root file system already has a “/home”. That is being used for mounting your home partition. After the bind mount, you should see the “home” subdirectory of the root directory under “/mnt”. This is called “looking under the mounted file system”. It will be what “/home” looks like when the home partition is not mounted.

So the basic idea was to copy the mounted “/home” to under the mounted system.

I hope that makes it clearer.

This procedure worked well. Thanks for putting together a nicely coherent set of instructions.

I printed the instructions to have them when I did the implementation. The only fly in the ointment is that after I inserted the comment on the /home line in fstab, I couldn’t get out of vi. The esc key would not get my out of insert and zz didn’t do anything either. The screen was just locked up. I had to hard reboot and then boot into Ubuntu live to make the edit of fstab.

My home directory is now under /root and I have deleted the old partition.

If it is possible, I would now like to move the swap partition into an extended partition. I am not sure if this is possible.

First, can swap be a logical partition inside of an extended partition? If so, is there any reason to not do that?

It seems like the thing to do would be,

  • boot into opensuse and use yast partition manager to edit the swap partition to “do not mount” the swap
  • boot into gparted and delete the swap partition
  • create the extended partition
  • boot into opensuse and use yast partition manager create a new swap in as a logical in the extended partition
  • set the new partition to auto-mount

Assuming that swap can be in a logical in an extended, does this procedure seem reasonable?

LMHmedchem

Swap contains no usable data so just remove from fstab delete and recreate it where you want it and set it to mount at the new location. You can run without swap in most cases if you don’t overload the system

Yes, swap can be in a part of the extended partition.

Your procedure should be okay. It as actually similar to gogalthorp’s, except that you are using different tools. In any case, use the tools that you find most congenial.

And, by the way, “vi” is likely to be on that “gparted” disk if you happen to need it at that time.

Thanks for all the help so far. I have managed to do most of what I need in order to make an additional linux installation on my drive. I have gone from having 4 primary partitions to 2 primary partitions and an extended partition. I have my swap in the extended partition and can add /home partitions there as well. I have a block of free space for the partition for my new OS. Grub is working and hopefully I can add another OS without too many additional grub issues. My current plan is to not install grub with the new OS and then do update-grub from inside opensuse. We will see how that goes.

I am running a 64-bit OS with 16GB of RAM, so I have thought for a while that I really don’t need a swap file. I guess there are some things that swap could still get used for such as hibernation and I believe that sometimes system error log files get written there. I also have seem some older applications that seem to need to have the swap there. I guess there is no harm in having it, even if it never gets used.

At any rate, I have somehow broken the internet connection in opensuse, so I need to get that back. I posted that question in the internet section, so here’s hoping.

Thanks again, I will post about how the new install goes in the other thread.

LMHmedchem