0

I mounted a new ext4 storage volume to my server after I had already installed an application that primarily uses /home. This application needs to take advantage of the additional storage, so I want to remount the volume so that it's used by the /home directory. Can anyone confirm my steps below?

umount -v /mnt/volume_nyc1_01
# Edit /etc/fstab 
# Replace the second field of the mountpoint's entry with /home
mount -av

I appreciate the feedback. I'm asking in hopes to avoid messing up my system by overlooking important considerations.

2 Answers 2

1

I assume that /mnt/volume_nyc1_01 is the mountpoint for the new ext4 volume. There is a line in /etc/fstab in which this volume is mounted on /mnt/volume_nyc1_01.

The steps you mention are not technically wrong, but if you follow them, you'll end up having an empty /home directory - since it's a new ext4 fs only lost+found will be there.

The steps I follow on such cases are:

  • Stop any service, daemon, app using /home.
    lsof |grep "/home" can help you with this.
  • Leave /etc/fstab as is for the time being and copy all data from /home to /mnt/volume_nyc1_01.
    I'd use this command:
    sudo rsync -aHAXS /home/* /mnt/volume_nyc1_01
  • After everything is successfully copied, you can proceed with the steps you described. The new volume will be mounted as /home and will include all your data.

If everything is up and running, at some point in the future you could unmount the new volume from /home mountpoint and delete the files in the /home directory which will still be there, and reclaim space on your first volume. Be cautious, /home is still a directory on the 1st volume, which is also used as a mountpoint for 2nd volume. So deleting files from /home directory is possible, without deleting files from the 2nd volume, if you umount the 2nd volume first. If all this seems complicated, just let the old files there.

1

My first answer to this: DON'T. If you don't know what you are doing, you could lose your (and any others) home directory. Especially the way you have mentioned above.

Since you didn't mention the application your working with, I'll just give some generic advice:

  1. check the app's preferences to see if you can point it's data to where it wants, then you could mount the new drive at any new mount point, copy the app's current data there, then add a line to fstab to permanently mount the drive there:

       find the app's current data storage dir, then
     $mkdir <app mount point>
     $mount </dev/sdX> <app mount point> (where </dev/sdX> is the new drive)
     $cp -pr <current app data> <app mount point>
       using your favorite text editor, add a new line to "/etc/fstab" that looks like this:
    
       </dev/sdX>   <app mount point>    ext4    defaults   1 1  
    
     finally, change the app's data storage preference to <app mount point>
    

    (check man fstab to see the format and meaning of the entries for that line)

When you start the app, everything should look the same as before. As I mentioned above, without knowing the app, I can't tell you how to change the preferences - if it even can be done. Check the app's help pages for more info before you do this.

  1. A bit more dangerous, you could mount the new drive as your home dir:

            using your favorite text editor, add a new line to "/etc/fstab" that looks like this:
    
         </dev/sdX>   <app mount point>    ext4    defaults   1 1
    
           Mount the drive /dev/sdX at some temporary point and copy your currrent home dir to the new mount point:
    
         $mount </dev/sdX>  /mnt
         $cp -pr /home/you/* /mnt/.
           reboot, and you should be able to login as before, and nothing else would have (should have?) changed.
    

As I keep saying this is dangerous if you don't know what you are doing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.