Show Menu

LFCS_Module5_StorageManagement Cheat Sheet by


max 4 partitions
max 128 partitions
Beyond 4: extended, logical partition
All 128 are Primary
fdisk utility
gdisk utility

Creating partition

cat /proc/­par­tit­iions
List current partitions
fdisk /dev/sdb
Create MBR partition on /dev/sdb
gdisk /dev/sdb
Create GPT partition on /dev/sdc

Create File Systems

mkfs.ext4 -b 1024 -L myfs /dev/sdb1
Create ext4 file system w/ myfs label (-L) and 1024Mb size (-b)
mount /dev/sdb1 /mnt; umount /mnt
Mount /dev/sdb1 on /mnt; unmount
mkfs.xfs -L XFSFS /dev/sdb5
Create xfs file system
mount LABEL=­XFSFS /mnt
mkfs.btrfs -L butter /dev/sdc1
Create btrfs file system

Mount partitions w/ etc fstab

vim /etc/fstab
/dev/sdb1 /ext4 ext4 defaults 0 0
Mount by label
mount -a
Mount everything specified in fstab

Create RAID

gdisk disk; fd00; partprobe
Create RAID disks
mdadm --create /dev/md0 --level=1 --raid­-di­sks=2 /dev/sdd2 /dev/sde1
Create RAID level 1 from 2 RAID disk
mffs.ext4 /dev/md0
Create file system on RAID
mdadm --detail --scan >> /etc/m­dad­m.conf
Write the RAID config
mkdir /raid; mount /dev/md0 /raid
Mount RAID to /raid
vim /etc/f­stab;
Mount persis­tently
cat /proc/­mdstat
Check the RAID if operat­ional
mdadm --detail /dev/md0
More info about the RAID

Swap Partition

mkswap /dev/sdb6
Create swap file system on /dev/sdb6
free -m
Show current swap
swapon /dev/sdb6
Turn swap on
Mounting automa­tically
swapon -a

Configure Encrypted Partitions

fdisk /dev/sdb; n; l; w; partprobe
Create the partition
cryptsetup luksFormat /dev/sdb7; YES; pass;
Create encrypted device
cryptsetup luksOpen /dev/sdb7 secret
Open the encrypted partiton to create file system
mffs.ext4 /dev/m­app­er/­secret
Create file system on encrypted device
mount /dev/m­app­er/­secret /mnt
Mount the device
vim /etc/c­ryp­ttab; secret /dev/sdb8
/dev/m­app­er/­secret /secret ext4 noauto 0 0

Create LVM

gdisk /dev/sdc; 8e00; w; y; partprobe
Create partition for LVM
pvcreate /dev/sdc4
Create physical volume
vgcreate vgdata /dev/sdc4
Put physical volume in volume group
lvcreate -L 1G -n lvdata vgdata
Create logical volume
Show current LV
Show current volume group
Show current physical volume

LVM volume naming

/dev/m­apper; ls -l
List device mapper
/dev/v­gdata; ls -l

Mount LVM persis­tently

/dev/m­app­er/­vgd­ata­-lvdata /lvmou­ntpoint ext4 defaults 0 0
Mount in fstab
dmesg | tail
See errors

File System Label & UUID

tune2fs -L lvdata /dev/v­dga­ta/­lvdata
Change volume label
Show UUID for all current file system
etc/fs­tab/; UUID="...."­
Mount it

LVM Resize

df -h
Show file system info
gdisk /dev/sdc; partprobe /dev/sdc
Create another partition
vgextend *volumne group name /dev/sdc5
Extend the volume group
lvextend -l +100%FREE -r /dev/v­gda­ta/­lvdata
Resize LVM to take 100% free storage

Recover after disk failure

mdadm --create /dev/md0 -l 5 -x 1 /dev/sdb /dev/sdc /dev/sdd /dev/sde
Create RAID md0 level 5 w/ 1 hot spare (-x)
mdadm --fail /dev/md0 /dev/sdb
Fail a device
mdadm --remove /dev/md0 /dev/sdb
Remove the device from RAID array
mdadm -- /dev/md0 /dev/sde
Add new device to RAID array


No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Linux Command Line Cheat Sheet
          mod_rewrite Cheat Sheet
          Vim NERDTree Cheat Sheet

          More Cheat Sheets by nhatlong0605