Announcement

Collapse
No announcement yet.

Help moving the home partition to another drive...

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help moving the home partition to another drive...

    Greetings, I ask for your help on the specific problem below,
    I'm using kubuntu 22.10...

    I successfully installed my home partition in a different disk than all other partitions,
    but the disk with home partition is just about to crash and i need to replace it.
    I need instructions (desktop or konsole) to create a home partition on the system disk (it has enough space) and move my current home partition there...

    Since home cannot be unmounted, I'd appreciate detailed instructions...

    Thank you very much in advance.

    #2
    Honestly, I don't know why you don't just duplicate your home on the the other drive, change the mount location in fstab, and log out and back in. I don't think there anything that is "locked" in your home that you wouldn't be able to just copy.

    There's a couple ways to do this, but IMO the easiest is to get a bootable USB stick, boot to it, mount the two file systems (partitions) on the different drives, then copy all the files from the old home to the new home. Once that's done, then you need to mount the root file system (the one you boot to normally). and edit etc/fstab to reflect the new location of home, and reboot.

    If you want to do it without a USB stick, then boot up but don't log in. Hit "ALT-F2" and log into to the terminal console. Then create a password for the root user and log out. Then log back in as root user. Then you can do the same as above - mount and move the files, edit fstab, etc. Once you've done that, log out of the root account and hit "ALT-F1" to return to the graphical console and log in. If all went well, you should log in normally. Once you've verified everything got moved, you can remove the root account password and the bad drive.

    If you provide actual details about your set up (drives, partitions, file system types, sizes, etc.) and how you think you'd like to do it, someone can help with an actual command list and instructions.

    Please Read Me

    Comment


      #3
      oshunluvr, thanks. The only reason is that I ignored that was possible...
      I will try your suggested method, but the part I am worried about is creating the new partition on the system disk, that kind of scares me, but I will try.

      Thank you.

      Comment


        #4
        Yeah, resizing a partition is always scary. On the bright side, YOUR data is on the other drive.

        What about just giving up a separate /home for now? No re-partitioning required. Just copy the files from your home into the /home folder on the boot disk, remove the /home mount from fstab, and reboot.

        This is actually the easiest and safest way to proceed. You would still have to log is as root because you would need to unmount /home and re-mount it somewhere to copy the files out of it.

        Then when you have a usable drive again for /home - move it back.

        Please Read Me

        Comment


          #5
          That sounds excelent. It sounds like the perfect temporal solution.
          Once the home is safely relocated and the defective disk replaced I can think of the next step.
          Could you pleas show me some examples of using fstab for chanching the home mount?

          Comment


            #6
            Ok, here's how I would do it:

            Boot up, but don't log in.
            Hit ALT-F2 to open terminal screen
            Log in to the terminal, then enter this command: sudo passwd root
            Give your root account a password - a simple one is fine because we'll be removing it at the end.
            Log out of your user account: exit
            and back in as root: root
            and enter the new password.

            Before continuing, it's a good idea to check drive space so you don't end up with a full root drive and leave yourself unbootable.

            Enter: df -h
            This will show drive space for each file system. Make sure / has more in "Avail" than /home has in "Used"

            For my example, I will use "/dev/sdb1" as the old home device and "starfleet" as your username.

            Enter this command to identify your home device: mount |grep home | awk '{print $1}'
            This will list the device name to use for the mount command below (instead of /dev/sdb1)

            Now unmount /home: umount /home
            Remount the old home at /mnt: mount /dev/sdb1 /mnt

            At this point, you have made no permanent changes except root having a password.

            You have remounted the home file system at /mnt and /home will be empty. To verify this, list the files at both locations:
            ls /home should result in nothing and
            ls /mnt should show your user folder(s).

            Next, copy the files into /home: sudo cp -ra /mnt/starfleet /home
            This may take a minute, The "-ra" option means to copy everything and retain file attributes.

            When it's done, run this to verify all is OK: diff -qr /mnt/starfleet /home/starfleet
            It should return nothing unless something is missing.

            Repeat these last two commands for other user folders if you have them.

            Now we edit fstab: nano /etc/fstab
            Look for the line that mounts /home - something like this:
            UUID=60834933-1e99-4d5c-922c-9abbc373e172 /home ext4 defaults 0 2
            ​You are going to simply add a "remark" character - a hash or pound sign - in front of this line so you can undo all this if something goes wrong. Like this:
            #UUID=60834933-1e99-4d5c-922c-9abbc373e172 /home ext4 defaults 0 2

            To save the file type: Ctrl-x, y, Enter

            "Ctrl-x" to exit the editor
            "y" to confirm to save it
            "Enter" to use the existing file name.

            Finally, unmount the old home: umount /mnt

            You should now be able to hit ALT-F1 to return to graphical mode and log in as your user. Test it now.

            If you can't seem to log in, return to ALT-F2 and check your edit of /etc/fstab. If you don't see a typo, re-edit it and remove the hash and reboot.

            Assuming all is well, the next step is to remove the root password. You can do it now or later or never if you wish.

            To again lock the root account so no one can log into it, retunr to ALT-F2 and log out as root: exit
            Then log back in as your user and lock the root account: sudo passwd -l root

            Since you're mucking about with your ability to log in, I recommend having a bootable live USB stick handy just in case.

            Please Read Me

            Comment

            Working...
            X