Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

50%
+0 −0
Q&A Partially moving /home to a new partition, leaving some content behind

There are two key ideas here: Moving data between partitions entails copying it onto the new one and then deleting it from the original - just like copying between different physical drives. H...

posted 8d ago by Karl Knechtel‭

Answer
#1: Initial revision by user avatar Karl Knechtel‭ · 2024-11-26T15:59:18Z (8 days ago)
There are two key ideas here:

1. Moving data between partitions entails copying it onto the new one and then deleting it from the original - just like copying between different physical drives. However, of course, the deletion can be postponed arbitrarily; *not* deleting leaves a potentially useful backup.

1. The new partition needs to be the mount point for `/home`, while the original should also be auto-mounted somewhere in order to have access to the files.  
The natural choice is `/home/shared/large_folder`, since fundamentally the contents are still user data.

The following approach is adapted from what I actually did (some steps were needlessly clumsy, and the real situation was actually more complex than I described) and from general advice in [Ubuntu's guide](https://help.ubuntu.com/community/Partitioning/Home/Moving) to moving `/home` onto a new partition starting from the root partition.

* Log out all users, then log in as `user_1` (a sudoer) from a terminal (to avoid having any GUI processes running that might write to `user_1`'s config files during the copy)
* Copy user folders to the medium partition
    * Mount the empty `medium_partition` and create empty folders for the mount point:
        ```
        mkdir -p /media/user_1
        mount /dev/sdXN /media/user_1/medium_partition
        mkdir -p /media/user_1/medium_partition/shared/large_folder
        ```
        (where `sdXN` is the actual device name, which can be inferred from `lsblk` output)
        Use `chmod` and `chown` as necessary to make the created `shared` and `large_folder` folders match the existing ones on the large partition.
    * Copy the shared folder and user folders:
        ```
        sudo cp -a /home/user_n/ /media/user_1/medium_partition/
        sudo cp -a /home/shared/other_stuff /media/user_1/medium_partition/shared
        ```
    * Unmount the partition
* Reconfigure permanent mount points:
    * Locate and back up `/etc/fstab`, then edit (requires sudo):
        * On the line with `/home`, change that to `/home/shared/large_folder` (i.e., change the mount point for the `large_partition`)
        * Determine the UUID for the `medium_partition` (I looked it up in `gnome-disks`; it could also be done via `blkid /dev/sdXN`)
        * Above the old `/home` entry, add a new one:
            ```
            UUID=01234567-89ab-cdef-0123-456789abcdef /home           ext4    defaults        0       2
            ```
            (filling in the actual UUID. If you use a different filesystem than `ext4`, change that too)
* Reboot, or `sudo mount -a`, and verify that everything works.

The large_partition will now look like:
```
/home/shared/large_folder
    shared
        other_stuff
        large_folder
    user_1
        ...
    user_2
        ...
```
Therefore, we now want to move the contents of the `large_folder` up to the root of the partition (i.e. directly into `/home/shared`):
```
mv /home/shared/large_folder/shared/large_folder/* /home/shared/large_folder
```
(Of course, this can just as well be done with a GUI)

and then the rest of that partition contains backups which can be dealt with as one pleases (archiving somewhere else, renaming the folders to avoid confusion, or just deleting it eventually).