I have a CentOS 7 system with a /home partition that is too large. I wish to reduce its size but it's XFS so that's pretty much impossible. Since I don't have much user data anyway (only 1 user currently), is it possible to tar the entire partition data, copy it out, delete the partition, repartition it to, say, ext4, with a smaller size?

If so, what are the commands to do so?

2 Answers 2


As this is not the root partition (/) you should be able to do this without losing data, if you login as the normal user, various files under your home directory are updated (from background email reading, surfing etc.). You don't want to lose emails that arrived between the backup and the restore).

The important thing to be able to repartition being is that you login either as root or as a user that doesn't have its home directory under /home. This is in order to be able to unmount /home without it being in use and repartition and reformat it.

Login in as root might not be possible, or at least not recommended, from the graphical interface (X, I'm not running CentOS 7 and cannot check). But graphical tools are probably more easy to use if you are less experienced in these ways. And if you are logged in and have a normal desktop you can also still use the internet to search for solutions if things go wrong. So in the following I will minimize reliance on using commandline tools.

You could move your existing user's /home/XYZ directory to e.g. /home2/XYZ (which is on the root partition), but there is probably too much data under that directory to do so. Therefore I recommend the following steps (for the commands you have to open a terminal):

  1. create a new temporary user xyz with a home directory /home2/xyz
  2. make sure this user can issue sudo commands
  3. logout and login as this user (using the GUI, not via the login: prompt
  4. unmount /home and remount it to make sure nothing is currently using it:

    sudo umount /home
    sudo mount /home
  5. check that the backup medium is available, lets assume this is under /mnt/USB01 (normally you check if the backup will fit, but you indicated there is not much data, so I will assume it does).

  6. use tar or cpio to backup from under /home (this is faster than copying individual files, and even should work if the backup medium is VFAT).

    sudo  tar --create --verbose --file=/mnt/USB01/homebup.tar.bz2 -C /home .
  7. check that you can read back the file you just created:

    sudo tar tvf /mnt/USB01/homebup.tar.bz2
  8. check on which partition /home is mounted, write the partition down (e.g. sdX2) and umount:

     mount | grep -f /home
     umount /home
  9. comment out the entry for /home in /etc/fstab, you might have UUID instead of sdX2, you can lookup which UUID belongs to sdX by doing:

    ls -l /dev/disk/by-uuid/ | grep -F sdX2
  10. repartition the drive sdX on which is the partition you found in the previous step, by deleting the `sdX2 partition and recreating it (if smaller you can create additional partitions now, or postpone that)
  11. make your filesystem of choice on one of the newly created partitions (You can usesdX2 again, but that partition will have a new UUID, so look it up)
  12. edit /etc/fstab and make sure you can mount /home by doing:

    mount /home

    (by editing /etc/fstab and mounting this way you'll have the partition mounted on reboot).

  13. (optional) reboot and make sure /home gets mounted
  14. restore the data on /home with:

    sudo tar xvf /mnt/USB01/homebup.tar.bz2 -C /home
  15. reboot and login normally
  16. remove the temporary user account
  • This is quite a new setup, so I only have 1 user in /home, and there isn't much data in there at all. I've just checked, and I actually have enough space in my /root partition to house /home/user. I've copied the directory over to /root/home2/user and unmounted /home, but I'm not sure how to find out which partition it's on. fdisk shows the following information: /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 1953523711 976248832 8e Linux LVM /etc/fstab shows "/dev/mapper/centos-home" for the /home entry. Commented Oct 7, 2014 at 5:02
  • Step 8 of the answer: You can check on which partition /home is by remounting it and using mount | fgrep /home. Using fdisk is more guesswork as it doesn't know much about what is in its partitions.
    – Anthon
    Commented Oct 7, 2014 at 5:12

You might take a look at something like clonezilla. With clonezilla on a small usb stick and somewhere to backup the data to (local or network), you could pretty much do exactly what you described - copy it out, delete the partition, re-partition it with both a different filesystem and smaller size, and then restore it. Working directly with the partition image (usually the easiest option) won't work so well going from bigger to smaller, but you should still be able to make it work. Check it out!

  • Hi, seems like clonezilla is a disk imaging software like Acronis that does bit-for-bit copy? Do I actually need this or would it be ok to just tar /home, copy it somewhere else, re-partition/re-size /home, copy the tar back and then untar it? Also, how would I actually re-partition it to a different filesystem and smaller size? Can I use something like gparted? Not sure if that works with XFS. Commented Oct 2, 2014 at 6:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .