cancel
Showing results for 
Search instead for 
Did you mean: 
Chetan_Tiwary_
Community Manager
Community Manager
  • 197 Views

Red Hat Linux Interview Series 31

Q.) What is the difference between systemctl disable and systemctl mask?

 

Q.) Why would you prefer rsync over scp to transfer a batch of files ?

 

Q.) Differentiate between ramfs, rootfs and tmpfs

 

Bonus Q.) Why do we need initramfs during boot process ?

 

 

Level L2 and above

 

I'll be posting a series of Linux-related questions covering various skill levels. Feel free to share your insights and expertise. Your contributions will benefit learners at all stages, from those in current roles to those preparing for Linux interviews.

 

4 Replies
Trevor
Starfighter Starfighter
Starfighter
  • 118 Views

I'll start with the Bonus question, and work my way back to the 
first one.

Bonus Q.) Why do we need initramfs during boot process ?

Answer:

An initramfs is needed during the Linux boot process to:
1) be mounted as the initial root filesystem, and
2) to load kernel modules

An Initramfs is used as the first root filesystem that a Linux system has access to.

The initramfs filesystem is used for mounting the real root filesystem - which has all the data.

The initramfs filesystem carries the modules needed for mounting the real root filesystem on a Linux system.

The initramfs filesystem contains the tools needed to mount file systems before the init (systemd) binary on the real root file system is called.


An initramfs may be needed if:
1) A root filesystem is to be loaded from a network, or
2) A root filesystem is to be loaded from an LVM logical volume, or
3) An encrypted root filesystem is to be loaded, where a password is required

 

 

Trevor "Red Hat Evangelist" Chandler
Trevor
Starfighter Starfighter
Starfighter
  • 92 Views

Q.) Why would you prefer rsync over scp to transfer a batch of files ?

Answer:

rsync not only transfers files, but it synchronizes files between the source
and destination. Unlike scp, rsync only transfers the differences between
the source and the destination, making it highly efficient, especially for
large datasets (i.e. a batch of files). The more files involved in the transfer,
and the smaller the difference in the content of the source and destination
files, the more favorable the use of rsync over scp!

rsync enhances replication speed through differential change detection
at the file level. What that means is, rsync uses a differential sync engine
to replicate only changed files (or changed portions of files). This is what
gives rsync the advantage over scp, when it comes to the transfer of a
batch of files. 

Any files that already exist at the destination, that have not changed, are
skipped by rsync - this is not the case with scp. scp transfers the entire file
every time, regardless of whether it has changed!

 

Trevor "Red Hat Evangelist" Chandler
0 Kudos
Trevor
Starfighter Starfighter
Starfighter
  • 88 Views

Q.) Differentiate between ramfs, rootfs and tmpfs

Answer:

ramfs:
- ramfs is a fileystem
- ramfs exports Linux's disk caching mechanisms (the page cache and dentry cache) as a dynamically resizable ram-based filesystem. Normally all files are cached in memory by Linux.
- ramfs does not use swap
- you cannot modify any parameter for a ramfs filesystem.
- The size limit of a ramfs filesystem is based on how much memory is available on the Linux system
- ramfs will grow dynamically.
- ramfs does not use swap
- With ramfs, basically a disk cache is being mounted as a filesystem.
- With ramfs, there is no backing store.

Note: A backing store refers to a storage device. A "backing storage device" refers to a device used to store data long-term, essentially acting
as a secondary storage option for a computer, like a hard disk drive (HDD)
or solid-state drive (SSD), which retains data even when the power is
turned off, unlike RAM (primary memory) that loses data when power is cut
off; it's essentially where your computer keeps files and programs for
long-term access.


tmpfs:

- tmpfs is a ramfs derivative.
- tmpfs was created to add size limits, and the ability to write the data to swap space.
- tmpfs is a temporary file system (TMPFS)
- tmpfs uses local memory for file system reads and writes, which is typically much faster than reads and writes in a UFS file system.
- tmpfs file systems can improve system performance -by saving the cost of reading and writing temporary files to a local disk or across the network.
- tmpfs isn't a pseudo file system - it's a real file system
- tmpfs stores its contents in virtual memory.
- The difference is that pseudo file systems offer a representation of something else, whereas real file systems store artefacts directly.
- If you oversize your tmpfs instances the machine will deadlock since the OOM handler will not be able to free that memory.
- tmpfs is a file system which keeps all of its files in virtual memory.
- Everything in tmpfs is temporary in the sense that no files will be created on your hard drive.
- If a tmpfs instance is unmounted, everything stored therein is lost.
- tmpfs puts everything into the kernel internal caches and grows and shrinks to accommodate the files it contains, and is able to swap unneeded pages out to swap space, if swap was enabled for the tmpfs mount.
- tmpfs extends ramfs with a few userspace configurable options listed and
explained further below, some of which can be reconfigured dynamically on the fly
using a remount (‘mount -o remount ...’) of the filesystem.
- A tmpfs filesystem can be resized but it cannot be resized to a size below its current usage.
- tmpfs also supports POSIX ACLs
- tmpfs supports extended attributes for the trusted.*, security.* and user.*
namespaces.
- tmpfs lives completely in the page cache and optionally on swap
- all tmpfs pages will be shown as “Shmem” in /proc/meminfo and
“Shared” in the output of the free command.
- tmpfs will not grow dynamically.
- tmpfs would not allow more to be written than the size that was specified
when mounting the tmpfs. It may give errors similar to “No space left on device”.
- tmpfs supports THP.
- tmpfs uses swap.

Note: Transparent Hugepage Support (THP) is a feature in the Linux
kernel, that allows users, to force or deny huge pages, on all tmpfs mounts.
NoteUnix File System (UFS) refers to a family of file systems commonly used in Unix-like operating systems


rootfs:

- rootfs is a special instance of ramfs (or tmpfs, if that's enabled).
- If CONFIG_TMPFS is enabled, rootfs will use tmpfs instead of ramfs by default. 
- To force the use of ramfs, add "rootfstype=ramfs" to the kernel command line at bootup.
- rootfs is used as a placeholder inside the Linux kernel.
- rootfs is a special kind of RAM-based filesystem that the kernel uses at the very beginning of the boot process.
- rootfs is the first filesystem the kernel has access to.

Note: CONFIG_TMPFS is a file system - that stores files in virtual memory.

 

Trevor "Red Hat Evangelist" Chandler
Trevor
Starfighter Starfighter
Starfighter
  • 77 Views

Q.) What is the difference between systemctl disable and systemctl mask?

Answer:


Adding a mask to a service creates a symlink from /etc/systemd/system to /dev/null.  What this does it to prevent a service unit from starting!
The service is prevented from starting during bootup, or even a manual
start (i.e. $ systemctl start service_name.service       # this will not start the service).

If a service is enabled ( $ systemctl enable service_name.service), a
symlink is created (in one of the ".wants" directories; this depends on what's configured in the service unit file). The creation of this symlink
configures the service unit to start during bootup.

To configure the Linux system, so that a service unit that is enabled,
will not start during bootup, simply execute the following command:

                     # systemctl disable service_name.service
- this removes the symlink that was created when the service was
enabled to start during bootup.

 

Summary:

systemctl  mask  service_name.service
-  creates a symlink

systemctl  disable  sevice_name.service
-  removes a symlink; not the symlink created by masking

 

A healthy understanding of systemd, and its management tool
(systemctl), will help with digesting the difference between the
systemctl sub-commands - mask  and  disable.

 

Trevor "Red Hat Evangelist" Chandler
Join the discussion
You must log in to join this conversation.