Linux Learning - Partition & Swap

###Provision Partitions & File Systems###
Features:
 1. Ability to provision additional storage


Tools:
 1. 'fdisk'
 2. 'parted'
 3. 'mke2fs' - ext2,ext3,ext4 FSs


Storage Hierarchy:
 Disk
  -Partition(s)
    -File System(s)


Tasks:
 1. Enumerate available storage:
  a. 'fdisk -l' - enumerates disks and partitions
  b. 'parted -l' - ""


 2. Provision additional storage:
  a. Select disk: /dev/sdb
  b. 'parted /dev/sdb'
  c. 'mkpart primary 1 10GB'
  d. 'mke2fs -t ext4 -j /dev/sdb1' - overlays EXT4 FS on: /dev/sdb1
  e. 'mkdir /temp10G1'
  f. 'mount /dev/sdb1 /temp10G1 && mount'
  g. Create content in new repository


 3. Repeat process on the same disk
 
 4. Make partitions available across reboots:
  a. '/etc/fstab'
 5. Unmount both partitions and re-mount via: '/etc/fstab'
  a. 'umount /temp10G1 && umount /temp10G2 && mount'
  b. 'mount -a' - reads the contents of: '/etc/fstab'
Note: Paritioning is typically handled during installation and/or within runlevel 1




###Provision Swap Space###
Features:
 1. Generates additional virtual memory
 2. Temporary fix for RAM-shortage. Permanent fix is to add more RAM.
 3. Requires no system downtime
 4. Works with dedicated partitions
 5. Works with existing file systems
 6. Works across disks, consequently improving performance


Tasks:
 1. Define swap partition and provision
  a. 'fdisk /dev/sdb' - create partition and set to type '82' with 't' option
  b. 'mkswap /dev/sdb3' - i.e. similar to: 'mke2fs'
Note: If necessary, reboot the system after using: 'fdisk' or 'parted' to provision new swap partition
  c. 'swapon -s' displays current swap devices
  d. 'swapon -v /dev/sdb3' - enables swapping on specific device
  e. 'swapoff /dev/sdb3' - disables swapping on specific device: /dev/sdb3


 2. Define swap storage on existing file system
  a. 'dd if=/dev/zero of=/swapfile1G  bs=1024 count=1048576' - generates a file that we can overlay a swap file system on of size: 1G
  b. 'mkswap /swapfile1G'
  c. 'swapon -v /swapfile1G'

你可能感兴趣的:(swap,&,Linux/Partition)