1

How can I move files from a full partition to one with more room?

Backstory:

Centos7 partitioned the 1TB hard drive on installation. I didn't realize that the partition mysql installs and runs from only has 50G. It reached maximum capacity and now the mysql service will not start so I can't simply drop or truncate tables. After I get this running I'll be searching online how to keep mysql tables on the large partition. I don't actually know why linux centos needs so many little partitions or what they are for. I don't have an internet browser on the linux machine so I can not copy and paste the output of df -h.

The partition mounted on / only has 50G while the partition mounted on /home has another 800G free.

Thanks for your help.

2

You should copy the contents of /var/lib/mysql onto a larger partition, remove the old copy from the space-constrained partition, and create a soft-link to the new location at /var/lib/mysql so that the system will find and use the new location instead.

As requested, here are actual commands, but as always please exercise extreme caution before running rm commands (i.e., check to make sure that your files have copied correctly -- using, for example, du -shx . in both places to check that the total size is approximately the same):

mkdir /home/var-lib-mysql
cp -ax /var/lib/mysql/. /home/var-lib-mysql/
rm -rf --one-file-system /var/lib/mysql
ln -sf -T /home/var-lib-mysql/ /var/lib/mysql

And, of course, keep in mind that this is a hack and you should refrain from ever creating a user account literally called "var-lib-mysql".

  • Thank you for the input. The question is "How?" mv /var/lib/mysql /home/mysql? How do you create a softlink so that mysql would still run? – Aunt Jemima Nov 20 '16 at 4:20
0
  • Create 'new partition'.
  • Mount 'New partition' to folder 'backup'.
  • Copy all contents and permission of '/var/lib/mysql' onto folder 'backup'.
  • Umount folder backup.
  • Mount 'ew partition' to '/var/lib/mysql'.

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.