how does block device, filesystem, and mount work together

tags: learning linux

content

  • when we wanna use a new storage hardware on the linux system, we need to
    • physically connect the device
    • partition the device if needed
    • put a filesystem on it (laymen term: reformat)
    • mount the device to a location on the linux’s directory tree

in action:

  1. lsblk to see what devices are connected physically
  2. fdisk /dev/sdb to partition /dev/sdb
    • /dev/sdb becomes /dev/sdb1, /dev/sdb2, etc
  3. sudo mkfs.ext4 /dev/sdb1: create filesystem ext4 on block device /dev/sdb1
  4. mkdir -p /home/mydata: create a location for the block device to mount on
  5. sudo mount /dev/sdb1 /home/mydata: mount the block device to the location /home/mydata
  6. df -h to verify

up

down

reference