Storage
Presenter:!Robert Wang
Linux’s Abstraction
(vfs)
(file systems)
(physical devices)
Storage Device
Disk Drive
Multiple Drives
❖ RAID!
❖ Redundant Array of Independent/Inexpensive Disks!
❖ Software or Hardware!
❖ RAID 0, 1, 5, 6, 10
Software RAID
❖ Linux md!
❖ LVM!
❖ ZFS, btrfs
Hardware RAID
❖ RAID controller card!
!
!
❖ Expensive!
❖ Higher performance!
❖ Able to expose as a single drive to OS
Direct Attached Storage
❖ DAS
Storage Area Network
❖ SAN!
❖ Fibre Channel (FC)!
❖ iSCSI!
❖ ATA-over-Ethernet
Network Attached Storage
❖ NFS!
❖ commonly support on unix-like OS!
❖ SMB/CIFS!
❖ Windows file sharing!
❖ AFP!
❖ Apple’s Mac OS
SAN vs. NAS
open(“yay.cpp”) read_block(5566)
Partitioning
Intro.
❖ A partition table on disk
MBR!
(msdos) GPT
Max disk size 2 TiB ~8 ZiB
Max # part. 4 primary 128
Utilities
❖ fdisk!
❖ No GPT support.!
❖ parted!
❖ Scripting support
fdisk
fdisk — create partition
fdisk — delete partition
fdisk — save and exit
parted
❖ Warning: Modification is immediate!
— help
parted — GPT example
Done once for each new disk
Create a new partition
parted — delete partition
Cannot Move
❖ Map as ranges!
❖ Partitions cannot easily be moved
1 2 3
logical disk address ———————>
Logical Volume Manager
What is LVM?
❖ A system to manage disk drives on Linux.!
❖ Provides!
❖ Storage pooling!
❖ Online resizing!
❖ Snapshots
Concepts
❖ PV — Physical Volume!
❖ A disk or partition!
❖ VG — Volume Group!
❖ A group of PVs!
❖ LV — Logical Volume!
❖ A virtual disk/partition!
❖ PE — Physical Extent!
❖ Data blocks of a PV
PP = PE = Physical Extent
Setup
❖ # aptitude install lvm2
Create PV
❖ When using DOS partition table, set the partition to LVM type!
❖ fdisk: change type to “8e”!
❖ parted: turn on “lvm” flag!
❖ # pvcreate /dev/XXX
Create VG
❖ # vgcreate <name> /dev/XXX
Create LV
❖ # lvcreate --name <name> --size<size> <vg name>!
❖ Size units!
❖ B, K, M, G, T!
❖ Path to new volume!
❖ /dev/<vg name>/<lv name>!
❖ /dev/mapper/<vg name>-<lv name>
More Info
❖ Commands you can try:!
!
!
❖ More on wiki!
❖ https://wiki.archlinux.org/index.php/LVM!
❖ And manpages.
File Systems
Linux File Systems
❖ ext family — default in most Linux distributions!
❖ ext2, ext3, ext4!
❖ XFS!
❖ ZFS!
❖ btrfs!
❖ pseudo-file system
ext family
❖ ext — replaced MINIX file system!
❖ ext2!
❖ ext3 — adds!
❖ Journaling!
❖ Online expanding!
❖ HTree directory index (was linked-list)
ext family (cont.)
❖ ext4 — adds!
❖ Larger file system (> 2TB)!
❖ Extents (large contiguous blocks)!
❖ Journal Checksum!
❖ Unlimited subdirectories (was 32,000)!
❖ Faster fsck!
❖ Delayed allocation!
❖ Persistent pre-allocation
XFS
❖ By SGI!
❖ Opensourced and ported to Linux!
❖ Fast for large filesystems and large files!
❖ Features!
❖ Journaling!
❖ Extents!
❖ Filesystem freezing!
❖ etc.
ZFS
❖ By SUN!
❖ Opensource but license not compatible with Linux!
❖ Available on!
❖ Solaris!
❖ FreeBSD!
❖ Linux using FUSE or “ZFS on Linux”!
❖ File system + LVM
btrfs
❖ Started by Oracle!
❖ Experimental!
❖ Actively developed!
❖ Comparable to ZFS
Recommendation
❖ Use ext4 or XFS!
❖ See manpage for options!
❖ Some need to be set at file system creation!
❖ Some can be tuned by remount or even online!
❖ Features, block size, strip size/width, etc.
Create a Filesystem
❖ # mkfs.<type> /dev/XXX!
❖ Type: ext2, ext3, ext4, xfs, …!
❖ btrfs!
❖ https://btrfs.wiki.kernel.org/index.php/Getting_started
Utilities
❖ ext family!
❖ e2fsprogs!
❖ XFS!
❖ xfsprogs
Mount
❖ A filesystem is mounted at a “mount point”!
❖ a directory!
❖ contents of that directory is hidden!
❖ See mounted filesystems!
❖ $ mount
<device> on <mount point> type <type> (<mount options>) /dev/sda4 on /home type ext4 (…)
How to Mount
❖ Create a directory!
❖ # mkdir /mnt/disk!
❖ Mount (auto detect type)!
❖ # mount /dev/XXX /mnt/disk!
❖ Mount (specify type/options)!
❖ # mount -t xfs -o ro,noatime /dev/XXX /mnt/disk
How to Unmount
❖ Unmount!
❖ # umount /dev/XXX!
❖ or!
❖ # umount /mnt/disk
Mount on Boot
❖ Edit /etc/fstab
Practice
❖ Use a flat file to play with fdisk and parted!
❖ $ dd if=/dev/zero of=XXX bs=1M count=10240!
❖ $ fdisk XXX!
❖ $ parted XXX!
❖ Create a DOS partition table!
❖ Create 2 partitions with!
❖ 1st — 2GiB!
❖ 2nd — the rest
Homework
❖ Given 2 HDDs from command line arguments.!
❖ # ./b02902000.sh /dev/XXX /dev/YYY!
!
❖ Use parted in script mode to create LVM partitions on both HDDs!
❖ Add them to LVM volume group!
❖ Use your student ID as the name!
❖ Create a 20G LV named ID-1 and format as ext4!
❖ Create a 20G LV named ID-2 and format as XFS!
❖ Undo (delete everything)!
!
❖ Be sure to try it SAFELY before submitting!
❖ Do not include any useless commands