SUMMARY OF LESS COMMANDS

Less command is linux utility which can be used to read contents of text file one page(one screen) per time. It has faster access because if file is large, it don’t access complete file, but access it page by page.

For example, if it’s a large file and you are reading it using any text editor, then the complete file will be loaded to main memory, but less command don’t load entire file, but load it part by part, which makes it faster.



      Commands marked with * may be preceded by a number, N.
      Notes in parentheses indicate the behavior if N is given.
      A key preceded by a caret indicates the Ctrl key; thus ^K is ctrl-K.

  h  H                 Display this help.
  q  :q  Q  :Q  ZZ     Exit.
 ---------------------------------------------------------------------------

                           MOVING

  e  ^E  j  ^N  CR  *  Forward  one line   (or N lines).
  y  ^Y  k  ^K  ^P  *  Backward one line   (or N lines).
  f  ^F  ^V  SPACE  *  Forward  one window (or N lines).
  b  ^B  ESC-v      *  Backward one window (or N lines).
  z                 *  Forward  one window (and set window to N).
  w                 *  Backward one window (and set window to N).
  ESC-SPACE         *  Forward  one window, but don't stop at end-of-file.
  d  ^D             *  Forward  one half-window (and set half-window to N).
  u  ^U             *  Backward one half-window (and set half-window to N).
  ESC-)  RightArrow *  Right one half screen width (or N positions).
  ESC-(  LeftArrow  *  Left  one half screen width (or N positions).
  ESC-}  ^RightArrow   Right to last column displayed.
  ESC-{  ^LeftArrow    Left  to first column.
  F                    Forward forever; like "tail -f".
  ESC-F                Like F but stop when search pattern is found.
  r  ^R  ^L            Repaint screen.
  R                    Repaint screen, discarding buffered input.
        ---------------------------------------------------
        Default "window" is the screen height.
        Default "half-window" is half of the screen height.
 ---------------------------------------------------------------------------

                          SEARCHING

  /pattern          *  Search forward for (N-th) matching line.
  ?pattern          *  Search backward for (N-th) matching line.
  n                 *  Repeat previous search (for N-th occurrence).
  N                 *  Repeat previous search in reverse direction.
  ESC-n             *  Repeat previous search, spanning files.
  ESC-N             *  Repeat previous search, reverse dir. & spanning files.
ESC-u                Undo (toggle) search highlighting.
  &pattern          *  Display only matching lines
        ---------------------------------------------------
        A search pattern may be preceded by one or more of:
        ^N or !  Search for NON-matching lines.
        ^E or *  Search multiple files (pass thru END OF FILE).
        ^F or @  Start search at FIRST file (for /) or last file (for ?).
        ^K       Highlight matches, but don't move (KEEP position).
        ^R       Don't use REGULAR EXPRESSIONS.
 ---------------------------------------------------------------------------

                           JUMPING

  g  <  ESC-<       *  Go to first line in file (or line N).
  G  >  ESC->       *  Go to last line in file (or line N).
  p  %              *  Go to beginning of file (or N percent into file).
  t                 *  Go to the (N-th) next tag.
  T                 *  Go to the (N-th) previous tag.
  {  (  [           *  Find close bracket } ) ].
  }  )  ]           *  Find open bracket { ( [.
  ESC-^F <c1> <c2>  *  Find close bracket <c2>.
  ESC-^B <c1> <c2>  *  Find open bracket <c1>
        ---------------------------------------------------
        Each "find close bracket" command goes forward to the close bracket
          matching the (N-th) open bracket in the top line.
        Each "find open bracket" command goes backward to the open bracket
          matching the (N-th) close bracket in the bottom line.

  m<letter>            Mark the current position with <letter>.
  '<letter>            Go to a previously marked position.
  ''                   Go to the previous position.
  ^X^X                 Same as '.
        ---------------------------------------------------
        A mark is any upper-case or lower-case letter.
        Certain marks are predefined:
             ^  means  beginning of the file
             $  means  end of the file
 ---------------------------------------------------------------------------

                        CHANGING FILES

  :e [file]            Examine a new file.
  ^X^V                 Same as :e.
  :n                *  Examine the (N-th) next file from the command line.
  :p                *  Examine the (N-th) previous file from the command line.
  :x                *  Examine the first (or N-th) file from the command line.
  :d                   Delete the current file from the command line list.
  =  ^G  :f            Print current file name.
 ---------------------------------------------------------------------------

                    MISCELLANEOUS COMMANDS

  -<flag>              Toggle a command line option [see OPTIONS below].
  --<name>             Toggle a command line option, by name.
  _<flag>              Display the setting of a command line option.
  __<name>             Display the setting of an option, by name.
  +cmd                 Execute the less cmd each time a new file is examined.

  !command             Execute the shell command with $SHELL.
  |Xcommand            Pipe file between current pos & mark X to shell command.
  s file               Save input to a file.
  v                    Edit the current file with $VISUAL or $EDITOR.
  V                    Print version number of "less".
 ---------------------------------------------------------------------------

                           OPTIONS

        Most options may be changed either on the command line,
        or from within less by using the - or -- command.
        Options may be given in one of two forms: either a single
        character preceded by a -, or a name preceded by --.

  -?  ........  --help
                  Display help (from command line).
  -a  ........  --search-skip-screen
                  Search skips current screen.
  -A  ........  --SEARCH-SKIP-SCREEN
                  Search starts just after target line.
  -b [N]  ....  --buffers=[N]
                  Number of buffers.
  -B  ........  --auto-buffers
                  Don't automatically allocate buffers for pipes.
  -c  ........  --clear-screen
                  Repaint by clearing rather than scrolling.
  -d  ........  --dumb
                  Dumb terminal.
 -D [xn.n]  .  --color=xn.n
                  Set screen colors. (MS-DOS only)
  -e  -E  ....  --quit-at-eof  --QUIT-AT-EOF
                  Quit at end of file.
  -f  ........  --force
                  Force open non-regular files.
  -F  ........  --quit-if-one-screen
                  Quit if entire file fits on first screen.
  -g  ........  --hilite-search
                  Highlight only last match for searches.
  -G  ........  --HILITE-SEARCH
                  Don't highlight any matches for searches.
  -h [N]  ....  --max-back-scroll=[N]
                  Backward scroll limit.
  -i  ........  --ignore-case
                  Ignore case in searches that do not contain uppercase.
  -I  ........  --IGNORE-CASE
                  Ignore case in all searches.
  -j [N]  ....  --jump-target=[N]
                  Screen position of target lines.
  -J  ........  --status-column
                  Display a status column at left edge of screen.
  -k [file]  .  --lesskey-file=[file]
                  Use a lesskey file.
  -K            --quit-on-intr
                  Exit less in response to ctrl-C.
  -L  ........  --no-lessopen
                  Ignore the LESSOPEN environment variable.
  -m  -M  ....  --long-prompt  --LONG-PROMPT
                  Set prompt style.
  -n  -N  ....  --line-numbers  --LINE-NUMBERS
                  Don't use line numbers.
  -o [file]  .  --log-file=[file]
                  Copy to log file (standard input only).
  -O [file]  .  --LOG-FILE=[file]
                  Copy to log file (unconditionally overwrite).
  -p [pattern]  --pattern=[pattern]
                  Start at pattern (from command line).
  -P [prompt]   --prompt=[prompt]
                  Define new prompt.
  -q  -Q  ....  --quiet  --QUIET  --silent --SILENT
                  Quiet the terminal bell.
  -r  -R  ....  --raw-control-chars  --RAW-CONTROL-CHARS
  Output "raw" control characters.
  -s  ........  --squeeze-blank-lines
                  Squeeze multiple blank lines.
  -S  ........  --chop-long-lines
                  Chop (truncate) long lines rather than wrapping.
  -t [tag]  ..  --tag=[tag]
                  Find a tag.
  -T [tagsfile] --tag-file=[tagsfile]
                  Use an alternate tags file.
  -u  -U  ....  --underline-special  --UNDERLINE-SPECIAL
                  Change handling of backspaces.
  -V  ........  --version
                  Display the version number of "less".
  -w  ........  --hilite-unread
                  Highlight first new line after forward-screen.
  -W  ........  --HILITE-UNREAD
                  Highlight first new line after any forward movement.
  -x [N[,...]]  --tabs=[N[,...]]
                  Set tab stops.
  -X  ........  --no-init
                  Don't use termcap init/deinit strings.
  -y [N]  ....  --max-forw-scroll=[N]
                  Forward scroll limit.
  -z [N]  ....  --window=[N]
                  Set size of window.
  -" [c[c]]  .  --quotes=[c[c]]
                  Set shell quote characters.
  -~  ........  --tilde
                  Don't display tildes after end of file.
  -# [N]  ....  --shift=[N]
                  Horizontal scroll amount (0 = one half screen width)
      ........  --no-keypad
                  Don't send termcap keypad init/deinit strings.
      ........  --follow-name
                  The F command changes files if the input file is renamed.
      ........  --use-backslash
                  Subsequent options use backslash as escape char.


 ---------------------------------------------------------------------------

                          LINE EDITING

 These keys can be used to edit text being entered
        on the "command line" at the bottom of the screen.

 RightArrow ..................... ESC-l ... Move cursor right one character.
 LeftArrow ...................... ESC-h ... Move cursor left one character.
 ctrl-RightArrow  ESC-RightArrow  ESC-w ... Move cursor right one word.
 ctrl-LeftArrow   ESC-LeftArrow   ESC-b ... Move cursor left one word.
 HOME ........................... ESC-0 ... Move cursor to start of line.
 END ............................ ESC-$ ... Move cursor to end of line.
 BACKSPACE ................................ Delete char to left of cursor.
 DELETE ......................... ESC-x ... Delete char under cursor.
 ctrl-BACKSPACE   ESC-BACKSPACE ........... Delete word to left of cursor.
 ctrl-DELETE .... ESC-DELETE .... ESC-X ... Delete word under cursor.
 ctrl-U ......... ESC (MS-DOS only) ....... Delete entire line.
 UpArrow ........................ ESC-k ... Retrieve previous command line.
 DownArrow ...................... ESC-j ... Retrieve next command line.
 TAB ...................................... Complete filename & cycle.
 SHIFT-TAB ...................... ESC-TAB   Complete filename & reverse cycle.
 ctrl-L ................................... Complete filename, list all.


Unix Less Command: Tips for Effective Navigation

The navigation keys in less command are similar to Vim editor. In this article, let us look at few less command navigation and other operations which will make you a better command line warrior.

1. Less Command – Search Navigation

Once you’ve opened a log file (or any file) using less file-name, use the following keys to search. Please note that the match will be highlighted automatically by default.

Forward Search

  • / – search for a pattern which will take you to the next occurrence.
  • n – for next match in forward
  • N – for previous match in backward

Backward Search

  • ? – search for a pattern which will take you to the previous occurrence.
  • n – for next match in backward direction
  • N – for previous match in forward direction

Tip: If you dont bother about which direction the search is happening, and you want to search file path, or URL, such as “/home/ramesh/”, you can use backward search (?pattern) which will be handy as you don’t want to escape slashes each time.

Search Path
In forward: /\/home\/aditya\/
In backward: ?/home/aditya/

2. Less Command – Screen Navigation

Use the following screen navigation commands while viewing large log files.

  • CTRL+F – forward one window
  • CTRL+B – backward one window
  • CTRL+D – forward half window
  • CTRL+U – backward half window

3. Less Command – Line navigation

In a smaller chunk of data, where you want to locate particular error, you may want to navigate line by line using these keys:

  • j – navigate forward by one line
  • k – navigate backward by one line

4. Less Command – Other Navigations

The following are other navigation operations that you can use inside the less pager.

  • G – go to the end of file
  • g – go to the start of file
  • q or ZZ – exit the less pager

5. Simulate tail -f inside less pager – Press F

Once you’ve opened a file using less command, any content that is appended to the file after that will not be displayed automatically. However, you can press F less command will show the status ‘waiting for data‘. This is as similar to ‘tail -f’.

6. Less Command – Count magic

Similar to Vim editor navigation command, you can give 10j to scroll 10 lines down, or 10k to go up by 10 lines.

  • 10j – 10 lines forward.
  • 10k – 10 lines backward.
  • CTRL+G – show the current file name along with line, byte and percentage statistics.

7. Other useful Less Command Operations

  • v – using the configured editor edit the current file.
  • h – summary of less commands
  • &pattern – display only the matching lines, not all.

8. Open any types of files using less command

less command can be used to open and view the following 10 different file types:

  1. PDF File – *.pdf
  2. Word Document- *.doc
  3. Image Files – *.gif, *.jpg, *.jpeg, *.png
  4. TAR Files – *.tar
  5. TAR Files with gzip – *.tar.gz
  6. Zip Files – *.zip
  7. Gzip and Gzip2 Files – *.gz and *.bz2
  8. ISO Files
  9. Debian Files – *.deb
  10. RPM Files – *.rpm

Set the LESSOPEN environment variable to lesspipe

First, make sure the following is set in the environment variable.

$ set | grep less
LESSOPEN='|/usr/bin/lesspipe.sh %s'

Please note that you can also do the following to setup the lesspipe.

$ eval "($lesspipe)"

$ cat ~/.bashrc
eval "($lesspipe)"
  • lesspipelessfile are the input preprocessor for less, which lets it to open all types of files.
  • lesspipe allows you to open while the process of conversion is going on using pipe.
  • lessfile completes the conversion first, and then displays the content. This writes the converted thing to a temporary file then displays it.
  • You can also write your own input preprocessor, and use it.

File Type 1: How to open a pdf file?

It shows all the text in the pdf file clearly, but ignores the images. The output may have some special characters here and there. But it is definitely readable.

File Type 1: How to open a pdf file?

It shows all the text in the pdf file clearly, but ignores the images. The output may have some special characters here and there. But it is definitely readable.

$ less Linux-101-Hacks.pdf
^LLinux 101 Hacks
www.thegeekstuff.com
o
o
o
Chapter 1: Powerful CD Command Hacks
cd is one of the most frequently used commands during a UNIX session.
The cd command hacks mentioned in this chapter will boost your productivity

File Type 2: How to open a word document file?

$ less pdb.doc
The Python Debugger Pdb
=======================

To use the debugger in its simplest form:

        >>> import pdb
        >>> pdb.run

The debugger's prompt is Pdb.  This will stop in the first
function call in

File Type 3: How to open a jpg, jpeg, png file?

While opening a image file (jpeg, jpg and png), less command shows the following information:

  • Name of the file
  • Type of file
  • Number of pixels — width & height
  • Size of the file
$ less testfile.jpeg
testfile.jpeg JPEG 2304x1728 2304x1728+0+0 DirectClass 8-bit 1.57222mb 0.550u 0:02

Note: Similar kind of information will be displayed for other image file types.

9. Less Command – Marked navigation

When you are viewing a large log file using less command, you can mark a particular position and return back to that place again by using that mark.

  • ma – mark the current position with the letter ‘a’,
  • ‘a – go to the marked position ‘a’.

10. Less Command – Multiple file paging

Method 1: You can open multiple files by passing the file names as arguments.

$ less file1 file2

Method 2: While you are viewing file1, use :e to open the file2 as shown below.

$ less file1
:e file2

Navigation across files: When you opened more than two files ( for e.g – less * ), use the following keys to navigate between files.

  • :n – go to the next file.
  • :p – go to the previous file.

How to Get a Sprint Call Log

A cell phone can usually retain a log of both incoming and outgoing calls. However, the handset’s call log is limited to a certain number of days, after which the entries automatically get deleted. To access a log that is not available on your phone, you can go to your Sprint account and access your phone’s call history. You will see the date, time, duration phone number and destination of each outgoing and incoming call.

Step 1

Go to Sprint’s website and log in to your account by entering your username and password. Once your account page opens, click the “My Account” tab.

Step 2

Click “See All Usage” at the bottom of the page.

Step 3

Click “See Call Log.” This will show you a detailed call log with each call made and received on the current billing cycle.

Step 4

Click “See my Bill” if you want to review the call log of the previous month.

How to Find a Server’s IP Address

The Internet protocol TCP/IP implies a unique IP address depicted in the dot-decimal form (such as 193.45.12.4) for every computer or server in the network. In the Internet, special domain name system (DNS) servers translate computer names into their IP addresses. Both Windows and Linux operating systems have simple commands for accessing the DNS service that allow you to find an IP address of any server worldwide.

In Windows XP/Vista/7

Step 1

Log on to a user account in Windows and go to the Start menu.

Step 2

Type “CMD” and press “Enter” to open the command prompt window in Windows Vista/7. Click “Run” and type “CMD” followed by pressing “Enter” in Windows XP.

Step 3

Type “nslookup” and press “Enter.” For instance, type “nslookup www.yahoo.com.”

Step 4

Read the command output. A line will contain the server’s name. In our example, the line contains “Name: www.yahoo.com.” The next line that begins with the word “Address” will include the the server’s IP address.

In Linux

Step 1

Click the GNOME menu “Applications” and “Accessories.” Then choose “Terminal” to open a command prompt window (terminal) in Linux.

Step 2

Type “host” and press “Enter.” For example, type “host www.amazon.com.”

Step 3

Read the server’s IP address in the command output. For instance, www.example.com has the IP address 144.5.210.250.

How to View a BIOS System Log

The Basic Input/Output System, or BIOS, of every computer or server is a vital component in the operation of that computer’s system. It stores essential information such as the system’s internal clock, hardware configuration, passwords and enabled/disabled devices. Computer users are allowed to access the BIOS system log to examine operations and make necessary changes, but there is a protocol for doing so. This protocol varies from manufacturer to manufacturer.

Accessing BIOS for Windows

Step 1

Turn on the computer. As the computer is booting up, look toward the bottom of the screen. You will notice directions that read “BIOS = F2, Boot System = F12” or something similar to those commands. Again, this will vary according to the manufacturer. Press the button indicated for BIOS.

Step 2

Press the button for “System Log” or “Event Log” on the menu that appears. The menu will offer you a variety of options that are accessed by pressing the indicated buttons.

Step 3

View the system log. If you do not see any of the prompts instructed in the previous steps, you may have to contact the BIOS manufacturer. To find the BIOS manufacturer for your system, go to the Search area on the desktop and type in “System Information.” Click “System Information” in the result, then view “System summary.” The BIOS manufacturer will be listed.

Accessing BIOS for Mac

Step 1

Turn on the computer and wait for the desktop screen to load.

Step 2

Go to “Applications,” “Utilities,” then “Console” or type “Console” in the Spotlight area.

Step 3

Go to “system.log” to view the BIOS system log.

Accessing BIOS for Gateway Servers

Step 1

Open the Gateway System Manager console and log in using your adminstrator ID and password

Step 2

Click on the “+” sign that is next to the icon labeled “GSM.”

Step 3

Click the “+” sign next to the server that you wish to view, then click “Events.”

Step 4

Click the “IPMI SEL” (short for Intelligent Platform Management Interface System Events Log) icon to show the system events log.

How to Change the Username of a Linux Account

Linux is a multi-user operating system. Each account on the system has a unique username. This is the name the user uses to log in to the system. It is also the name of the user’s home directory. Every Linux distribution uses the “usermod” command to modify user accounts. This includes changing the user name for a particular account. The “usermod” command can only be used by the root user. The root user can modify every account that accesses the operating system.

Step 1

Click on the main “Applications” or “Programs” menu.

Step 2

Click on the “Terminal” or “Konsole” menu option to open a terminal window and access the command prompt.

Step 3

Type the command “su -” to become the root user. Ubuntu and Linux Mint users type “sudo” before the following command.

Step 4

Type the command “usermod -l new_user login” to change the user name for an account. Replace “new_user” with the new username for the account. Replace “login” with the current username for the account.

Step 5

Type the command “exit” to close the root session.

How to Find UID and GID

The Linux and Unix operating systems use the UID — user ID — to identify a particular user. The GID, or group ID, is used to identify a group. Each user will have a single, unique UID and a primary GID. The user can belong to several secondary groups and each secondary group will have a unique GID. The “id” command can be used to show the UID and GIDs for a particular user. The root (super) user can view the UID and GID for any user. If you do not have root privileges, you can only view your own UID and GID.

Step 1

Open a terminal window. The terminal application is usually found in the “Accessories,” “Utilities” or “Tools” section of the main “Programs” or “Applications” menu.

Step 2

Type the command “su” to become the root user. Skip this step if you do not have root user privileges or want to find the UID or GID for your own account.

Step 3

Type the command “id -u” to find the UID for a particular user. Replace “” with the user’s Unix or Linux username.

Step 4

Type the command “id -g” to find the primary GID for a particular user. Replace “” with the user’s Unix or Linux username.

Step 5

Type the command “id -G” to list all the GIDs for a particular user. Replace “” with the user’s Unix or Linux username.

Step 6

Type the command “exit” to close the root user session.

How to View Linux Login History

Linux is a multi-user operating system, meaning that more than one person can be logged into a computer at the same time. To see the login history of all the computer’s users, use the “last” command in the Linux terminal window. Variations of the “last” command can show you the history of one particular user, or the IP addresses of any computers used to log in from, provided the Linux system can be accessed by remote computers.

Step 1

Open the Linux terminal window. The terminal window can be found under the “System Tools,” “Utilities” or “Accessories” section of the main menu depending on your distribution.

Step 2

Type the “last” in the terminal window and press Enter to see the login history of all users.

Step 3

Type the command “last” in the terminal window, replacing “” with the username for a particular user.

Step 4

Type the command “last -a” to see the login history and the IP addresses of the computers used.

Step 5

Type “exit” and press the Enter key to close the terminal window.

Some basics of MBR v/s GPT and BIOS v/s UEFI

MBR

A master boot record (MBR) is a special type of boot sector at the very beginning of partitioned computer mass storage devices like fixed disks or removable drives intended for use with IBM PC-compatible systems and beyond. The concept of MBRs was publicly introduced in 1983 with PC DOS 2.0.

The MBR holds the information on how the logical partitions, containing file systems, are organized on that medium. Besides that, the MBR also contains executable code to function as a loader for the installed operating system—usually by passing control over to the loader’s second stage, or in conjunction with each partition’s volume boot record (VBR). This MBR code is usually referred to as a boot loader.

The organization of the partition table in the MBR limits the maximum addressable storage space of a disk to 2 TB (232 × 512 bytes). Therefore, the MBR-based partitioning scheme is in the process of being superseded by the GUID Partition Table (GPT) scheme in new computers. A GPT can coexist with an MBR in order to provide some limited form of a backwards compatibility for older systems. 

GPT

GUID Partition Table (GPT) is a standard for the layout of the partition table on a physical hard disk, using globally unique identifiers (GUID). Although it forms a part of the Unified Extensible Firmware Interface (UEFI) standard (Unified EFI Forum proposed replacement for the PC BIOS), it is also used on some BIOS systems because of the limitations of master boot record (MBR) partition tables, which use 32 bits for storing logical block addresses (LBA) and size information.

MBR-based partition table schemes insert the partitioning information for (usually) four “primary” partitions in the master boot record (MBR) (which on a BIOS system is also the container for code that begins the process of booting the system). In a GPT, the first sector of the disk is reserved for a “protective MBR” such that booting a BIOS-based computer from a GPT disk is supported, but the boot loader and O/S must both be GPT-aware. Regardless of the sector size, the GPT header begins on the second logical block of the device. 


GPT uses modern logical block addressing (LBA) in place of the cylinder-head-sector (CHS) addressing used with MBR. Legacy MBR information is contained in LBA 0, the GPT header is in LBA 1, and the partition table itself follows. In 64-bit Windows operating systems, 16,384 bytes, or 32 sectors, are reserved for the GPT, leaving LBA 34 as the first usable sector on the disk. 

MBR vs. GPT

Compared with MBR disk, A GPT disk can support larger than 2 TB volumes where MBR cannot. A GPT disk can be basic or dynamic, just like an MBR disk can be basic or dynamic. GPT disks also support up to 128 partitions rather than the 4 primary partitions limited to MBR. Also, GPT keeps a backup of the partition table at the end of the disk. Furthermore, GPT disk provides greater reliability due to replication and cyclical redundancy check (CRC) protection of the partition table. 

The GUID partition table (GPT) disk partitioning style supports volumes up to 18 exabytes in size and up to 128 partitions per disk, compared to the master boot record (MBR) disk partitioning style, which supports volumes up to 2 terabytes in size and up to 4 primary partitions per disk (or three primary partitions, one extended partition, and unlimited logical drives). Unlike MBR partitioned disks, data critical to platform operation is located in partitions instead of unpartitioned or hidden sectors. In addition, GPT partitioned disks have redundant primary and backup partition tables for improved partition data structure integrity. 

BIOS

In IBM PC compatible computers, the Basic Input/Output System (BIOS), also known as System BIOS, ROM BIOS or PC BIOS, is a de facto standard defining a firmware interface. The name originated from the Basic Input/Output System used in the CP/M operating system in 1975. The BIOS software is built into the PC, and is the first software run by a PC when powered on.

The fundamental purposes of the BIOS are to initialize and test the system hardware components, and to load a bootloader or an operating system from a mass memory device. The BIOS additionally provides abstraction layer for the hardware, i.e. a consistent way for application programs and operating systems to interact with the keyboard, display, and other input/output devices. Variations in the system hardware are hidden by the BIOS from programs that use BIOS services instead of directly accessing the hardware. Modern operating systems ignore the abstraction layer provided by the BIOS and access the hardware components directly. 

UEFI

The Unified Extensible Firmware Interface (UEFI) (pronounced as an initialism U-E-F-I or like “unify” without the n) is a specification that defines a software interface between an operating system and platform firmware. UEFI is meant to replace the Basic Input/Output System (BIOS) firmware interface, present in all IBM PC-compatible personal computers. In practice, most UEFI images provide legacy support for BIOS services. UEFI can support remote diagnostics and repair of computers, even without another operating system.

The original EFI (Extensible Firmware Interface) specification was developed by Intel. Some of its practices and data formats mirror ones from Windows.] In 2005, UEFI deprecated EFI 1.10 (final release of EFI). The UEFI specification is managed by the Unified EFI Forum.

BIOS vs. UEFI

UEFI enables better use of bigger hard drives. Though UEFI supports the traditional master boot record (MBR) method of hard drive partitioning, it doesn’t stop there. It’s also capable of working with the GUID Partition Table (GPT), which is free of the limitations the MBR places on the number and size of partitions. GPT ups the maximum partition size from 2.19TB to 9.4 zettabytes.

UEFI may be faster than the BIOS. Various tweaks and optimizations in the UEFI may help your system boot more quickly it could before. For example: With UEFI you may not have to endure messages asking you to set up hardware functions (such as a RAID controller) unless your immediate input is required; and UEFI can choose to initialize only certain components. The degree to which a boot is sped up will depend on your system configuration and hardware, so you may see a significant or a minor speed increase.

Technical changes abound in UEFI. UEFI has room for more useful and usable features than could ever be crammed into the BIOS. Among these are cryptography, network authentication, support for extensions stored on non-volatile media, an integrated boot manager, and even a shell environment for running other EFI applications such as diagnostic utilities or flash updates. In addition, both the architecture and the drivers are CPU-independent, which opens the door to a wider variety of processors (including those using the ARM architecture, for example).

However, UEFI is still not widespread. Though major hardware companies have switched over almost exclusively to UEFI use, you still won’t find the new firmware in use on all motherboards—or in quite the same way across the spectrum. Many older and less expensive motherboards also still use the BIOS system. 

Converting from MBR to GPT

One of the more unusual features of gdisk is its ability to read an MBR partition table or BSD disklabel and convert it to GPT format without damaging the contents of the partitions on the disk. This feature exists to enable upgrading to GPT in case the limitations of MBRs or BSD disklabels become too onerous—for instance, if you want to add more OSes to a multi-boot configuration, but the OSes you want to add require too many primary partitions to fit on an MBR disk.

Conversions from MBR to GPT works because of inefficiencies in the MBR partitioning scheme. On an MBR disk, the bulk of the first cylinder of the disk goes unused—only the first sector (which holds the MBR itself) is used. Depending on the disk’s CHS geometry, this first cylinder is likely to be sufficient space to store the GPT header and partition table. Likewise, space is likely to go unused at the end of the disk because the cylinder (as seen by the BIOS and whatever tool originally partitioned the disk) will be incomplete, so the last few sectors will go unused. This leaves space for the backup GPT header and partition table. (Disks partitioned with 1 MiB alignment sometimes leave no gaps at the end of the disk, which can prevent conversion to GPT format—at least, unless you delete or resize the final partition.)

The task of converting MBR to GPT therefore becomes one of extracting the MBR data and stuffing the data into the appropriate GPT locations. Partition start and end points are straightforward to manage, with one important caveat: GPT fdisk ignores the CHS values and uses the LBA values exclusively. This means that the conversion will fail on disks that were partitioned with very old software. If the disk is over 8 GiB in size, though, GPT fdisk should find the data it needs.

Once the conversion is complete, there will be a series of gaps between partitions. Gaps at the start and end of the partition set will be related to the inefficiencies mentioned earlier that permit the conversion to work. Additional gaps before each partition that used to be a logical partition exist because of inefficiencies in the way logical partitions are allocated. These gaps are likely to be quite small (a few kilobytes), so you’re unlikely to be able to put useful partitions in those spaces. You could resize your partitions with GNU Parted to remove the gaps, but the risks of such an operation outweigh the very small benefits of recovering a few kilobytes of disk space.

How to convert MBps to IOPS or calculate IOPS from MB/s

Most SSDs have two speed ratings for reading as well as for writing.  The first rating is the sustained MB/s performance, which is the main marketing most manufacturers use.  The second rating is the 4K Random IOPS performance, which gives a much better idea of how the drive will perform in the real world.  The sustained MB/s rating is the sequential transfer rate the SSD will maintain continuously, such as over a period of 30 seconds.  The 4K Random IOPS on the other hand is how many 4K (4096 byte) operations the drive will handle per second with each block being read or written to a random position.

Usually when a Random 4K IOPS figure is given, it may state that this is at a certain queue depth, such as 4, 16, 32 or 64.  With a queue depth of 4, this means that there are 4 separate threads taking place with the drive, each thread independently running its own transfers.  With the use of Native Command Queuing (NCQ), the SSD can handle these threads simultaneously to improve the overall throughput compared to running a single thread.  While many hard disks use native command queuing to line up read/write operations to minimise seek times between each read/write operation, SSDs can read from and write to multiple NAND cells simultaneously, where as the read/write head in a hard disk can only be in one physical place at any time.
While it is nice to see how many IOPS a drive is capable of, it is also useful to see how this translates into actual throughput or even vice versa.  For example, most benchmark tools such as CrystalDiskMark and AS SSD report the random 4K performance in throughput, i.e. MB/s, while the SSD’s specifications usually rates the 4K performance in IOPS.To see how to translate MBps into IOPS and vice versa, we need to do a little math:

IOPS = (MBps Throughput / KB per IO) * 1024
Or
MBps = (IOPS * KB per IO) / 1024

So let’s say we have an SSD claiming a Random 4K write speed of 20,000 IOPS and it achieves 76.2MB/s in the CrystalDiskMark with the QD32 write test.

To convert the 76.2MB/s to IOPS, we perform the following calculation:

IOPS = (76.2 / 4) * 1024
IOPS = 19.1 * 1024
IOPS = 19,558.4

To see what throughput we need to achieve to match the actual 20,000 IOPS claim, we can perform this calculation in reverse:

MBps = (20,000 * 4) / 1024
MBps = 80,000 / 1024
MBps = 78.125MB/s

Note that each manufacturer uses its own method of coming up with their SSD IOPS ratings.  Besides separate IOPS ratings for read and write speeds, a given SSD can behave quite different depending on the type of data being read or written, as well as the duration this transfer takes place.  For example, an SSD that achieves 5,000 Random 4K IOPS sustained write over a period of 30 seconds may only achieve 1,000 IOPS sustained write over a period of 5 minutes.  For SSDs using the SandForce processor, the compressibility of the data also has an impact, so two benchmark tools may show completely different IOPS readings if one tool sends uncompressible data and the other tool sends highly compressible data and also if one runs the benchmark for longer duration than the other.

🙂

Happy calculating.