# Partitioning - `lsblk` to shows devices ![[images/Pasted image 20250802181233.png]] - `df -h` to shows existing partitions, usage, and mount points ![[images/Pasted image 20250802181246.png]] - `fdisk` used for MBR (master boot record) partitions - `fdisk disk` to create a new MBR partition on target disk - `gdisk` used for GPT (GUID partition table) partitions - `gdisk disk` to create a new GPT partition on target disk - `parted` used for both MBR and GPT partitions - `gparted` is a GUI version of `parted` # Simple File System Creation - `mkfs -t ext4 partition_path` to apply ext4 fs to target partition - fs tools: `blkid`, `chattr`, `lsattr` ,`debugfs`, `dumpefs2`, `resize2fs`, `tune2fs` # Mounting a FS - `mount` shows all current mount points and additional info (when no flags provided to command) ![[images/Pasted image 20250802181856.png]] - `sudo mount partition_path mount_path` mounts partition to mount point - `sudo mount -f parition_path mount_path` performs a dry run - `sudo mount -t ext4 partition_path mount_path` mounts partition to mount point with ext4 fs - edit `/etc/fstab` to auto mount drives on reboot ![[images/Pasted image 20250806174007.png]] - format: `file_system` `mount_point` `fs_type`  `options`  `dump`  `pass` - file_system: UUID, PARTUUID, LABEL, /dev/drive, etc. - fs_type: exts, xfs, btrfs, vfat, etc. - common options is defaults - defaults include: rw, suid, dev, exec, auto, nouser, async - dump always 0 - pass specifies whether to override fsck - `sudo mount -a` to force OS to read modified fstab file to mount any drives specified therein - `sudo mount -f parition_path mount_path` performs a dry run - `sudo umount options target_fs` to unmount target fs - -a unmounts all fs in `/etc/fstab` - -f force unmount - -n dry run - -v verbose - -r remount target fs as read-only # EXT Tools - EXT is the most common linux file system type - `makefs.ext4 partition_path` applies ext4 fs to partition - `dumpe2fs`: used to dump info re: ext file systems - pipe through head, etc. for viewability - `e2fsck`: used to check ext file systems - `fsck`: used to check file systems - `tune2fs -c n`: change max mount count param for a partition - number of times an fs is mounted until fsck is run on it - must also change pass field in `/etc/fstab` which can override the max mount count param - `-c -1` ignores max mount count param - `-c 1` obeys max mount count param for root partition - `-c 2` obeys max mount count param for other partitions - `resize2fs`: reduce/increase size of an ext file system # XFS Tools - XFS used by redhat - popular for performance and scalability - `makefs.xfs partition_path` applies xfs fs to partition - `xfs_repair`: e2fsck or fsck equivalent for XFS - `xfs_growfs`: can only grow and not shrink XFS - `xfs_info`: dumps info re: XFS partition - `xfs_admin`: add labels, etc. to XFS # BTRFS Tools and RAID Array Creation - `mkfs.btrfs partition_path` applies btrfs fs to partition - `btrfs device usage [mounted_btrfs]` to show info - `btrfs device add /dev/drive2 [mounted_btrfs]` to add drive to btrfs unit - aka union mounting - `btrfs balance start -mconvert=raid1 -dconvert=raid1 [mounted_btrfs]` - mconvert: metadata convert - dconvert: data convert - this command converts [mounted_btrfs] to a RAID1 mirrored btrsf unit - additional features: snapshots, subvolumes