-2

I backup my files to an external hard drive using the command: sudo dd if=dev/mmcblk0p2 of=dev/sda2

After creating the file, I want to append a time stamp to every backup.

If I mount sda2 to a directory on the main micro sd card file system (using a 32 GB micro sd drive) will each file take up the full space of the current file system?

If so, can I directly access the backup file on the external drive,append the time stamp without taking up space on the micro sd card file system, but store it on the external drive?

1
  • 1
    I changed your title because "I want to access files on /dev/sda 2 directly without mounting the drive" is an XY problem which tends to attract negative attention ;) whereas the rest of your question is clear and reasonable.
    – goldilocks
    Aug 18 '21 at 22:57
2

If I mount sda2 to a directory on the main micro sd card file system [...] will each file take up the full space of the current file system?

No; *nix derived operating systems (such as GNU/Linux, the umbrella under which RpiOS/Raspian falls) organize mounted filesystems in a hierarchical tree structure with a singular root -- hence what you've referred to as "the main micro sd card file system" is usually just called "the root filesystem". The term root here is unrelated to the superuser root.

This is possibly confusing to users coming from Microsoft Windows, where filesystems are conflated with the devices on which they are stored. This is why full Windows file paths start with a drive letter (C: etc) whereas on linux a full path always begins with the root, /.

Point being, presuming the fundamental root filesystem was mounted from /dev/whatever, when you do this:

mount /dev/foo2 /home/bar

The OS does not copy the filesystem from /dev/foo2 onto /dev/whatever. In fact, if there are already files in /home/bar, those remain untouched storage wise, but they become inaccessible until the /dev/foo2 mount is removed. This means you can't accidentally loose things by making a mistake with a mount point, but OTOH it is a possible source of confusion if for example on a Pi the boot partition is unmounted, and an update puts stuff in /boot -- because the first partition of the SD isn't mounted, it gets put in the /boot directory on the second partition and will never be used when booting.

Make sure you understand that last part WRT your backups. If you are using a mount point directory that doesn't contain anything when nothing is mounted there, be careful you don't back stuff up to it when nothing is there because not only will that end up on the SD card: It's also separate from the real contents of the backup device and so prone to end up hidden when you do properly mount the device.

That screw-up is actually hard to make once you understand the point. As a further note/hint: Don't assume everything in the root filesystem is an actual lump of data stored on the SD card, or any storage device. It is possible to mount other filesystems over a network, and commonly file paths are used as intefaces to the kernel (eg., nothing in /sys or /proc is actually stored on a disk, these are virtual files, hence usually reported with a size of zero even though when you read them there may be lots there).

2
  • 1
    Thank you!! I now understand that a mount point, if done correctly, is only a “pointer” to the external device and takes up virtually no room on the micro Ed card. Aug 19 '21 at 23:16
  • If you are satisfied with the answer, please indicate this by ticking the big checkmark on the left of it.
    – goldilocks
    Aug 20 '21 at 13:54

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.