Useful disk commands

I rarely use disk commands that why I often forget them and spend minutes to find the right command that I already used.

Here are some of the most useful disk commands I use:

# List all existing disks
fdisk -l
 
# Show mounted partitions, modify them in /etc/fstab, to mount use "-all" argument
mount
 
# Build a RAID 1 from 2 disks /dev/sda3 & /dev/sdb3
mdadm -C /dev/md3 --level=raid1 --raid-devices=2 /dev/sda3 /dev/sdb3
 
# Details about RAID /dev/md3
mdadm --detail /dev/md3
 
# Update mdadm.conf, delete lines before
mdadm --examine --scan >> /etc/mdadm/mdadm.conf
 
# Format /dev/md3 in ext4
mke2fs -t ext4 /dev/md3

Leave a Reply

Your email address will not be published. Required fields are marked *