Need to adjust partition sizes post install without loosing data

Discussion in 'Installation/Configuration' started by vestport, Nov 15, 2014.

  1. vestport

    vestport Member HowtoForge Supporter

    I recently installed ISPCONFIG and followed the perfect install. I am 99% sure I took all the default partitions for my 2TB drive but something goofed. I just ran out of space copying files due to my root partition being about 52GB and may /home being pretty much the rest. The only thing I have in the /home directory is one regular user and can be deleted if need be.

    Here are the stats:

    Filesystem 1K-blocks Used Available Use% Mounted on
    /dev/mapper/centos-root 52403200 52403180 20 100% /
    devtmpfs 3996392 0 3996392 0% /dev
    tmpfs 4003556 0 4003556 0% /dev/shm
    tmpfs 4003556 197192 3806364 5% /run
    tmpfs 4003556 0 4003556 0% /sys/fs/cgroup
    /dev/mapper/centos-home 1890830276 32940 1890797336 1% /home
    /dev/sda1 508588 131724 376864 26% /boot

    Not too pretty as you can see. 100% used on my "/"! As I am not using gnome etc. and used the perfect install I will need to do this with fdisk most likely but not sure how. I spent weeks on this server and just noticed this copying huge data over when I ran out of room. OOPS!



    What I need to do is shrink my /home directory and give up 99% or it to "/" asap. How can I do that without loosing all the data that I already have in "/"?

    Thanks in advance for any replies.

    Please help!


    Art
     
    Last edited: Nov 15, 2014
  2. vestport

    vestport Member HowtoForge Supporter

    I jumped the gun and tried a:

    Code:
    lvresize -L -200GiB /dev/centos/home -r
    and then got myself in trouble trying to remount the partition with superblock errors. Also, the system would not reboot so I tried:

    Code:
    xfs_repair -n /dev/centos/home
    and no luck. All I got was a bunch of periods with the logical drive trying to recover .....................................................................................................................................................................................................................................to find the superblocks I guess.

    The /dev/centos/home volume that I resized was initially 1.8TB and I simply wanted to reduce it to 200GB so I could free up the other 1.6TB for the "/" partition where I need it for my vhosts. After that I would need to resize (grow) the "/" partition to max (or 1.6GB more than it was. This obviously should have been done at install but that's the way it goes I guess when your rusty.

    Luckily I found some info where at least I could get back up and running by editing /etc/fstab:

    Code:
    vi /etc/fstab 
    and commenting out the line for that logical drive "/dev/centos/home"


    The only file that was in the "/dev/centos/home" partition was a single user directory with nothing in it except for maybe some hidden files for the user.

    I need some advice before proceeding. I am running CentOS 7 and the latest version of ISPCONFIG 3. My 2 drives are RAID 1 hardware mirror array on a Dell PowerEdge 1950 so not so easy to just pull a drive to use a gui app to resize the 2 partitions.

    At this point I need to first figure out what the heck went wrong with reducing /dev/centos/home and get that back online before moving forward to grow my "/" partition to max with the additional 1.6GB I picked up from reducing /dev/centos/home. /etc/centos/home did reduce but I think I needed an additional command to reduce the block size too and that is why the drive would not remount or boot after I ran

    Code:
    lvresize -L -200GiB /dev/centos/home -r
    initially.

    Can't make that mistake on the "/" partition as I have way more than a single directory there and all my vhosts, mail, etc.

    Any help to get my home /dev/centos/home partion back online and grow the "/" partion to max via command line is welcome.


    Thanks,


    Art
     
  3. vestport

    vestport Member HowtoForge Supporter

    df shows:

    Code:
    [[email protected] ~]# df
    Filesystem              1K-blocks     Used Available Use% Mounted on
    /dev/mapper/centos-root  52403200 44990764   7412436  86% /
    devtmpfs                  3996392        0   3996392   0% /dev
    tmpfs                     4003556        0   4003556   0% /dev/shm
    tmpfs                     4003556    58004   3945552   2% /run
    tmpfs                     4003556        0   4003556   0% /sys/fs/cgroup
    /dev/sda1                  508588   131724    376864  26% /boot
    [[email protected] ~]#
    
    fdisk reports the following:

    Code:
    [HTML]           Device Boot      Start         End      Blocks   Id  System
    
    Command (m for help): p
    
    Disk /dev/centos/home: 214.7 GB, 214748364800 bytes, 419430400 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk label type: dos
    Disk identifier: 0x79f200e8
    
               Device Boot      Start         End      Blocks   Id  System
    
    Command (m for help):
    [/HTML]
    
    My partition /dev/centos/home does not show up after I reduced the size from 1.8TB to 200MB. I read online that xfs partitions cannot be reduced and can only be expanded. I assume that it was an xfs partition. I followed perfect install for centos7 and ISPCONFIG 3. I let the software decide partitioning. All I really had in the /home directory (/dev/centos/home) was a single directory for a regular user created during install. Now I deleted the /dev/centos/home like so:

    Code:
    lvremove /dev/centos/home
    and created a new 200GB home partition like so:

    Code:
    lvcreate -L 200000 -n home centos
    then

    Code:
    mkfs.ext3 -m 5 /dev/centos/home
    but even after un-commenting the line for /dev/centos/home

    Code:
    mount /dev/centos/home
    still won't mount.



    Also, I should mention that it warned me that if I created the partition I would loose the signature. I thought the volume was trash anyways so that is why I blew it away and tried to just create a new one.

    Still stuck on this and reluctant to try to expand my "/" partition for fear of loosing the whole system. My system is running, just without the /dev/centos/home partition and without having expanded the "/" volume another 1.4GB to 1.6GB.


    PLEASE HELP!!!!
     
  4. vestport

    vestport Member HowtoForge Supporter

    To regrow the new expanded /dev/centos/root partition I also had to do a:

    Code:
    xfs_growfs -d /dev/centos/root

    while it was mounted.


    I still need help with mounting my smaller /dev/centos/home partition if anyone can help.
     
  5. srijan

    srijan New Member HowtoForge Supporter

  6. vestport

    vestport Member HowtoForge Supporter

    Thanks Srijan, No luck. I have seen lots of these pages that show how to resize and create filesystems but the problem still seems to be just getting this to auto mount in /etc/fstab.

    The current line in my /etc/fstab for this partition is:

    Code:
    /dev/mapper/centos-home /home                   xfs     defaults        1 2
    
    I have resized this partition and also it is definitely xfs via force:

    Code:
    mkfs.xfs -f /dev/centos/home
    I have a directory named /home

    when I type:

    Code:
    mount -n

    It is not mounting it in /etc/fstab and also will not boot without going into maintenance mode.

    Code:
    df -h
    does not show the partition after a:

    Code:
    mount -n

    I also tried prefixing the

    Code:
    /dev/mapper/centos-home /home                   xfs     defaults        1 2
    
    with the UUID and that didn't help either.



    Code:
    [[email protected] ~]# mount /dev/centos/home /home
    [[email protected] ~]# ls
    [[email protected] ~]# df
    Filesystem               1K-blocks     Used  Available Use% Mounted on
    /dev/mapper/centos-root 1520409600 65536816 1454872784   5% /
    devtmpfs                   3996392        0    3996392   0% /dev
    tmpfs                      4003556        0    4003556   0% /dev/shm
    tmpfs                      4003556    16984    3986572   1% /run
    tmpfs                      4003556        0    4003556   0% /sys/fs/cgroup
    /dev/sda1                   508588   131724     376864  26% /boot
    /dev/mapper/centos-home  204700000    32928  204667072   1% /home
    
    At this point the xfs partition is there, it is the right size, it has an xfs filesystem on it, it will mount manually. I just need someone to show me how to get it to work again in my /etc/fstab so it will boot without going into maintenance mode. My current line does not work (with or without a UUID).

    Here is the current /etc/fstab line again that originally worked before I reduced the size of /home:

    Code:
    /dev/mapper/centos-home /home                   xfs     defaults        1 2
    

    Currently it's commented out so the system will boot. I realize that I don't really need a separate /home partion anyways and that I can do that just with a directory but I would just like to get this working again the way it was.
     
  7. srijan

    srijan New Member HowtoForge Supporter

  8. vestport

    vestport Member HowtoForge Supporter

    Hi Srijan,

    It looks like the article is for accessing directories and not whole xfs partitions. I tried bind as described and many variations and no luck. I edited the /etc/fstab, mount -n and then checked with "df" and the partition did not appear each time. I can manually mount this so I know the partition is good. I just can't get it too come up in fstab.:eek:
     

Share This Page