1

I'm using Ubuntu Server 20.04, and have access to a remote server via SSH.

I need more room in the root FS, and so have made a copy of the /var directory on another partition. I've then added to my /etc/fstab to make it mount the new /dev/sdX2 over the old /var.

All is well... df -h /var indicates that it's using the newly mounted version.

However, I now can't remove the original one to free up the space that I so badly need. If I run mount --bind / /mnt/root, and then try to do anything, like mv /mnt/root/var /mnt/root/var.old, I get: mv: cannot move 'var' to 'var.old': Device or resource busy.

As this is only really accessible through SSH, I can't get in to single user mode.

So, the only other thing I can think of is to have a script that will move the original /var directory to /var.old, and then, once I can see everything is working correctly, remove it once and for all.

The main issue is that this script will need to load before fstab or anything hooks in to var, and I'm not even sure if that's possible?

Any other ideas?

2
  • Ubuntu 19.04 is past EOL, and we no longer answer questions about it here. Consider re-partitioning and re-installing to remove some of your constraints.
    – user535733
    Jun 7, 2020 at 1:18
  • I'm trying to upgrade, that's why I need the space. Let's say I'm on 20.04. Nothing I've remarked upon has changed in the release cycles since.
    – Jack_Hu
    Jun 7, 2020 at 1:24

2 Answers 2

1

Your mount command is not the good one. You must call the disk drive device, not the root symbol ie

sudo mount /dev/sdZX /mnt/root
sudo mv /mnt/root/var /mnt/root/var.old
sudo umount /mnt/root
1

You cannot mv or rm the folder /mnt/root/var since /var is used as mountpoint for your new partition. Instead, mv it's contents:

mkdir /var.old
mount --bind / /mnt/root
mv /mnt/root/var/"*" /mnt/root/var.old/
umount /mnt/root

After checking that everything works fine you can remove /var.old

rm -r /var.old 

You must log in to answer this question.

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