Divided into 2 parts, in the first part I introduced the concept that everything is a file and I introduced special devices/dev/ null, / dev / zero, / dev / random and / dev / full. In this part 2, I will present interesting didactic features about this, for example, how to transform a file into a partition! Reading this post requires prior knowledge of Part 1!
You are a scholar who has the following knowledge:
1. Create a 4Gb file filled with zeros using the DD command.
It will be created in / home / $ USER; change this path if you do not have enough disk space.
$ dd if = / dev / zero of = ~ / test bs = 1M count = 4096
2. Now let's format this file. Yes, and more, it will have the EXT4 format in our example!
A little confused? Trust me, buddy. Come on:
$ mkfs.ext4 -m .005 ~ / test
The -m flag in the command causes us to decrease the "root" space that the EXT4 sets to 05 by default. This is even useful for installing a system and preventing EXT4 from consuming a lot of disk space by default.
3. Formatted? Okay, now you have a 4GB file of type "unknown" called "test" in your / home, and nothing else opens it. Sit in a chair (if you're not already in one) and note that now comes the best part:
Mount it as a partition!
$ sudo mkdir / media / test
$ sudo mount -rw ~ / test / media / test /
Hey buddy congratulations, you not only created a file in .EXT4 format, you created an EXT4 PARTY inside a common file in your / home and you can still store things inside it!
The same procedure can be done for any file format: EXT2, FAT32, NTFS etc. Everything only depends on your need!
But do not think you can install Windows on it, as it is a partition inside a partition, who manages it under EXT4 (or btrfs, or xfs depending on your system). It's also tricky to mount it as a partition on a Windows since the system does not operate as UNIX-based devices reading block devices as files, but treating them differently. You can even force your assembly with the -F flag but only UNIX-based systems will recognize it and mount it.
This detail has been made explicit here.
As I explained in Part 1, "everything is a file":
That is, a folder, a directory, a partition (that is, things that store things) are nothing more than "index files" that define what's in it sector of your disk or SSD. When they say that UNIX-based systems have a philosophy of simplicity, it's this simplicity we're talking about: Everything is just a file, palpable, simple and functional, easily manipulated, bluntly.
The biggest lesson here is that you just learn how basic way Virtualization of an operating system (VirtualBox): You create a partition in a file (in VirtualBox it is in .vdi format) and within you install your system.
Some file systems such as JFS operate by allowing for better organization of data if they are small (text documents) and in other cases like XFS if they are large files (disk images, HD photos, .flac songs). Having a virtual partition with one of these formats can optimize the disk space consumed.
$ sudo umount / media / test
After that, you can play this file-partition in the trash.
In this second and last part of the session "Did You Know? Everything is File "I have said about the virtual partitioning of files to be used as disk partitions and some advantages of these. Along with the earlier part, where I board on special devices, there is knowledge that can be added to any Linux student (or other UNIX-based systems), improving their understanding of how a system works.
Most Read Articles
Translate Our Site
Notice : Please be careful, after translation commands will change.
This website uses marketing and tracking technologies. Opting out of this will opt you out of all cookies, except for those needed to run the website. Note that some products may not work as well without tracking cookies.Opt Out of Cookies