Cheatography
https://cheatography.com
MBR vs GPT
BIOS |
UEFI |
<2TB |
>2TB |
max 4 partitions |
max 128 partitions |
Beyond 4: extended, logical partition |
All 128 are Primary |
fdisk utility |
gdisk utility |
Creating partition
cat /proc/partitiions |
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 |
Mount |
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 |
LABEL=XFSFS |
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-disks=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/mdadm.conf |
Write the RAID config |
mkdir /raid; mount /dev/md0 /raid |
Mount RAID to /raid |
vim /etc/fstab; |
Mount persistently |
cat /proc/mdstat |
Check the RAID if operational |
mdadm --detail /dev/md0 |
More info about the RAID |
Swap Partition
partprobe |
mkswap /dev/sdb6 |
Create swap file system on /dev/sdb6 |
free -m |
Show current swap |
swapon /dev/sdb6 |
Turn swap on |
/etc/fstab |
Mounting automatically |
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/mapper/secret |
Create file system on encrypted device |
mount /dev/mapper/secret /mnt |
Mount the device |
vim /etc/crypttab; secret /dev/sdb8 |
/dev/mapper/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 |
lvs |
Show current LV |
vgs |
Show current volume group |
pvs |
Show current physical volume |
LVM volume naming
/dev/mapper; ls -l |
List device mapper |
/dev/vgdata; ls -l |
// |
Mount LVM persistently
/dev/mapper/vgdata-lvdata /lvmountpoint ext4 defaults 0 0 |
Mount in fstab |
dmesg | tail |
See errors |
File System Label & UUID
tune2fs -L lvdata /dev/vdgata/lvdata |
Change volume label |
blkid |
Show UUID for all current file system |
etc/fstab/; 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/vgdata/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 |
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by nhatlong0605