Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Notes on hard drives partitioning for Linux

News

Linux Installation

Recommended Links Linux Disk Partitioning LVM Managing Disks by UUID Partition labels
 Linux Swap filesystem Swap file /etc/fstab/ Missing backup horror stories Recovery of LVM partitions    
Linux Software RAID Ext2/Ext3 File System Btrfs Linux SCSI subsystem Linux Logical Volume Snapshots Humor Etc
  1. We assume that a typical server now has iether two SSD drives (say 256GB and 1TB each) or four rotating drives (say 1TB each), that are configured into two logical drives using mirroring: OS disk and data disk. If you use four drives OS disk drives can be smaller (let's say 256GB or 512GB each)  then data disks but the price difference now is so small it does not make sense to buy rotating disks less then 1TB.  
     
  2. On rotating drives the key idea is to put three most used partitions such as / (we assume it includes /usr and /opt), /tmp, and /var on a narrow set of cylinders close to the center of the rotating drives. On SSD it really does not matter much, but still it is beneficial to have rarely used partitions such as swap on OS drive as the cells from those partitions can be reused easing wear and tear of other cells. In this sense it makes sense to use slightly larger boot and swap partition on SSD disks.

On rotating disks

  1. Root partition should be close to center of drive which is achievable by putting first boot, home and swap partitions, and only then /tmp, / and var (/ can include /usr and /opt). As working set of partitions for Linux is really small (12 GB or less) the large harddrive you have the better results you will get as in larger harddrive the size of each cylinder bigger and movement of the head will be smaller.  So 320 10K RPM drive can give a run for the money to 146 15K RPM drive.
     

  2. Mark all partitions except swap with format option (unless this is a re-install).
     
  3. Unless you know LVM really well never put your root partition on LVM. It complicates recovery. If the system is unbootable then after booting from a recovery disk you might find out that you LVM disks are not visible. For many sysadmin at this point cold goes down the spine.
     
  4. Swap file is a special Linux filesystem used by virtual memory management. If you have sufficient memory this file is almost never used, so it make sense to put it at the beginning of the drive (along with the /home partition -- typically data are just stored in to and it is yet another little used partition in Unix) to workhorse partitions such as root partition (that can and probably should include /usr and opt), /tmp and /var  closer to the middle of the drive.
     
  5. Unless you want to have /usr as read-only partition, in Suse it is not needed (nor makes much sense) to create separate partitions for /usr and /opt. They can be merged with root partition. That makes usage of disk space more efficient.  

    primary partitions:

    1. /boot  -- the value of having the first partition as book is that you can also save into its a copy of  the tarball of the etc directory and couple of other system files that simplify recovery. You can allocate to it 1G or if you want to keep ISO in it 6 GB.  In any case it helps to move "working partitions" deeper inside the disk where chances of corruption are less.
    2. swap. Swap should generally be allocated as the second partition on disk after /boot as it mostly unused. For small amount of RAM (less then 8GB) swap should be approximately 2x ram-size. For large amount of RAM swap can he half of RAM or less. For example in case of workstation with just 32GB  of memory you might need only  8GB for swap. I do not recommend swap size less then 8GB. You can also avoid creating this partition  at all and use a swap file.
    3. /home. Typically this is a little used partition that should approximately 8-16 GB just for private files of sysadmin and users.  In case you run out of space it can already be converted into LVM volume  You can mount it nosuid for security
      mount -o remount,nodev,nosuid /home

    Extended partitions

    1. root (think twice before putting root partition under LVM). Can include /opt and /usr. Total can be 16-32GB or something like that for everything.
    2. LVM partitions. Thos partitions can require additional space and as such can benefit from being under LVM.
      1. /var   For a typical serve should be around 20-30GB. This partition contains logs so it you have a web server or other large logs producing program it should be big.
      2. /tmp It is good idea to have /tmp as a separate partition as in this case you can mount it nosuid, nodev
        #!/bin/bash 
        # Title:    RHEL 6 Hardening 
        # Author:   Oageng Escobar Baruti 
        # Date:     24/08/2015 
        # >
        # DESCRIPTION: DISABLE / REMOVE / STOP / START / CONFIGURE 
        # 
        # Configure File Systems 
        cp /etc/fstab /etc/fstab.`date +%d%m%Y_%H:%M.%S` 
        mount -o remount,nodev /tmp 
        mount -o remount,nosuid /tmp 
      3. /srv -- typically used if if you have Web server or ftp upload service, should be mounted nosiud, nodev, noexec.
  6. With Suse 11 SP 1 you probably might benefit from using LVM on data partitions and /var  and /srv as size requirements for those partitions can change: it looks like there is no difference in stability and LVM provides additional flexibility as well as the ability to create snapshots. As for /home you can always create new partition and exile largest users into it  of create a new LVM volume and merge two partitions into one.  Do not start with LVM for home partition unless you need to as in case you need to recover data recovery from regular partitions is simpler.
  7. If you use SAN for data and local harddrives just for storing OS using LVM does not make much sense at all as SAN provides necessary flexibility in resizing partitions. 

To optimize disk configuration put both swap and home partitions before root partition. This way root partition will be closer to the middle of the disk.

Configuring RAID5 arrays

Raid 5 arrays can survive failure of only one drive. So for large disk enclosures it is suicidal to configure all disks as a single RAID5 virtual drive via Dell or HP RAID controller.  You are better off with RAID 6 if your controller support it.

If you are stuck with RAID5 you beed always use in conjunction with a spare harddrive to increase resiliency. Also it is not necessary to put all drives into a single virtual disk on the controller. If you have, say 16 drives, it might make sense to split them into two groups 8 each (each with  a spare) and have better resiliency


Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

Cool Solutions Install Linux Frequently, Without the Hassle

With RPM-based Linux distributions, version-to-version upgrades often don't work very well. A fresh installation may be the better choice. One may be reluctant to do this, because of the potential loss of data, preferences, configuration, and third-party applications. Also, if you don't like the newly installed system, the thought of reinstalling the old system to switch back to it is not a pleasant thought either.

This document describes a means of reinstalling Linux frequently, while minimizing the effort needed to become productive on a new system. It also allows you to instantly and effortlessly rollback to a previous Linux OS if you aren't happy with a newly installed system. Some possible applications of these suggestions include trying a new Linux distribution, or staying up-to-date with the latest beta release of your favorite Linux distribution.

Table of Contents

1. Introduction
1.1. Assumptions
2. Partitioning
2.1. Swap
2.2. Root Partitions
2.3. Data Partition
2.4. Variations
2.5. Partition Table Summary
3. Installing The First Instance of Linux
3.1. Install Target
3.2. Bootloader Location
3.3. Mount the Data Partition
4. Fixing the Bootloader
4.1. Move Bootloader Files
4.2. Install GRUB in the Boot Sector of the Root Partition
4.3. Edit the Boot Menu
4.4. Booting the Linux OS
5. Home Directory Maintenance
5.1. Setup the Data Partition
5.2. Symlinking to the Data Partition
5.3. Using the Customized Home Directory
6. Installing More Linux Systems
6.1. Bootloader Location
6.2. Mounting the Data Partition
6.3. Creating the Symbolic Links
7. Practical Use
7.1. Beta Snapshots
8. Other Hints
8.1. Third-party Applications
8.2. Make the Most of Symbolic Links
9. Summary

1. Introduction

If a little extra care is taken when first installing Linux on a system, it can require far less maintenance over the lifetime of the system. This document presents suggestions for using partitions and symbolic links to your advantage to minimize the effort required to test-drive a new Linux distribution.

1.1. Assumptions

The rest of this document makes the following assumptions:

If your system differs from this, you'll need to make appropriate adjustments to the examples that follow. For example, if you do not have windows installed, the swap partition can be /dev/hda1 instead of /dev/hda2. If you actually think you can find a use for the entirety of your modern, huge hard disk, this document is not for you.

Creating dynamic swap space

Posted by Steve on Thu 27 Sep 2007 at 06:32

Tags: , ,

When a GNU/Linux machine runs out of physical memory it will start to use any configured swap-space. This is usually a sign of trouble as swap files and partitions are significantly slower to access than physical memory, however having some swap is generally better than having none at all. The size of swap allocated to files, or partitions, is usually chosen arbitrarily with many people adopting the "double the memory size" rule of thumb. Using a dynamic system can ease the maintainance of this size.

The relatively unknown dphys-swapfile package contains a simple script which will create and activate a swapfile at boottime which is sized appropriately for your system.

The advantage of this dynamic creation is that the swap will be resized automatically if you upgrade your memory and don't remember to do it.

Upon recent kernels there doesn't appear to be a significant penalty to using swap files as opposed to swap partitions. With this in mind I'd recommend files rather than partitions, to give yourself more flexibility.

To get started first remove any existing swap you have allocated. You can view any swap space which is in use by running:

skx@vain:~$ /sbin/swapon  -s
Filename                                Type            Size    Used    Priority
/dev/md1                                partition       2931768 557428  -1

Here we see that there is swap allocated to the physical raid volume /dev/md1. We can disable that by running:

root@vain:~# /sbin/swapoff /dev/md1

Once it is gone we can now install the package upon installation the system will create and activate then new swap:

root@vain:~# apt-get install dphys-swapfile
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed
  dphys-swapfile
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 9572B of archives.
After unpacking 111kB of additional disk space will be used.
Get: 1 http://apt-cache sid/main dphys-swapfile 20061020-1 [9572B]
Fetched 9572B in 0s (60.5kB/s)       
Selecting previously deselected package dphys-swapfile.
(Reading database ... 116206 files and directories currently installed.)
Unpacking dphys-swapfile (from .../dphys-swapfile_20061020-1_all.deb) ...
Setting up dphys-swapfile (20061020-1) ...
Starting dphys-swapfile swapfile setup ...
computing size, want /var/swap=1876MByte, generating swapfile ... of 1876MBytes
done.

Now whenever you boot you'll have /var/swap created at a size of twice your amount of physical memory, automatically.

You can verify this yourself with the swapon command we demonstrated earlier:

skx@vain:~$ /sbin/swapon  -s
Filename                                Type            Size    Used    Priority
/var/swap                               file            1921016 0       -3

If you wish to change the location, or size, of the generated swapfile please create the file /etc/dphys-swapfile and give it contents such as this:

# /etc/dphys-swapfile - user settings for dphys-swapfile package
# author Neil Franklin, last modification 2006.09.15
# copyright ETH Zuerich Physics Departement
#   use under either modified/non-advertising BSD or GPL license
# this file is sourced with . so full normal sh syntax applies

# where we want the swapfile to be, this is the default
CONF_SWAPFILE=/swap.file

# size we want to force it to be, default (empty) gives 2*RAM
CONF_SWAPSIZE=2048

##
#  Give yourself three times the memory size of swap?
#
# mem=$(grep MemTotal /proc/meminfo |awk '{print $2}')
# CONF_SWAPSIZE=$(expr $mem \* 3)
#



Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: October, 06, 2019