I feel like an idiot realizing block devices are just… block devices.
They just hold data.
Shocker, I know.
But it just hit me when playing around with LVM. I can create a PV directly on a disk. I can even directly format a disk with FS. Floppies don’t tend to have a partition table either. On the other hand, I can partition a partition. I can also just write a Tar directly to disk, like with tape. Or any file.

But with multiple files it starts to become a problem. A-ha! I can just write files to partitions just the same to make reading them simpler.
In this case:

Device      Start    End  Size Name
/dev/sda1    2048  70704 33.5M Limahl - Never Ending Story
/dev/sda2   71680 127492 27.3M Alphaville - Big in Japan
/dev/sda3  129024 201967 35.6M Alphaville - Sounds Like a Melody
/dev/sda4  202752 259447 27.7M Bronski Beat - Junk
/dev/sda5  260096 324229 31.3M Chris De Burgh - High On Emotion
/dev/sda6  325632 386300 29.6M Jermaine Jackson - When the Rain Beg
/dev/sda7  387072 437492 24.6M Kylie Minogue - The Loco-Motion
/dev/sda8  438272 493179 26.8M Mauro - Buona Sera Ciao Ciao
/dev/sda9  493568 545532 25.4M Olivia Newton-John - Xanadu
/dev/sda10 546816 613761 32.7M Radiorama - Yeti

I don’t know if it’s the limitation of GPT, but fdisk let’s me theoretically get up to 232 partitions (default is 27). In practice, this will be lower.
For example:

Expert command (m for help): l
New maximum entries (1-4294967295, default 134217728): 268435456
Not enough space for new partition table!

Expert command (m for help): p

Disk /dev/sda: 57.3 GiB, 61524148224 bytes, 120164352 sectors

Right now I just did it manually. Check file size, divide by sector size, add one if remainder, make partition of that number of sectors, name partition, write partition table, copy file with dd and repeat.

But I should try to automate this. It could be a bash script, but I want to learn C beyond basics, so I guess I should try writing it in that.
Take destination drive and files as arguments, then do what I wrote above. And try not to nuke the wrong disk in the process.
On the other hand, I am so lazy I can’t typically even start with my hobbies. Which sucks because I want to, I just can’t… start.

Anyway, hundreds of files and partitions can’t be processed by hand any easier.

  • RheumatoidArthritis@mander.xyz
    link
    fedilink
    arrow-up
    6
    ·
    edit-2
    4 hours ago

    Well it’s a program that turns a huge array of bytes into a directory tree by allocating some of these bytes for data structures holding directory structure, metadata etc. The simplest to understand example would be FAT16 or floppy formats from 80s home computers. These had a lot of shortcomings, which were solved by more and more complex data structures.

    You can write a Python script that reads /dev/sda byte by byte and displays the directory tree. That would be a simple file system driver.

      • BartyDeCanter@piefed.social
        link
        fedilink
        English
        arrow-up
        1
        ·
        2 hours ago

        The closest production system to that I’ve seen is IBM i libraries, or maybe the failed WinFS.

        The problem is that without namespacing, how do you tell one README from another? And once you have a unique namespacing system, you’re basically back to a tree with extra steps. Sure, from the FS POV, you could keep everything in a flat space with uniqueness determined by inode or a UUID but those aren’t very human friendly.

        • MonkderVierte@lemmy.zip
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          34 minutes ago

          Grouping? Which is directories, except not in a fixed place.

          Ok, maybe then we’ll get sub-groups or nested groups and then we’re back to fixed paths again.

          I just thought of grouped tags as a nice (partial) way around link rot in servers. A tree breaks a lot with a changed name inbetween, while file-bound attributes are more robust.
          Also, the Unix tooling still crawling trees just doesn’t align well with modern computer/phone use and disk sizes. And makes features like hardlinks and xattributes mostly useless. Doesn’t help that you can’t just parse the tree yourself either. Honestly, it’s all just glued together clusterfuck.

      • RheumatoidArthritis@mander.xyz
        link
        fedilink
        arrow-up
        1
        ·
        3 hours ago

        I think this all has been tried and didn’t get traction. Although it has been before everyone had devices that hide the filesystem from you.