Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Device vs Partition vs File System vs Volume: how do these concepts relate to each other, accurately

How do these concepts relate to each other, from a Java developer standpoint?

My question: Could someone provide explanations or some links for simple and accurate / generally accepted definitions? Tks.

for reference, documents I found but are not clear to me:

http://arxiv.org/ftp/cs/papers/0508/0508063.pdf http://arxiv.org/ftp/cs/papers/0508/0508063.pdf

Not very lucky on Google.

My initial assumptions:

  • In the beginning is the physical device, and its driver.
  • A partition is a view of a portion of the device provided by the driver, not related to file system concept
  • A volume is the name given to a set of partitions organized in some way (RAID for instance)
  • A file system goes on top of a volume to store data in file units.
  • A file system provides usually a tree view of the volume
  • A file system tree may silently include other file system trees using file system Junction / Link features
like image 825
mins Avatar asked Jun 26 '14 11:06

mins


Video Answer


1 Answers

Let's start with some basics:

  • Data: Data is just a set of bits in order. The interpretation of the contents depend on the application which you use to read the data. Example1: You try it with an text editor, then this application may bundle 8bits and interpret them as ASCII characters. Example2: You try to open the file with an audio player, then it will for example try to put 12 bits together to get one amplitude in the played audio.

  • Storage Device: A device is a physical storage where you can store data. These are often accessible in a 'Random Access' fashion, e.g. get bit number 1337 -> 1 (simplified). Examples for these devices are: hard disk drives, solid state disks, usb sticks, CDs, DVD, but also Memory of your computer.

These two things are all you need: 1. A device to store/read the data 2. Rules on how to handle the data

Example: Let's say you would copy a binary to the beginning of your hdd and tell your computer to boot from this hdd. The computer will read the first command and execute it, and then read the next command and so on. This is what a bootloader does. At this early stage there are no filesystems, partitions, etc. involved.

At the beginning of software development you didn't 'open a File', you 'read bytes 100 to 180' and work with this data (maybe the 80 bytes are a string or audio data). Working with numbers got annoying (Where does my string start? Was it 40? How long was it again? Which string is this?), so Filesystems where invented:

  • Filesystem: A Filesystem is just a Layer in order to get some meaning to the bytes. A file in the filesystem is just the information where data starts, how long it is, and a simpler way to address it ('diary.txt' is easier to handle than '4000 Bytes beginning at Byte 500'). Paths and the tree view is just a thing to make it more convenient to find and organize files.

    So basically the Filesystem uses data and interprets it as a filesystem. Furthermore it allows the user (or other applications) to access chunks of this data in an easy way. The filesystem does not care where the data is stored, it may come from any device. You can also create a

    Example: Filesystem gets data ([---Data---]), handles it, and allows to access chunks ([D]) of the data.

    [---Data---] -> Filesystem -> [D][D][D][D]

    Since a file is just data received from a filesystem, you can install a filesystem in a file. No problem:

    `HDD ---> Filesystem ---> File ---> Filesystem ---> File

These are the main concepts in my opinion. You talked about some other things like partitions, (logical) volumes, volume groups, (encryption) container, etc. Don't get confused by these things, these are just other layers in order to organize data. On a closer look you will see that these are basically filesystems. Let's take partitions: A partition contains the information where in the underlying data it starts, how long it is, and a way to address it (e.g. partition number 2). Sounds familiar?

So, what is the Java Developer view on this? Most of the time you will be accessing data through File. Although it may be total reasonable to write/read to the hdd directly. I think the best approach is: Use the data source which fits your application best:

Example:

  • organized data? -> Database
  • text? -> File
  • partition organizing tool -> Read directly from the device, e.g. /dev/sd0

Hope that helps to clarify some things.

like image 142
Absurd-Mind Avatar answered Oct 23 '22 13:10

Absurd-Mind