In Linux system, it is a important task for system administrator to well organize their disks. Here are some commonly used operations:
Partitioning: Create an area of fixed (or variable) volume (partition) on free disk space to store data;
Delete: Remove existing partition(s);
- Mount: Load a device or disk partition on existing directory for using.
Using graphical interface
Users can utilize software named Gparted to manage their disks.
View disk information
df to display information about disk.
df ## List disk usage of each file system df -ia ## List inode usage of each file system df -T ## List types of file system
du to estimate the usage of specified file system
du -h --max-depth=1 ## Show the size of each subdirectory under current directory, as well as the total size of current directory du -h --max-depth=1 work/testing ## Show the size of directory"work/testing" du -h --max-depth=1 work/testing/* ## Show sizes of each file and subdirectory under directory "work/testing" du -ha ## Show sizes of each subdirectory and file recursively
fdisk for partitioning.
fdisk -l ## List disks and their partitions
mkfs to format disk or partition
mfks -t ext3 /dev/sda6 ## Format partition "/dev/sda6" as ext3 mkfs -t ext2 /dev/sdb7 ## Format partition "/dev/sdb7" as ext2
fsck to check and fix possible errors on disk.
fsck -t msdos -a /dev/hda5 ## Check msdos partition "/dev/sda5", and repaire it if it has error
badblocks to check bad sector on disk
badblocks -[svw] Disk
-s : Show progress on screen -v : Show more details during check -w : Also do writing test. Do not use this option when you have data on the disk!
sync to synchronize data between RAM and external storage device
sync # Write unsynchronized data in memory to hard disk
dd to copy or convert file
sudo dd if=/home/cxbii/deepin.iso of=/dev/sdb bs=8M conv=fsync # Write file "/home/cxbii/deepin.iso" to device "/dev/sdb"
Disk quota is used to limit the usage of disk space by users, so that the whole system does not malfunction when disk space runs out.
Types of disk quota:
Soft limit: When disk usage goes beyond soft limit, system will generate a warning, but still allow using of disk.
- Hard limit: The actual boundary of disk usage. When hard limit is passed, system does not allow user to increase their data size anymore.
Disk quota can be turned on or off manually.