Announcement

Collapse
No announcement yet.

Shifting /Home to another partition

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [SOLVED] Shifting /Home to another partition

    I had to reinstall K22.04 yesterday. That’s fine, except I forgot one thing I should have remembered. In my initial setup (before the crash), I had set up /Home in a different partition from the OS. When I reinstalled, I allowed the installer to use all of the partition that the crashed version of the OS was in. What I failed to do was to designate the different partition /Home as the /Home partition (but without reformatting) for the new installation.

    As a result, my OS partition has a /Home directory on it, but it has no contents. My separate partition /Home remains intact, with all of my files in it. I can get to it through Dolphin, but it’s kludgy to have to do that every time.

    So my question: is there a step-by-step with which I can re-designate where the OS thinks /Home is to the separate partition’s /Home. Then I can delete the still empty OS-partition /Home.

    I have thought of one way that would work, and that is simply to reinstall the OS again, remembering this time how to set up the Home file on the separation. I will if I have to, but is there an easier way? (There well may not be.)

    Many thanks.

    #2
    You will need to open a konsole.

    So /etc/fstab is used by the OS to mount filesystems, partitions, etc. during boot.

    This is what my /etc/fstab file looks like, and I also have a separate partition for /home:
    # /etc/fstab: static file system information.
    #
    # Use 'blkid' to print the universally unique identifier for a
    # device; this may be used with UUID= as a more robust way to name devices
    # that works even if disks are added and removed. See fstab(5).
    #
    # <file system> <mount point> <type> <options> <dump> <pass>
    # / was on /dev/nvme0n1p2 during installation
    UUID=43f7aabd-aa47-4eef-b4f4-d49cbef8b875 / ext4 errors=remount-ro 0 1
    # /boot/efi was on /dev/nvme0n1p1 during installation
    UUID=C309-DC20 /boot/efi vfat umask=0077 0 1
    # /home was on /dev/nvme0n1p3 during installation
    UUID=870436af-1189-421f-8240-e35613dba718 /home ext4 defaults 0 2
    # swap was on /dev/nvme0n1p4 during installation
    UUID=4bfd3cbc-efd5-48cd-ba39-6c4186543565 none swap sw 0 0


    The line used to mount /home is right under the # /home ... comment line. Your /dev entry for your /home could be different. I use an nvme drive, and an SSD will be /dev/sda(and some number).

    To determine the UUID reference for the existing partition that has your /home data, enter:
    lsblk -T --output NAME,FSTYPE,FSVER,PARTUUID,LABEL,SIZE,FSAVAIL,MOUN TPOINTS
    Which will list all the information for your exiting partitions.

    In the konsole, open /etc/fstab using sudo with a text editor such as nano with this entry:
    sudo nano /etc/fstab
    Because you are using sudo, it will prompt you for your password.

    Use your cursor to move down in the fstab file to a place in the file that looks something like where it is in my example. If you do not have a swap partition, then just use the last line. You can type in the info or you can just type UUID= and paste the UUID number after that. Do not leave a space between the = sign and your UUID number. After the UUID number enter a space followed by /home followed by a space followed by ext4 (or whatever you actual filesystem is in the lsblk listing) followed by defaults followed by a space followed by 0 followed by a space followed by 2. Or you can just copy my example from /home to the end of the line and paste it into your file. Check you typing at least once. When you are satisfied that it's in there correctly, press CTRL and the letter o. That should write the entry into your fstab file. If there are errors, and you can't figure out how to fix it, just press CTRL and the letter x to exit out of the file. You can always come back here to get more info.

    If your /etc/fstab file updates correctly, you can reboot and see if your "real" /home re-appears. Again, you can always come back here to get more info.
    Last edited by jglen490; Jul 28, 2023, 08:08 PM.
    The next brick house on the left
    Intel i7 11th Gen | 16GB | 1TB | KDE Plasma 5.24.7 | Kubuntu 22.04.4 | 6.5.0-28-generic


    Comment


      #3
      jglen,
      Thanks for responding so quickly. First difficulty: my fstab has a lot less in it than yours.

      # /etc/fstab: static file system information.
      #
      # Use 'blkid' to print the universally unique identifier for a
      # device; this may be used with UUID= as a more robust way to name devices
      # that works even if disks are added and removed. See fstab(5).
      #
      # <file system> <mount point> <type> <options> <dump> <pass>
      # / was on /dev/sda5 during installation
      UUID=8620f04e-1777-4715-80d1-0ec65b8f146c / ext4 errors=remount-ro 0
      1
      # /boot/efi was on /dev/nvme0n1p2 during installation
      UUID=38BA-F449 /boot/efi vfat umask=0077 0 1
      /swapfile none swap sw 0​

      So I have nothing corresponding to your # /home was on . . .

      What shall I try next? I don't want to cause you extra work; if it becomes simpler for me to reinstall along the lines that I suggested in my post, please tell me.

      Comment


        #4
        Originally posted by jglen490 View Post
        To determine the UUID reference for the existing partition that has your /home data, enter:
        Code:
        lsblk -T --output NAME,FSTYPE,FSVER,PARTUUID,LABEL,SIZE,FSAVAIL,MOUN TPOINTS


        That last should be MOUNTPOINTS

        Originally posted by Don View Post
        So I have nothing corresponding to your # /home was on . . .
        This is correct. You will need to add a similar line, based on the output of the (corrected) command jglen provided.
        Now, you can just use Kate or kwrite to edit the file - it will ask for your password when saving the file, so you don't need to worry about using nano if you don't feel comfortable with it.

        So, report what the output of the command shows, and tell us which line corresponds to your old /home.
        Once the mounting info is added to the fstab file, rename/move the existing /home directory, and you reboot, your old home will be restored.
        We can give you the exact steps you need to do, once we have the partition info.

        Originally posted by Don View Post
        f it becomes simpler for me to reinstall
        For this, it is much simpler to edit a file and reboot, than to reinstall.
        There are literally hundreds of how-tos on doing this exact thing, though they are geared towards creating a new home partition from scratch, and migrating files top the new location - you already have most of the steps done

        I have done this exact thing a few times over the years, but it has been a long while since I last time.

        Comment


          #5
          Here is the output from jglen's corrected command:

          NAME FSTYPE FSVER PARTUUID LABEL SIZE FSAVAIL MOUNTPOINTS
          loop0
          squash 4.0 245M 0 /snap/firefo
          x/2908
          loop1
          squash 4.0 63.4M 0 /snap/core20
          /1974
          loop2
          squash 4.0 349.7M 0 /snap/gnome-
          3-38-2004/143
          loop3
          squash 4.0 63.3M 0 /snap/core20
          /1822
          loop4
          squash 4.0 346.3M 0 /snap/gnome-
          3-38-2004/119
          loop5
          squash 4.0 4K 0 /snap/bare/5
          loop6
          squash 4.0 240.6M 0 /snap/firefo
          x/2356
          loop7
          squash 4.0 91.7M 0 /snap/gtk-co
          mmon-themes/1535
          loop8
          squash 4.0 49.8M 0 /snap/snapd/
          18357
          loop9
          squash 4.0 53.3M 0 /snap/snapd/
          19457
          sda 2.7T
          ├─sda1
          │ vfat FAT32 8a3dfe55-10b7-4914-ba5b-5e9f2b07fa57 94M
          ├─sda2
          │ ext4 1.0 b1cec86a-740c-4bfa-a238-085120297f65 27.9G
          ├─sda3
          │ swap 1 cb48203f-c218-4c2c-8917-44a590058836 74.5G
          ├─sda4
          ext4 1.0 faac8925-7d39-489a-99aa-ce3a9096e205 1.4T 1.1T /media/ddoer
          nberg/f9cc9e42-b1df-4619-8287-de078eb92257

          └─sda5
          ext4 1.0 75ecc6e3-8c1c-4206-b03a-b814f6cf6060 1.2T 1.1T /var/snap/fi
          refox/common/host-hunspell

          /
          sr0 1024M
          nvme0n1
          │ 1.8T
          ├─nvme0n1p1
          │ 6b42957e-2db8-44aa-b6d2-639d3a24b5ec 1M
          ├─nvme0n1p2
          │ vfat FAT32 012561a9-5bb9-48a7-99ab-a729a28d573c 513M 505.9M /boot/efi
          └─nvme0n1p3
          ext4 1.0 cc638d6e-79c9-457c-8413-fb7240b46e43 1.8T

          The red type is my old home drive, the one I want to keep. The green type is a backup partition that I made and will retain. So as I now understand it, I need to modify /etc/fstab to include "directions" to those two partitions. I can try to copy the syntax from jglen's post, but if someone has the time to reply with the exact code I should use, I will be eternally grateful. (Truth in advertising: I'm pretty old, so eternally may not lat as long as one might hope.)

          Am I correct in reading the output that I have no swap file on my current installation? As I read the last three lines of my original printout, that's what it seems to be telling me (which doubtless explains why the machine is running much more slowly than before the crash). Do I need to reestablish the swap file when I re-designate /Home? I suspect so, in which case I'll need to add the swap information under sda 2.7T of the new printout to fstab (I think).

          Am I making any sense, or is my little red choo-choo further around the bend that I realize?

          Thanks to all.​

          Comment


            #6
            Perfect!
            We take the UUID and use that for the creating the fstab entry.

            So:
            • Open /etc/fstab with kate/kwrite
            • At the bottom add the following:
            Code:
            # My home partition on /dev/sda4
            UUID=faac8925-7d39-489a-99aa-ce3a9096e205     /home    ext4       defaults    0 2​
            • Save the file - you will be prompted for your password
            • Log out - but don't reboot just yet.
            • At the login screen, hit ctrl-alt-f3
            • log in using your normal username/password
            • move your current /home directory and create a new empty one for your partition to get mounted to, like so:
            Code:
            sudo mv /home /home_old && sudo mkdir /home
            • either type systemctl reboot or hit ctrl-alt-f2 to get back to the SDDM screen, and reboot from there
            If you don't need files or anything from the the moved home dir and everything is working as you like, you can safely delete /home_old
            Last edited by claydoh; Jul 29, 2023, 01:27 PM.

            Comment


              #7
              Claydoh, this is great, but I have one question. Isn't my desired home partition sda4 from my printout rather than sda5? Unless I'm reading the printout wrong, the partition label (sda4) is on the line above the partition data, not the line below. Sorry to be dense, but as in carpentry, I'm a "measure twice, cut once" person. I understand the rest of what you've directed; it's just the single digit that I'm concerned about.

              Comment


                #8
                Originally posted by Don View Post
                . Isn't my desired home partition sda4 from my printout rather than sda5?
                Opps,. yeah you are 100% correct, but that first line is only a comment, not code (the "#" indicates this), it is only there for reference. The UUID is the important part. Sometimes the /dev/sdX can change, the UUID doesn't.

                You can even leave out the entire comment line, if you like.

                Comment

                Working...
                X