I have a system which completely resides on a (relatively small) single harddrive (/dev/sda). Now I am expecting to /var/lib/ to become populated with more and more files (due to using lxd containers) and therefore I want to shift that to another hard drive or partition which I am adding to the system.

2 methods come to mind and I'd like to get some advice from a little more experienced people which one to favor

METHOD A - symlink

  1. sudo cp -a -r /var/lib/ /mnt/new-hd/
  2. sudo mv /var/lib /var/old-lib
  3. sudo ln -s /mnt/new-hd/lib
  4. reboot

METHOD B - mounting new folder over existing /var/lib

  1. sudo mnt /dev/new-hd
  2. /mnt/temp sudo
  3. cp -a -r /var/lib/* /mnt/temp
  4. sudo umount /mnt/temp
  5. create fstab entry for /dev/new-hd (to be mounted to /var/lib)
  6. sudo mount -a

looking at it now. I'm in favor of METHOD B slightly. Any comments?

In my usecase it's about lxd, so I am also wondering whether shifting the entire /var/lib is the best choice for this or should I only move the relevant parts? Mocing the entire /var/lib has the advantage to have a structure which is very similar to the default (and therefore less custom things to be aware of)


If you were building the system from scratch, you'd probably use method B because that's the proper way to spread your file system over multiple physical devices. So if you can do B, I think thats the more-sound approach. I'd only use method A if you were planning to exchange different copies frequently, or needed one copy to exist in two places.

| improve this answer | |
  • ok, seems you both agree on that. And that sounds reasonable to me. thanks – vrms Mar 31 '17 at 5:37

Is it really necessary to perform this operation on a running machine? Why dont you download a livecd of any linux distro, and run the system from cd/usb? You should be able to move the /var/lib to any other location without any problem. Dont forgett to copy/move file permissions.

| improve this answer | |
  • no, not necessary to do this on a running system at all. would you then just mv /var/lib to the right place? I mean 'mv', not 'cp' – vrms Mar 31 '17 at 5:34
  • yes. boot from a cd, move the /var/lib to the desired destination. The advantage of this is - if anything goes wrong (like wrong permissions) - you will still be able to reboot, start the livecd linux and correct the settings. This is rather simple operation, but sometimes there is little devil hidden in "simple task" ;) Remeber to check permision on /var/lib after you mout the additional drive. – psad Mar 31 '17 at 9:24

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.