Linux Block Device Notes

Prev  
 Next

Linux Block Device Notes

Linux Disk Partition and Format Notes

Some basic tools

  • ls -l /dev/disk/by-uuid/ will list the disks with UUIDs
  • lsblk to list partitions (or list block devices)
  • lsblk -f or blkid to list the UUIDs
  • sudo blkid will list data blocks

parted

There would seem to be a number of partition tools for Linux CLI.
  • sudo parted -l - to see all available partition information
  • sudo parted /dev/sda - to partition the specific drive

When in parted:

  • print to see current partition information
  • mkpart help to list option
  • mklabel gpt to give drive label gpt
  • mkpart help mkpart to list specific help items on mkpart
  • mkpart primary ext4 0% 100% to make a partition that take the full optimised drive area
  • rm 1 to remove partition 1

Format

sudo mkfs.ext4 /dev/sda1 - to format the drive


Fstab

sudo vim /etc/fstab -to edit the boot disk mount table, remember to make matching mount point directories


mount

Local Device

mount -t ext4 /dev/sdb1 /run/media/diska

NFS Device

To mount a NFS manually:

  • sudo mount -t nfs -o rw,vers=4 192.168.1.5:/export/Disk1 /mnt/backup1
  • sudo mount -t nfs -o rw,vers=4 192.168.1.5:/export/Disk2 /mnt/backup2

Where:

  • -t nfs : type nfs
  • -o : options, options are separated by commas with no spaces
    • rw : read / write
    • vers=4 : version 4 of nfs
  • 192.168.1.5:/export/Disk1 is the remote exported NFS mount point
  • /mnt/backup1 : is the local mount point, note this directory must exist, ideally empty, any existing contents are usually invisible and otherwise ignored

unmount

sudo umount /run/media/diska


mount at boot

sudo vim /etc/fstab


Block Device Monitoring and Control

My main server has a parity disk that is normally only is used once a week. I would like to place this hard disk in to stand-by to reduce power and wear and tear upon it.

smartmon

  • sudo smartctl -i -n standby /dev/sdb will chack the HD activity mode. It does this without starting up the drive, which hdparm may do.
    • If in standby mode it reports back only: “Device is in STANDBY mode, exit(2)” otherwise
    • active or idel mode

hdparm

  • sudo hdparm -y /dev/sdb sets the HD into standby mode

To for the HD into standby mode after reboot and set the standby time crate and use an on boot systemd service.

/etc/systemd/system/hdparm.service

Some tips:

  • use whereis hdparm to confirm where the command is installed.
  • use sudo apt install hdparm to install if required
  • use sudo systemctl daemon-reload after modifying or creating a new systemd service to update systemd configuration
  • use sudo systemctl status hdparm.service to see status of service and enable if required.

idle3-tools

idle3-tools provides a linux/unix utility that can disable, get and set the value of the infamous idle3 timer found on recent Western Digital Hard Disk Drives.

References

/app/www/public/data/pages/home_server/home_server_setup/other_services/disk.txt · Last modified: 2025-09-14 Sun wk37 15:54
CC Attribution-Share Alike 4.0 International Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International