0

I am using my raspberry pi 4 with raspbian to host server. I have written some code that makes backups of the server data and I upload these to google drive using rclone. The problem is that I only have the 15 gb free plan on Google drive. I would want to limit the size of the local directory which I sync to Google drive to 15 gb. Is there a way to do this in Linux?

EDIT: I have understood that I am supposed to use Quota to do this. However Quota seems to be based on different users. At the moment I only have the standard user pi, is there a way to just limit the size of a certain backup directory with just the pi user.

1
  • What is the size of your storage (SD Card)? Is it workable to reduce it? – Ingo Jan 31 at 19:45
0

Not sure how fast it would be but creating an .img file of 15GB and using it as mounted as storage will do exactly what you want.You can do all the normal things with it like create partitions format them if wanted.

root@zeus-H370M-DS3H:/home/zeus/qemu_vms# fdisk -l ubuntu-20.10-preinstalled-desktop-arm64+raspi.img 
Disk ubuntu-20.10-preinstalled-desktop-arm64+raspi.img: 8.15 GiB, 8750736384 bytes, 17091282 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xb6b5c3c7

Device                                             Boot  Start      End  Sectors  Size Id Type
ubuntu-20.10-preinstalled-desktop-arm64+raspi.img1 *      2048   526335   524288  256M  c W95 FAT32 
ubuntu-20.10-preinstalled-desktop-arm64+raspi.img2      526336 17091247 16564912  7.9G 83 Linux
root@zeus-H370M-DS3H:/home/zeus/qemu_vms# losetup -P /dev/loop0 ubuntu-20.10-preinstalled-desktop-arm64+raspi.img 
root@zeus-H370M-DS3H:/home/zeus/qemu_vms# mkdir /tmp/imgboot
root@zeus-H370M-DS3H:/home/zeus/qemu_vms# mkdir /tmp/imgroot
root@zeus-H370M-DS3H:/home/zeus/qemu_vms# mount /dev/loop0p2 /tmp/imgroot
root@zeus-H370M-DS3H:/home/zeus/qemu_vms# mount /dev/loop0p1 /tmp/imgboot
root@zeus-H370M-DS3H:/home/zeus/qemu_vms# ll /tmp/imgboot/
total 68870
-rwxr-xr-x 1 root root    26530 Oct 22 11:21 bcm2710-rpi-2-b.dtb
-rwxr-xr-x 1 root root    28028 Oct 22 11:21 bcm2710-rpi-3-b.dtb
snip.....
-rwxr-xr-x 1 root root 24222208 Oct 22 11:21 vmlinuz

root@zeus-H370M-DS3H:/home/zeus/qemu_vms# ll /tmp/imgroot/
total 1048660
lrwxrwxrwx   1 root root          7 Oct 22 11:00 bin -> usr/bin
drwxr-xr-x   4 root root       4096 Oct 22 11:12 boot
root@zeus-H370M-DS3H:/home/zeus/qemu_vms# rm -r /tmp/imgroot/*
root@zeus-H370M-DS3H:/home/zeus/qemu_vms# ll /tmp/imgroot/
total 0

You can do pretty much anything you want with them, how fast it would be as I say no clue.

4
  • What does the code block show? What does it mean? – Ingo Feb 7 at 19:47
  • It shows how to mount an image file and manipulate its contents once it is mounted. This is a method for the OP to make an exact sized storage place for his needs, the speed of doing it I have no idea as I have not used such a device for my needs only know it is possible. – user130167 Feb 7 at 20:51
  • You should better explain it in the answer, not in a comment. – Ingo Feb 7 at 22:53
  • Like I know about that, one thing you do here tells you one way to do the other tells another, edit it if it offends you. I answer the question, your the one with the nitpick. BTW the code block was self explanatory showing how to do it as I said. If you have better answer put it up. – user130167 Feb 7 at 23:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy