Thursday, February 13, 2025

How to Organize the Partitions in Linux?

How to Organize the Partitions in Linux?

I am a genuine Critic of Linux and a Long Time User.

If  you visit this web site and peruse pieces on Linux I had been critical of LiLo booting to GRUB booting to Daemon to Chron jobs.

I never fiddle with system files and root partition.

I am an adult teacher and  freelance writer.

First warning.

Do not expect the Internet to teach YOU Linux basics

It is a junk yard, with guys frustrated probably with their girl friends vent their anger on Linux. We are seasoned guys and can take any adverse comment but those guys should dig into basics. 

Better still read a book for reliable information.

Take the Linux Bible and read the relevant chapter. 

One need not read the entire book. 

But, I have read more than 70% of it over 30 years. 

I have the latest copy on the right hand side of the table

If I miss a point I revise myself and revisit the problem.

That has saved me.

I did not have to do it today.

Linux developers are very smart guys, they have documented everything, in a large Help file or manpage and I have never visited it or reviewed options available.

These developers are busy guys and they are not your teachers

They discuss their problems with their cohort or fellow developers. 

If you have a problem file a bug report. 

I have never filed a bug report but post a piece here, if I have a problem, believing one of them would read them in his or her own leisure time.

Linux has taken tremendous strides over the last 30 years

It is viable and robust

To test my gut feeling and I posted the following question in the Web.

How to Organize the Partitions in Linux?

I saw a few amateurish attempts.

This is why, I decided to write a book on Linux in spite having a big Linux Bible.

Unlike me, a medical guy who have read Harrison's Medicine and Russel L. Cecil (1881-1965) and Robert F. Loeb (1895-1973)  (W.B.Saunders) books on Medicine (never Oxford) reading Linux Bible with very specific instructions was chicken feed, as it were.

My book has gone over 400 pages. 

I will post here a section from that book on partitions.

Traditionally, Linux has a hierarchical file structure

Even though, Linux distribution can remain in one partition apart from the Efi partition theoretically, it prefers to organize the files in strict and orderly manner.

Ubuntu does it in one partition.

Endless OS has similar approach.

The simple order is Efi partition and /root partition.

The rest of the partitions sit under the /root partition in a parent and child relationship

That is it.

One my understand that there is a 1MB FAT portion above the EFI, probably dedicated to Microsoft Windows to snooze upon your system. Today I noticed it had Free BSD name on it. I tried to install BSD a couple of days ago but it hung up with a name tag. 

I name it again with my name if any guy or girl want to snooze.

/root

/boot

/home

/tmp

/var

/usr

/srv

/usr/local

/opt

With efi and SWAP there are eleven partitions (11) in total.

I have a SATA 320GB hard disk and therefore, I have limitations. 

I use to drop /var partition (the variable partition), since it gets loaded up with variable files in no time which eventually fill the partition up that cannot be cleaned up. I invariably gets a message saying, there is no space in the hard disk, meaning that the /var partition is saturated. When this happens, the system actually freezes and I cannot install additional software. 

The package manager has no idea what space is left in the hard disk and try to install ad hoc manner. 

What I usually do is, open the Disk Usage Analysis Tool of the Utilities Bundle and keep it opened while installing applications. When it indicates in graphic form, only 2GB space is available, I stop installing additional packages.

The Stacer utility in graphic mode is a better option

It may say, only 1.8GB is available. 

That is the bottom line and I do not install anymore software even for testing. 

Mind you, I have DBS Database in my LibreOffice Suite and it needs some space for additional Databases.

Moving to a different topic, there are different Installers and MX Linux has it own Installer which is very restrictive with only 3 partitions namely /root /boot and /home. 

Suse and Redhat have their own installers.

It is said Linux is either a File or a Directory.

In that sense, a summary of the file hierarchy in Linux is mandatory for a guy or girl using command line work.

It goes on like this.

/bin – Binaries

The /bin directly contains the executable files of many basic shell commands like ls, cp, cd etc. Mostly the programs are in binary format here and accessible by all the users in the Linux system.

/dev – Device files

This directory only contains special files, including those relating to the devices. They are virtual files, and they do not physically present on the disk.

/etc – Configuration files

The /etc directory contains the core configuration files of the system, use primarily by the administrator. The services, such as the password file and networking files occupy /etc.

If one needs to make changes in system configuration (for example, changing the host name), the etc folder is where one finds the respective files.

/usr – User binaries and program data

In /usr all the executable files, libraries, source of most of the system programs reside. For this reason, most of the files contained therein are read ­only for the normal user.

My advice is one should not allocate a partition for /usr.  It gets filled up in no time, if separate partition is allocated and the system would freeze when this happens. 

I tried various combination of partitions to test them and I have had very nasty experiences.

Let the/usr remain under /root directory and the /root automatically decides how to allocate resources to each directory with seamless efficiency.

/usr/bin contains basic user commands

/usr/sbin contains additional commands for the administrator

/usr/lib contains the system libraries

/usr/share contains documentation or common libraries, for example /usr/share/man contains the text of the manpage

/home – User personal data

Home directory contains personal directories for the users.

The home directory contains the user data and user specific configuration files. When root user allows one to create a user on a Linux system, it creates a home directory for the user with a specific name. Suppose the Root allows Linux system to have two users named Tom and Jury. There are two home directories as /home/tom and /home/jury. Do note that capital letters are not allowed for user names and additionally, Tom is not allowed to access  /home/jury and vice versa. That makes sense, since only the user should have access to his or her /home directory. 

However Root has access to all the files.

/lib – Shared libraries

Libraries are basically codes that can be used by the executable binaries. The /lib directory holds the libraries needed by the binaries in /bin and /sbin directories.

Libraries needed by the binaries in the /usr/bin and /usr/sbin are located in the directory /usr/lib.

/sbin – System binaries

This is similar to the /bin directory. The only difference is that it contains the binaries that can only be run by root or sudo.

One can assume that the ‘s’ in ‘sbin’ as super or sudo.

/tmp – Temporary files

As the name suggests, this directory holds temporary files. Many applications use this directory to store temporary files. But do note that the contents of the /tmp directories are deleted when the system reboots.

/var – Variable data files

Var, short for variable, is where programs store runtime information like system logging, user tracking, caches and other files that system programs create and manage. The files stored here are not cleaned automatically and hence it provides a good place for system administrators to look for information about their system behaviour. For example, if the Root wants to check the login history in the Linux system, this is where he checks, the content of the file in /var/log/wtmp.

I tend to give a big partition for /var since it is not cleaned up automatically and builds up with junk

The system gives a warning when /var gets filled up and I quickly delete unnecessary applications when that happens. I never try to fiddle with /root directory since, if a single file configuration is corrupted, the /root refuses to boot.

/boot – Boot files

The ‘/boot’ directory contains the files of the kernel and boot image, in addition to LILO and GRUB. It is often advisable that the directory resides in a partition at the beginning of the disc but in Debian, the /root has first priority and /boot /home and /tmp follow afterwards.

/proc – Process and kernel files

The /proc directory contains the information about currently running processes and kernel parameters. The content of the /proc directory is used by number of tools to get runtime system information. For example, if one want to check processor information in Linux, one can simply refer to the file            /proc/cpuinfo. To check memory usage of the Linux system one looks at the content of /proc/meminfo file.

The application, Stacer described in this book is a good utility to check the file system without disrupting the configuration of the system.

/opt – Optional software

Traditionally, the /opt directory is used for installing/storing the files of third party applications that are not available from the repository of the distribution. 

I tend to create a partition for /opt of sufficient size.

The normal practice is to keep the software code in opt and then link the binary file in the /bin directory so that all the users can run it.

/root – The home directory of the root

This is /root directory as well as the home directory of the root. Instead of /home/root, the home of root is located at /root.

Do not confuse it with the root directory (/).

/media – Mount point for removable media

When a user connect a removable media such as USB disk, SD card or DVD, a directory is automatically created under the /media directory for the user.

/mnt – Mount directory

This is similar to the /media directory but instead of automatically mounting the removable media /mnt is used by system administrators to manually mount the file system.

/srv – Service data

The /srv directory contains data for services provided by the system. For example, if one runs a HTTP server, the website data is stored in the /srv directory.

I think ordinary user should not worry about the file architecture of the system in detail but s/he should worry only about the /home directory where he or she   is allowed to use and function at lib.

The root user can limit the resources of this directory, if one fills it up with junk

It is the responsibility of user to maintain it in pristine form,

Partition Order for a Desktop Linux

I have had many second thoughts about the partition order. I do not think it matters a lot.

I presume the following order may be useful.

EFI about 528MB

/root

/boot (optional and may be redundant)

/home

/tmp

/usr    (the user file location assuming more than one user is using the computer)

/srv  services

/var

I have some reservation about /var partition, since it get used up when more and more applications are added. Then one gets the warning that not enough space is available in the hard disk.

SWAP is mandatory and I have several.

One should not forget SWAP Partition and I have one Swap Partition after every distribution, usually three in number. I sometimes delete (I have two more in reserve) the last Swap partition stationed as the last partition in the Partition Table and install, the latest distribution that I wish to test, to see how much hardware memory in GB the distribution needs.

Generally speaking, 10GB is the minimum for a light weight distribution but 30 to 40 is optimal but  I use at least 100GB for each distribution which includes a relatively large /home partition.

I hate Virtual Installations, even though, I have the BOX utility in my system. Only after full install one gets the real feel of the distribution one is using.

There is a small caveat here.

If one is using a spinning hard disk the order matters and the scanning needle has to spin a lot, if the order EFI, /root, /boot /home /tmp etc are not in  sequential order. In that scenario for effective booting EFI has to be the first. In  Solid State Disks (SSD), it does not matter unless one installs  many Linux distributions, in one disk.

By the way, I have reserved 50GB for a NTFS partition to store Iso images which I  Test and Delete, as I wish.

 

I have still have not made up the best three distributions one would like to use.

Gnome of Debian comes first.

The KDE Netrunner is pretty good.

Ubuntu I have disposed of due to many reasons.

May be Manjaro comes third.

Peppermint failed on my last testing.

Latest EndeavourOS  is pretty good

 

After many a tests I settled downed with MX Linux KDE.

Yesterday, I installed Netrunner KDE with 6.1 kernel. It is OK with a beautiful boot menu at the start but it is very slow to boot compared to Debian Gnome. 

Debian keep an eagle eye and it tells me it has some updates.

It took seven mutes for updates are done offline. The files are downloaded in the background as a demon when I am online. I have over 20 window managers to choose from Awesome to Cinnamon to Fluxbox, IceWarm (beautiful) many versions of Gnome to KDE, to MATE to XFCE, that is why it took 7 minutes. Otherwise few minuted would be enough.

 

No comments:

Post a Comment