Tuesday 31 January 2017

Linux vs Windows vs Mac OS

Linux vs Macintosh vs Windows (unbiased comparison)In this article, I will be outlining the pros and cons of the three major operating systems: Linux, Mac and Windows (commonly referred to as "PC"). Keep in mind that there are many other operating systems, but I will not be reviewing them because of their very small market share.

Let's start with the most popular: Windows
With almost 90% of the operating system market share, you can't miss Windows. It's in commercial buildings, industrial facilities, as well as home computers. Windows, having been introduced in 1985, is a very mature and complete piece of software. Yet, it has it's flaws... Pros: 
  1. Compatibility: Almost every application, driver or game will work on Windows.
  1. Technical support: Having so many users, you can always find someone (either online or offline) who can help you with Windows.
  1. Huge quantity of function: When you get to know Windows well, you'll find out that there are so many functions that you can do almost anything quite easily.

Cons:

  1. Viruses: You may need to buy an antivirus program, although free ones exist.
  1. Slow: Windows, especially Vista and 7, requires a lot of computer resources (memory, processor, disk space), and thus, runs slower.
  1. Price: It easily costs over a hundred dollars.


Another big player: Macintosh
Apple's Macintosh OS is even older than Windows. It is the first ever successful graphical-based operating system, being released one year before it's Microsoft counterpart. Pros:
  1. Viruses: Apple Macs get almost no viruses. This is mostly due to Window's superior market share.
  1. Reliability: Macs only run on Apple computers, and are thus less prone to hardware and software crashing.
  1. Looks: Let's face it, most of the time, Mac just looks better than Windows.

Cons: 

  1. Expensive: Mac costs even more than Windows.
  1. Only available on Apple computers: If you already have a computer, you cannot install MAC on it unless it's an Apple. Otherwise, you must buy a new computer.
  1. Compatibility: Only a few programs will run on Mac, and almost no games.


Smaller but growing: LinuxLinux is GNU's answer to Mac and Windows. Yes, this means that Linux is FREE! By free, you can download, modify and redistribute it without spending a dime! . Linux is a younger player in the OS world, having been written in 1991, and is optimized for modern use (well, more than Windows and Mac). Unfortunately, it has some disadvantages also...Pros:
  1. Price: Linux is F-R-E-E. You can download it, install it, use it, modify it... All for a whooping 0$.
  1. Variety: Linux is not a full operating system. It is just a kernel. To use the kernel, additional software needs to be bundled with Linux. Several hundreds of these bundles (called "distributions" or simply "distros") exist. The most popular ones include Ubuntu, Mint and Fedora. The good thing is, with so many different flavours of Linux, there is always one to suit your needs!
  1. Viruses: Although being more vulnerable to viruses than Mac (because it is open source), Linux still has very, very, very few viruses.

Cons:

  1. Complicated: Although some distros are quite easy to use, most of them will required a good deal of computer knowledge in order to get them to work. 
  1. Compatibility: Like Mac, representing only a few percents of the market share, Linux does not have as many programs and games as Windows.
  1. Vendors: You won't find a lot of vendors selling Linux computers. Usually, you'll just end up having to buy Windows computer, reformatting the hard drive, and installing Linux yourself.


Bottom lineNo operating system is really better, the choice is up to you. If you're a gamer, then you have no choice, go for Windows. Programmers might prefer Linux and video/graphics producers will probably tend towards Mac. The best thing to do is probably to try each OS and see which is best for you!


Introduction to File systems:

File systems are one of the things any newcomer to linux must become acquainted with. In the world of Microsoft you never really have to worry about it, the default being NTFS. Linux however, being built on a world of open source and differing opinions, is not limited in this way and so the user should have an understanding of what a file system is, and how it affects the computer.
At the core of a computer, it's all 1s and 0s, but the organization of that data is not quite as simple. A bit is a 1 or a 0, a byte is composed of 8 bits, a kibibyte is 1024 (i.e. 2^10) bytes, a mebibyte is 1024 kibibytes and so on and so forth. All these bits and bytes are permanently stored on a Hard Drive. A hard drive stores all your data, any time you save a file, you're writing thousands of 1s and 0s to a metallic disc, changing the magnetic properties that can later be read as 1 or 0. There is so much data on a hard drive that there has to be some way to organize it, like a library of books and the old card drawers that indexed all of them, without that index, we'd be lost. Libraries, for the most part, use the Dewey Decimal System to organize their books, but there exist other systems to do so, none of which have attained the same fame as Mr. Dewey's invention. File systems are the same way. The ones most users are aware of are the ones Windows uses, the vFat or the NTFS systems, these are the Windows default file systems.
There are several different attributes which are necessary in defining file systems, these include their max file size, max partition size, whether they journal or not.

