1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Move mail folder to other partition

Discussion in 'E-mail Discussions' started by ladless, May 12, 2011.

  1. ladless

    ladless New Member

    Joined:
    May 12, 2011
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Hello.

    I am the latest Centos distro and the latest cPanel version.

    As you know all users have their stuff in the /home folder.

    Now, I have /home/user/mail. The "mail" folder contains all the e-mail accounts listed under that user account.

    However, I want to change the location of this to another partition, let's say /usr or /var for example.

    Would a symlink work with this ?

    I am in great need of disk space and the /home partition only has 50gb as /usr has 200gb.

    Thank you very much.
     
  2. cPanelTristan

    cPanelTristan Active Member
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,621
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    Most partitioning schemes have /home with the most space, especially cPanel-based machines. Why precisely was /usr given 4x the disk space over /home partition?

    Maybe you would want to have some accounts writing to /usr instead such as /usr/home for new accounts. If you create an area for new accounts to go there, then you should be able to use WHM > Basic cPanel & WHM Setup area for this section:

    To have new user accounts put into /usr/home instead of /home due to it having more disk space. It would be better to have a secondary partition (/usr/home) being used for the new accounts over trying to move existing data and symlink it in /home
     
  3. ladless

    ladless New Member

    Joined:
    May 12, 2011
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Thank you very much for you kind answer.
    Everything you said is correct and known to me. Unfortunately I don't have a choice. I only have 2 accounts and never will have more than these 2. Thing is the mail folder is getting bigger and bigger and I have only two choices (?):
    somehow increase the free space on /home partition by taking space from /usr and/or /var (each of them is of 200GB)
    OR
    move the /home/user/mail folder to one of /usr or /var partition and trick cPanel with a symlink.

    Any suggestions would be much appreciated.

    Thank you.
     
  4. cPanelTristan

    cPanelTristan Active Member
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,621
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    If you are going to do this, please ensure that you have full backups before trying to move the folder to another partition. I cannot say the results as I've never tried it previously. If you have full backups, you can at least restore the account or folder if needed.

    I did do some basic testing doing the steps below by moving the mail folder for a testing domain and then symlinking it back. After performing those steps, I was still able to create new email accounts, log into webmail interface and send a test email from Roundcube. So those areas appear to still function per the very quick test I performed.

    For moving it, all you'd do is the following (please do not create the email folder beforehand and let it be created with the move command):

    Code:
    mv /home/username/mail /usr/username-mail
    A move normally maintains the permissions, so you should then be able to do the symlink:

    Code:
    cd /home/username
    ln -s /usr/username-mail mail
    Please replace username in all instances to the cPanel account username.
     
  5. ladless

    ladless New Member

    Joined:
    May 12, 2011
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Very comprehensive and helpful. I will engage in this hopefully this weekend. Thank you so much (this reminds me why I paid 400+ bucks for this tool).

    Will test this and will let you know.

    Thank you !
     
  6. ladless

    ladless New Member

    Joined:
    May 12, 2011
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    So, here's my reply as promised.
    I am able to send/receive e-mails after moving the mail folder as instructed above.
    note that I issued the command
    Code:
    /sbin/service exim stop
    before the actual mv command and
    Code:
    /sbin/service exim start
    after it completed.
    Lots and lots of e-mails so patience was my ally. I opened up another SSH instance and monitored the transfer with 'df' command.

    So, in addition to your tests I add mine and I confirm that so far all is good.

    Thank you very much again !
     
  7. ladless

    ladless New Member

    Joined:
    May 12, 2011
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Hello again.

    After almost one year now... It has come to my attention, now that I am migrating the user-accounts from this server to a new one, that the e-mails weren't transfered.

    Also, neither the backup process that is built-into cPanel has ever backed up the e-mails because they were located in /usr/username-mail... not in /home/username/mail (as they should be by default)...

    Are there any chances for me to backup the e-mails with the built-in backup function (that apparently doesn't know how to follow the @mail symlink in /home/username/) or should I write a script to just tar them where they are and then rsync them on a backup server ?

    Also, as I was saying, I am now migrating the account on a new server... of course the migration process took care of everything except for the e-mails... (sheeeesh ! lots of hassle for that first partitioning mistake).

    So, I've let the migration function finish, everything went smooth and I did the same steps like in the above posts with symlinks and now I am using rsync to copy the /usr/username-mail from the old server to the new /usr/username-mail on the new server...
    Should I expect this to succeed properly ? (119GB transfer gave me the time to write this)

    Thanks !
     
  8. cPanelTristan

    cPanelTristan Active Member
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,621
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    Backups will not follow symlinks, so this would not be backed up. It would have been more advisable (as originally suggested) to have set the accounts to /usr/home and have them create there without using symlinks. As you are now doing, you'd manually copy over those mail folders to the new machine. I would suggest having mail collect in the default /home location on the new machine rather than continuing to use this setup provided you have sufficient space in /home on this server
     
  9. ladless

    ladless New Member

    Joined:
    May 12, 2011
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    I understand. Well, the rsync has finished successfully and all the e-mails were copied without any problems. I've set up a cron job that triggers a zipping of the mail folder and then uploads the tar to a remote backup server. Everything works as expected.

    However, is there a way to increase the space on a partition by taking up space from another one ? I know this is possible in Windows using numerous tools but I don't know if this is possible in linux. I understand that ext3 can support live resizing... would this work with the appropriate tool ?


    Thanks.
     
  10. cPanelTristan

    cPanelTristan Active Member
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,621
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    You can attempt to resize a partition using space from another partition. The most typical type of resizing is for /tmp partition. I cannot really recommend how to do it, since I wouldn't recommend resizing any partition other than /tmp on a production machine.
     
  11. ladless

    ladless New Member

    Joined:
    May 12, 2011
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    I see... I wanted to resize /home (currently 200GB) and take size space from /usr (1TB)... Thank you.
     
  12. cPanelTristan

    cPanelTristan Active Member
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,621
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    On a machine currently in production with active accounts? If so, again I cannot recommend doing that.
     
  13. ladless

    ladless New Member

    Joined:
    May 12, 2011
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Yes... I'm afraid so... I will seek some advice in the Centos forums... Perhaps they have met this situation before and can advise me how to do it...
     
  14. pkiula

    pkiula New Member

    Joined:
    Jan 14, 2012
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    Did you ever get around to doing this? I need the opposite help. I need to move away space from my massive /home folder to the /usr folder.

    Code:
    Filesystem    Type    Size  Used Avail Use% Mounted on
    ...
    /dev/sda5     ext3    9.7G  2.6G  6.7G  28% /
    /dev/sda7     ext3    152G   16G  128G  11% /home
    /dev/sda3     ext3    9.7G  9.3G     0 100% /usr
    ...
    /usr/tmpDSK   ext3    2.0G  473M  1.5G  25% /tmp
    
    I want to move some space from that /dev/sda7 ("/home") into the /usr folder.

    What's a good way to do this? How do I ensure that the "free" part of the /home folder is given away to the /usr folder?

    Thanks!
     
  15. ladless

    ladless New Member

    Joined:
    May 12, 2011
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Hello,

    I didn't had the time to work on this yet, but instead I used a 'work-around' with symlinks to 'trick' the system and buy me some more time until I will have the time to put down the box and try a partition resize.

    Sorry I can't help you more now.
     
  16. cPanelTristan

    cPanelTristan Active Member
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,621
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    Why would anyone risk a partition resize versus going to a new machine with proper partitioning? There's always a possible risk of the production machine being corrupted and losing your data. Obviously, resizing /tmp isn't a big concern, since that data is just temporary anyway and losing it wouldn't really matter. Just wondering the reasoning here.
     

Share This Page