The officially official Devuan Forum!

You are not logged in.

#1 2016-12-05 07:24:31

Registered: 2016-12-01
Posts: 16  

Moving /home to a separate partition after installation.

Please note that this procedure can easily result in permanent data loss. Be sure to have a backup before taking the plunge. Other than that, enjoy! smile

If you have installed Devuan to one partition and you are regretting that fact, be informed that you can easily assign a separate partition for /home, or any other directory you deem deserve to be transferred to a separate partition. This can be done without reinstalling because conventional GNU/Linux doesn't hide its operational 'secrets' from its users. smile

If not already present create a directory under /mnt, say my_home:

mkdir /mnt/my_home
cd /mnt/my_home

The first thing to do is obviously to find enough free space for the new partition. Then, use a tool (gparted) to format the new partition to some native Linux filesystem like ext3 or ext4. Other filesystems exist but you have to inform yourself about the pros and cons in using them instead of ext3 and ext4. Once you have a separate formatted partition, you will need to copy the contents of the /home directory to the new partition. This can be done using various CLI tools under root. You can use cp -a and rsync. I use cp -a although in  the past I used rsync. Make sure to mount the new partition before attempting to write to it and pay special attention to the mount point you will be using because you don't want to corrupt the existing partition.

Let us say, the new partition to hold the contents of /home is /dev/sda10:

The Procedure:

  1. To mount the partition:

    # mount /dev/sda10 /mnt/my_home
  2. To copy /home to the new partition:

    # cp -a /home/* /mnt/my_home
  3. Unmount the partition:

    # umount /mnt/my_home
  4. After that, you will need to edit the /etc/fstab file so that at boot the new partition is mounted on /home. This can be done by adding a new entry to the file as root. To find the uuid of the partition, use the blkid command to list the uuids of the partitions.

  5. Add the new entry to the fstab file as shown:

    UUID=the_long_long_uuid  /home           ext4    defaults,noatime        0       2

    Save the file.

  6. Reboot to test  whether the installation uses the new partition. Use mount without parameters for that.

  7. When you are 100% sure that the installation is using the new partition, you can delete the data under /home which is hidden when /home is used as a mount point. Don't do this while your installation is running, instead use a LiveCD for that. Be cautious because you can easily delete your valuable data especially if you dare to do this procedure without making a backup. A backup is very strongly recommended.

  8. Using a Live Devuan CD, issue this command as root although it shouldn't be necessary to be root.

    1. Create a temporary directory under mount for the Live Linux CD session as follows:

      mkdir /mnt/my_devuan_installation
    2. Mount the root partition of the installation of which you want to purge the contents of /home.

      mount /dev/sda2 /mnt/my_devuan_installation

      I assumed /dev/sda2 contains the blessed installation.

    3. Perform the dangerous cleanup:

      rm -rf /mnt/my_devuan_installation/home/*
    4. Unmount the partition:

      # cd /
      umount /mnt/my_devuan_installation

This same procedure can be used to transfer any directory to a dedicated partition. However, different mount parameters have to be used in /etc/fstab because /home does not have the same permissions as system directories and you don't want to render your system insecure or unusable.

Enjoy! smile


#2 2016-12-07 19:35:48

Registered: 2016-12-07
Posts: 6  

Re: Moving /home to a separate partition after installation.

Hi edbarx,

Since you mention using a Live CD starting from step 7, why not do everything from the Live CD? I think it also makes it easier for the preparation of the partitions, since it's not possible to shrink some FS (ext4, for instance) online. And if during the reboot the /home does not mount correctly, it's still possible to log in as root and fix the /etc/fstab.


#3 2016-12-08 13:34:33

Registered: 2016-12-01
Posts: 16  

Re: Moving /home to a separate partition after installation.

Malinas wrote:

Hi edbarx,

Since you mention using a Live CD starting from step 7, why not do everything from the Live CD?

Modifying my method as a result of understanding the reasons behind it is a good thing that I fully encourage. I cannot and I do not intend to shackle independent problem solving.


#4 2017-07-08 10:42:14

Registered: 2017-06-28
Posts: 11  

Re: Moving /home to a separate partition after installation.

You can just boot single-user to do all this.


Board footer