Journaling:
A journaling file system is more reliable when it comes to data storage. Journaling file systems do not necessarily prevent corruption, but they do prevent inconsistency and are much faster at file system checks than non-journaled file systems. If a power failure happens while you are saving a file, the save will not complete and you end up with corrupted data and an inconsistent file system. Instead of actually writing directly to the part of the disk where the file is stored, a journaling file system first writes it to another part of the hard drive and notes the necessary changes to a log, then in the background it goes through each entry to the journal and begins to complete the task, and when the task is complete, it checks it off on the list. Thus the file system is always in a consistent state (the file got saved, the journal reports it as not completely saved, or the journal is inconsistent (but can be rebuilt from the file system)). Some journaling file systems can prevent corruption as well by writing data twice.
Table
Now below is a very brief comparison of the most common file systems in use with the Linux world.
File System
Max File Size
Max Partition Size
Journaling
Notes

Fat16
2 GiB
2 GiB
No
Legacy

Fat32
4 GiB
8 TiB
No
Legacy

NTFS
2 TiB
256 TiB
Yes
(For Windows Compatibility) NTFS-3g is installed by default in Ubuntu, allowing Read/Write support

ext2
2 TiB
32 TiB
No
Legacy

ext3
2 TiB
32 TiB
Yes
Standard linux filesystem for many years. Best choice for super-standard installation.

ext4
16 TiB
1 EiB
Yes
Modern iteration of ext3. Best choice for new installations where super-standard isn't necessary.

reiserFS
8 TiB
16 TiB
Yes
No longer well-maintained.

JFS
4PiB
32PiB
Yes (metadata)
Created by IBM - Not well maintained.

XFS
8 EiB
8 EiB
Yes (metadata)
Created by SGI. Best choice for a mix of stability and advanced journaling.

GiB = Gibibyte (1024 MiB) :: TiB = Tebibyte (1024 GiB) :: PiB = Pebibyte (1024 TiB) :: EiB = Exbibyte (1024 PiB)
Above you'll see a brief comparison of two main attributes of different filesystems, the max file size and the largest a partition of that data can be.
Of the above file systems the only one you cannot install Linux on is the NTFS. It is not recommended to install Linux on any type of FAT file system, because FAT does not have any of the permissions of a true Unix FS.

Editing Files:
Those used to a Windows file system (NTFS, FAT) know that it isn't normally possible to change files while they are open. This restriction does not exist in a Unix file system. This is because in Unix file systems, files are indexed by a number, called the inode, and each inode has several attributes associated with it, like permissions, name, etc. When you delete a file, what really happens is the inode is unlinked from the filename, but if some other program is using the file, it still has a link open to the OS, and will continue to be updated. A file is not really deleted until all links have been removed (even then, the data is still on the disk, but not indexed in anyway and thus very hard to recover). All of this means that you can delete executing programs while they're running without crashing and move files before they're finished downloading without corruption.

Fragmentation:
Another common Windows practice that is not needed in Unix is defragmenting the hard drive. When NTFS and FAT write files to the hard drive, they don't always keep pieces (known as blocks) of files together. Therefore, to maintain the performance of the computer, the hard drive needs to be "defragged" every once in a while. This is unnecessary on Unix File systems due to the way it was designed. When ext3 was developed, it was coded so that it would keep blocks of files together or at least near each other.
No true defragmenting tools exist for the ext3 file system, but tools for defragmenting will be included with the ext4 file system.

In what ways Linux Filesystem is different from Windows Filesystem

