3

I have a /var directory that sometimes gets too large for the partition it's on. It would be beneficial if I could mount this directory on a larger partition.

I don't have physical access to this machine though. Only SSH and similar remote access.

How can I remount /var safely on a machine that I don't have physical access to?

The only solutions I know of involve boot discs or init 1, so the popular directory isn't accessed during the transition.

Drew Dormann
  • 87
  • 1
  • 10
  • do you "super user do" sudo acess in the remote machine? Can you do something like ssh -v root@somehost.. you may want to do something like sudo bash -C " excute some command...." – z atef May 15 '17 at 03:37
  • Which filesystem are you using for /var? You mentioned partition, but to clarify, do you mean a disk partition or an LVM volume? – Emmanuel Rosa May 17 '17 at 21:28

1 Answers1

3

With only ssh (and su/sudo of course):

  • mount the bigger disk on a temporary mount-point
  • update /etc/fstab using the bigger disk device but using the mountpoint of the current /var, and with the existing disk device for /var in another temporary mountpoint (to allow recovering stray last-moment log messages). Just editing /etc/fstab will not force the remounting. And by the way, mounting it and writing to it ensures that you've made the filesystem, and have the device information consistent.
  • rsync the current /var to the bigger disk (to reduce the amount of log-history loss)
  • reboot, which will use the updated /etc/fstab to mount /var on the bigger disk.
Thomas Dickey
  • 75,040
  • 9
  • 171
  • 268