I have a server with a program which rapidly writes data to a folder. I attached a new disk to the server, mounted it and now I want it to expand or replace the folder with data. The program works with hardcoded folder names and I don't really want to stop it copy the files to new disk and symlink them to address of the old folder.

My original way would be like this:

rsync -avxP --progress /data/oldsrc /mnt/newsrc/
rm -rf /data/oldsrc
ln -s /mnt/newsrc /data/oldsrc

Is there any way to do this without moving/copying old files, removing them from source and linking from new disk to old folder?

Edit: I need all the data in the old folder to be accessible by the program.

  • Can't you unmount /data/oldsrc/and mount /mnt/newsrc instead? – Panki Dec 7 at 9:29
  • @Panki i need all the data inside the old folder accessible. Editing my question. – Mustafa Yılmaz Dec 7 at 9:41
  • Is it an LVM filesystem structure? Kindly post the output of df -Th. – erTugRul Dec 7 at 9:53
  • @erTugRul nah it's an EXT4 drive. /dev/sda3 ext4 309G 286G 6,6G 98% / – Mustafa Yılmaz Dec 7 at 10:20
  • No. You should stop the software that is writing. Then tar up the contents of the directory, delete the contents of the directory, mount the new disk in the directory, unpack the tar archive, and then start the software. – Christopher Dec 10 at 14:56

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.