0

Now on my server, we have 20GB disk size. We use it for daily backup with this path: /var/lib/backup. Filesystem is on /vda.

But it's small. It will be used out in future soon. So we added another volume(disk) to this instance. It like:

sudo lsblk -f
NAME   FSTYPE  LABEL    UUID                                 MOUNTPOINT
sr0    iso9660 config-2 2020-03-05-17-33-22-00
vda
`-vda1 xfs              5c248666-70f5-4037-8b24-17100c2f5c1e /
vdb    swap             5210b427-142c-4958-a2f9-461b4a431eec [SWAP]
vdc
`-vdc1 xfs              5c248666-70f5-4037-8b24-17100c2f5c1e

vdc is added new one. /dev/vdc1 can be used.

If mount /dev/vdc1 to a special path such as /mnt, the disk can be added. But daily files increasing occurred at /var/lib/backup path(vda volume). /mnt can't be used automatically. How to make it possible to join them together?

I tried symbolic link for it.

ln -s /var/lib/backup /mnt

Here I have another question. If files in /var/lib/backup increased, that's on /vda, link to /vdc, are the files use the same space both on the /vda and /vdc? Or use /vda only, when /vda used out, continue use /vdc? How they use 2 different disks?

rawmain
  • 291
  • 1
  • 7
  • 17
  • Your question is a bit unclear,l as far as exactly what you know and what you are trying to do. Are you aware of /etc/fstab - you can graft disks directly into file trees without going via /mnt - and fstab is reqd at startup. – davidgo Mar 30 '20 at 09:13
  • When you symlink or grapht a directory structure, files are stored on the grafted disk only, thus if you have /var/lib (on sda1) and /var/lib/backup (on sdb1) the files in /var/lib/backup are stored only on sdb1. – davidgo Mar 30 '20 at 09:15
  • Your symlink idea, while messier then using fstab to directly mount should work (and indeed is a solution used in more complex scenarios). That said, I think your syntax is backwards. Its ln -s /src /target - so ln -s /mnt /var/lib/backup so that writing to /var/lib/backup actually writes to /mnt. – davidgo Mar 30 '20 at 09:20
  • (I note I've kept this simple in line with your question - there are other solutions which greatly muddy the waters, which arguably makes my answer above technically wrong - if you start using union filesystems - but you won't do this by mistake - and you need to be strong on the basics before getting to that level) – davidgo Mar 30 '20 at 09:23

1 Answers1

1

Here are the points I want to clarify:

  1. You usually don't mount directly on /mnt. Instead, you mount on a directory under it like /mnt/mydisk.
  2. You can not create link matching same name as existing file or directory. You will get an error, because link is actually a file.
  3. When writing to a link you are actually writing to the target. So, it will simply consume disk space from the target file partition.
  4. You can combine two disks using LVM if you are already using it. Here is a link.

It is still possible to use links to increase disk space without too much trouble combining the partitions / disks.

Suppose, you have your files/directories organized under two directories like:

/var/lib/backup/dir1
/var/lib/backup/dir2

You need to backup your files under dir1, remove it, and then create a link:

ln -s /mnt/mydisk/dir1 /var/lib/backup/dir1

I am assuming you mounted the new partition under /mnt/mydisk and created dir1.

When writing to dir1, you are now writing to the new partition. When writing to dir2, you are still writing to the old partition.

Khaled
  • 36,533
  • 8
  • 72
  • 99