On Sat, 2019-08-17 at 09:38 +1000, Cameron Simpson wrote:
On 16Aug2019 13:18, Patrick O'Callaghan
<pocallaghan(a)gmail.com> wrote:
> I'm trying to rationalise space by moving my /var directory from its
> own partition to /, as currently there's a lot of wastage. I've copied
> /var to /newvar with rsync, and now want to mount /newvar as /var on
> reboot by creating an entry in /etc/fstab. This is it (using /var-tst
> for testing):
>
> /newvar /var-tst ext4 loop
0 0
That isn't what loop is for. loop is for associating a file with a
device.
What you want is "bind", not "loop", because you're binding an
_existing_ mount to another location.
> but I'm getting:
>
> mount: /var-tst: failed to setup loop device for /newvar.
Because /var-tst is a directory, not a file-shaped-like-a-partition.
Yes, I finally got that.
Example from our home server:
/app8tb/media/video /exports/video none bind,relatime 0 0
> PS Suggestions on how to move /var without all this jiggery-pokery are
> also welcome.
If you want /var to be on /, rsync it as you have done, and just make a
symlink as /var.
That implies overwriting the existing /var directory entry, which is
not possible while the system is running, even in single-user mode.
Really, all you need to do is to remove the /var fstab entry, umount
the
existing /var mount, rsync /newvar BACK INTO the stub /var mountpoint
which is there, scrub /newvar.
/var cannot be unmounted while the system is running (see above).
I did finally solve it following the suggestion from
Francis.Montagnac(a)inria.fr (adding rd.break=pre-pivot to the boot line,
then remounting /sysroot etc.)
No fstab trickery required (other than erasing/commenting the /var
line).
Then afterwards you need to decide what to do with the partition you
have been using for /var.
I'm going to merge it with / (the two are contiguous) but that will
have to be via a live USB stick. I know that doing this with LVM would
be easy (for certain values of "easy") but I gave up on LVM years ago
as it made my head spin :-)
poc