What is a file system?
Any computer file is stored on some kind of a storage with a given capacity. Actually, each storage is a linear space for reading or both reading and writing digital information. Each byte of information on the storage has its own offset from the storage start (address) and is referenced by this address. A storage can be presented as a grid with a set of numbered cells (each cell is a single byte). Any file saved to the storage gets a number of these cells.

Generally, computer storages use a pair of sector and in-sector offset to reference any byte of information on the storage. The sector is a group of bytes (usually 512 bytes) that is a minimum addressable unit of the physical storage. For example, byte 1040 on a hard disk will be referenced as a sector #3 and offset in sector 16 bytes ([sector]+[sector]+[16 bytes]). This scheme is applied to optimize storage addressing and use a smaller number to reference any portion of information on the storage.

To omit the second part of the address (in-sector offset), files storing begins in the sector start and occupy the whole sectors (e.g.: 10-byte file occupies the whole sector, 512-byte file also occupies the whole sector, at the same time, 514 byte file occupies two whole sectors).

Each file is stored on 'unused' sectors and can be read then by a known position and size. However, how do we know what sectors are used or unused? Where are file size and position stored? Where is a file name? These answers are given by a file system.

As a whole, file system is structured data representation and a set of metadata describing the stored data. A file system not only serves for the purposes of the whole storage but is also a part of an isolated storage segment – disk partition. Usually, the file system operates blocks, not sectors. File system blocks are groups of sectors which optimize storage addressing. Modern file systems generally use block sizes from 1 to 128 sectors (512-65536 bytes). Files are usually stored from the start of a block and take entire blocks.

Immense write/delete operations to file system cause file system fragmentation. As a result files aren't stored as whole fragments and are divided into fragments. For example, a storage is entirely taken by files with size about 4 blocks (e.g. a collection of pictures). User wants to store a file that will take 8 blocks and therefore deletes the first and the last files. By doing this it clears the space on 8 blocks, however, the first segment is near to the storage start, and the second – to the storage end. In this case 8-block file is split into two parts (4 blocks for each part) and takes free space 'holes'. The information about both fragments as parts of a single file is stored to file system.

In addition to user’s files, the file system also contains its own parameters (such as block size), file descriptors (including file size, file location, its fragments etc.), file names and directory hierarchy. It may also store security information, extended attributes and other parameters.

To comply with diverse requirements as storage performance, stability and reliability plenty of file systems are developed to serve certain user purposes.

Windows file systems:
Microsoft Windows OS uses two major file systems: FAT, inherited from old DOS with its later extension FAT32, and widely-used NTFS file systems. Recently released ReFS file system was developed by Microsoft as a new generation file system for Windows 8 Servers.

FAT:
FAT (File Allocation Table) is one of the simplest types of a file system. It consists of a file system descriptor sector (boot sector or superblock), a file system block allocation table (referred as File Allocation Table) and plain storage space to store files and folders. Files on FAT are stored in directories. Each directory is an array of 32-byte records, each defining file or file extended attributes (e.g. long file name). File record attributes the first block of a file. Any next block can be found through a block allocation table by using it as linked-list.

Block allocation table contains an array of block descriptors. Zero value indicates that the block is not used and non-zero – relates to the next block of the file or a special value for file end.

The numbers in FAT12FAT16FAT32 stands for the number if bits used to enumerate file system block. This means that FAT12 can use up to 4096 different block references, while FAT16 and FAT32 can use up to 65536 and 4294967296 accordingly. Actual maximum count of blocks is even less and depends on implementation of a file system driver.

FAT12 was used for old floppy disksFAT16 (or simply FAT) and FAT32 are widely used for flash memory cards and USB flash sticks. The system is supported by mobile phones, digital cameras and other portable devices.

FAT or FAT32 is a file system, used on Windows-compatible external storages or disk partitions with size under 2GB (for FAT) or 32GB (for FAT32). Windows cannot create FAT32 file system over 32GB (however Linux supports FAT32 up to 2TB).

NTFS:
NTFS (New Technology File System) was introduced in Windows NT and is major file system for Windows at present. This is a default file system for disk partitions and the only file system that is supported for disk partitions over 32GB. The file system is quite extensible supporting many file properties, including access controlencryption etc. Each file on NTFS is stored as file descriptor in a Master File Table and file content. Master file table contains all information about the file: size, allocation, name etc. The first and the last sectors of the file system contain file system settings (boot record or superblock). This file system uses 48 and 64 bit values to reference files, thus supporting quite large disk storages.

