{"id":23140910,"url":"https://github.com/onder7/disk-management-in-linux-unix-systems","last_synced_at":"2025-04-04T11:18:44.647Z","repository":{"id":265436075,"uuid":"895995936","full_name":"onder7/Disk-management-in-Linux-Unix-systems","owner":"onder7","description":"Disk management in Linux/Unix systems","archived":false,"fork":false,"pushed_at":"2024-11-29T10:39:31.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-09T21:14:48.708Z","etag":null,"topics":["disk-management","disk-space","linux","unix-systems"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/onder7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-29T10:38:25.000Z","updated_at":"2024-11-30T19:15:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"e5a3409d-246f-4e97-ae41-d0e69468c892","html_url":"https://github.com/onder7/Disk-management-in-Linux-Unix-systems","commit_stats":null,"previous_names":["onder7/disk-management-in-linux-unix-systems"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onder7%2FDisk-management-in-Linux-Unix-systems","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onder7%2FDisk-management-in-Linux-Unix-systems/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onder7%2FDisk-management-in-Linux-Unix-systems/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onder7%2FDisk-management-in-Linux-Unix-systems/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onder7","download_url":"https://codeload.github.com/onder7/Disk-management-in-Linux-Unix-systems/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247166171,"owners_count":20894654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["disk-management","disk-space","linux","unix-systems"],"created_at":"2024-12-17T14:11:59.032Z","updated_at":"2025-04-04T11:18:44.629Z","avatar_url":"https://github.com/onder7.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Disk Management and Essential Commands in Linux/Unix Systems\n\nDisk management in Linux and Unix systems is one of the most fundamental responsibilities of system administrators. In this article, we will examine in detail the basic commands used in disk management and their purposes.\n\n## 1. Disk Usage Monitoring Commands\n\n### df (Disk Free)\nThe `df` command shows the usage status of file systems.\n- `df -h`: Shows in human-readable format (GB, MB)\n- `df -i`: Shows inode usage\n- `df -T`: Shows filesystem type\n- `df -l`: Shows only local filesystems\n\n### du (Disk Usage)\nThe `du` command shows disk usage of directories and files.\n- `du -h`: Shows in human-readable format\n- `du -s`: Shows only the total size\n- `du -a`: Shows all files\n- `du -c`: Shows the grand total at the end\n\n## 2. Disk Partitioning Commands\n\n### fdisk\nClassic disk partitioning tool:\n- `fdisk -l`: Lists all disks and their partitions\n- `fdisk /dev/sda`: Opens specified disk for partitioning\n\n### parted\nModern disk partitioning tool:\n- `parted -l`: Lists all disks and their partitions\n- `parted /dev/sda print`: Shows partitions of a specific disk\n- `parted /dev/sda mkpart`: Creates new partition\n\n### gparted\nGraphical disk partitioning tool:\n- `gparted`: Launches the graphical interface\n\n## 3. Filesystem Management\n\n### mkfs (Make Filesystem)\nCreating filesystems:\n- `mkfs.ext4 /dev/sda1`: Creates ext4 filesystem\n- `mkfs.xfs /dev/sda2`: Creates XFS filesystem\n- `mkfs.btrfs /dev/sda3`: Creates BTRFS filesystem\n\n### mount/umount\nMounting and unmounting disk partitions:\n- `mount /dev/sda1 /mnt`: Mounts the disk\n- `umount /mnt`: Unmounts the disk\n- `mount -a`: Mounts all disks in fstab\n\n## 4. Disk Health and Performance\n\n### smartctl\nChecking disk health:\n- `smartctl -a /dev/sda`: Shows detailed disk information\n- `smartctl -H /dev/sda`: Shows disk health status\n\n### iostat\nDisk I/O statistics:\n- `iostat -x 1`: Shows disk performance metrics every second\n- `iostat -m`: Shows statistics in MB\n\n### fio\nDisk performance testing:\n- `fio --filename=/dev/sda --direct=1 --rw=randread`: Random read test\n- `fio --filename=/dev/sda --direct=1 --rw=randwrite`: Random write test\n\n## 5. Disk Issues and Solutions\n\n### fsck (Filesystem Check)\nFilesystem check and repair:\n- `fsck /dev/sda1`: Checks filesystem\n- `fsck -f /dev/sda1`: Forces check\n- `fsck -y /dev/sda1`: Automatically answers \"yes\" to all questions\n\n### badblocks\nBad sector checking:\n- `badblocks -v /dev/sda1`: Checks for bad sectors\n- `badblocks -w /dev/sda1`: Checks with write test (destructive)\n\n## 6. LVM (Logical Volume Management)\n\n### pvs/vgs/lvs\nListing LVM components:\n- `pvs`: Shows physical volumes\n- `vgs`: Shows volume groups\n- `lvs`: Shows logical volumes\n\n### pvcreate/vgcreate/lvcreate\nCreating LVM components:\n- `pvcreate /dev/sda1`: Creates physical volume\n- `vgcreate vg0 /dev/sda1`: Creates volume group\n- `lvcreate -L 10G vg0`: Creates 10GB logical volume\n\n## Best Practices\n\n1. **Regular Monitoring**: Monitor disk usage regularly\n2. **Backup**: Always backup before important disk operations\n3. **Performance Optimization**: Regularly check disk I/O performance\n4. **Automated Checks**: Automate disk health checks\n5. **Documentation**: Document disk configurations\n\n## Common Issues and Troubleshooting\n\n1. **Disk Space Issues**\n   - Regular cleanup of temporary files\n   - Log rotation\n   - Identifying large files and directories\n\n2. **Performance Problems**\n   - Monitoring I/O wait times\n   - Checking for fragmentation\n   - Optimizing disk scheduling\n\n3. **Hardware Failures**\n   - Regular SMART checks\n   - Monitoring system logs\n   - Implementing RAID when necessary\n\n## Security Considerations\n\n1. **Access Control**\n   - Setting appropriate permissions\n   - Managing mount options\n   - Encrypting sensitive data\n\n2. **Audit Trail**\n   - Logging disk operations\n   - Monitoring file system changes\n   - Tracking user activities\n\n## Conclusion\n\nDisk management in Linux/Unix systems is critical for system stability and performance. Effective use of these commands and tools allows system administrators to quickly identify and resolve issues. Regular disk monitoring and maintenance increase system reliability and prevent data loss.\n\n## Additional Resources\n\n- Man pages for each command\n- Online Linux documentation\n- Community forums and support channels\n- Professional training materials\n\nRemember that proper disk management is essential for:\n- System performance\n- Data integrity\n- Resource optimization\n- System reliability\n- Disaster recovery\n\nAlways stay updated with the latest tools and best practices in disk management to maintain an efficient and reliable system.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonder7%2Fdisk-management-in-linux-unix-systems","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonder7%2Fdisk-management-in-linux-unix-systems","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonder7%2Fdisk-management-in-linux-unix-systems/lists"}