ReFS:
ReFS (Resilient File System) is the latest development of Microsoft presently available for Windows 8 Servers. File system architecture absolutely differs from other Windows file systems and is mainly organized in a form of B+-treeReFS has high tolerance to failures due to new features included into the system. And, namely, Copy-on-Write (CoW): no metadata is modified without being copied; data is written not over the existing data, but into a new disk space. With any file modifications a new copy of metadata is created into free storage space, and then the system creates a link from older metadata to the newer ones. As a result, a system stores significant quantity of older backups in different places providing easy file recovery unless this storage space is overwritten.

Linux file systems
Open-source Linux OS aims at implementing, testing and using different concepts of file systems. The most popular Linux file systems nowadays are:
  • Ext2, Ext3, Ext4 - 'native' Linux file system. This file system falls under active developments and improvements. Ext3 file system is just an extension to Ext2 which uses transactional file write operations with a journalExt4 is a further development of Ext3, extended with support of optimized file allocation information (extents) and extended file attributes. This file system is frequently used as a 'root' file system for most Linux installations.
  • ReiserFS - alternative Linux file system is created to store huge amount of small files. It has good capability of files search and enables compact files allocation by storing file tails or small files along with metadata in order not to use large file system blocks for the same purpose.
  • XFS - file system derived from SGI company and was initially used for company’s IRIX servers. Now XFS specifications are implemented in Linux. XFS file system has great performance and is widely used to store files.
  • JFS - file system is developed by IBM for the company’s powerful computing systems. JFS1 usually stands for JFSJFS2 is the second release. Currently this file system is open-source and implemented in most modern Linux versions.
The concept of 'hard links' used in this kind of OS is a common feature of Linux file systems of not regarding the file name as file attribute and rather defined as an alias for a file in certain directory. File object can be linked from many locations, even multiply from the same directory under different names. This may present serious and even insurmountable difficulties for recovery of file names after file deletion or file system damage.

More about Linux File System Layout:



For convenience, the Linux file system is usually thought of in a tree structure. On a standard Linux system you will find the layout generally follows the scheme presented below.


Subdirectories of the / (root) directory:
DirectoryContent
/binCommon programs, shared by the system, the system administrator and the users.
/bootThe startup files and the kernel, vmlinuz. In some recent distributions also grub data. Grub is the GRand Unified Boot loader and is an attempt to get rid of the many different boot-loaders we know today.
/devContains references to all the CPU peripheral hardware, which are represented as files with special properties.
/etcMost important system configuration files are in /etc, this directory contains data similar to those in the Control Panel in Windows
/homeHome directories of the common users.
/initrd(on some distributions) Information for booting. Do not remove!
/libLibrary files, includes files for all kinds of programs needed by the system and the users.
/lost+foundEvery partition has a lost+found in its upper directory. Files that were saved during failures are here.
/miscFor miscellaneous purposes.
/mntStandard mount point for external file systems, e.g. a CD-ROM or a digital camera.
/netStandard mount point for entire remote file systems
/optTypically contains extra and third party software.
/procA virtual file system containing information about system resources. More information about the meaning of the files in proc is obtained by entering the command man proc in a terminal window. The file proc.txt discusses the virtual file system in detail.
/rootThe administrative user's home directory. Mind the difference between /, the root directory and /root, the home directory of the root user.
/sbinPrograms for use by the system and the system administrator.
/tmpTemporary space for use by the system, cleaned upon reboot, so don't use this for saving any work!
/usrPrograms, libraries, documentation etc. for all user-related programs.
/varStorage for all variable files and temporary files created by users, such as log files, the mail queue, the print spooler area, space for temporary storage of files downloaded from the Internet, or to keep an image of a CD before burning it.
How can you find out which partition a directory is on? Using the df command with a dot (.) as an option shows the partition the current directory belongs to, and informs about the amount of space used on this partition:
yadnesh:/lib> df -h .
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda7             980M  163M  767M  18% /

No comments:

Post a Comment