Disks and filesystems: Difference between revisions

From wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:Linux/Unix]]
;badblocks -v- s /dev/sdb >badblocks.log
;badblocks -v- s /dev/sdb >badblocks.log
:Check a device for bad blocks
:Check a device for bad blocks


;fdisk /dev/sdb
;fdisk /dev/sdb  # Deprecated
:Manage disk partitions
;gdisk /dev/sdb
:Manage disk (GPT) partitions


;df -h
;df -h
Line 10: Line 13:
;df -i
;df -i
:Show filesystem inode usage
:Show filesystem inode usage
;df -P
:Report file-system information in parseble format.
;du -shx *
:Report disk usage for all files and directories in the current directory. Do not count files on other filesystems (-x) and do not follow symbolic links (default)


;ls -i <file>
;ls -i <file>
:Show inode of <file>
:Show inode of <file>


;rm -i <file>
;stat <file>
:Remove a file by its inode
:Show about all there is to know about <file>
 
;getfacl <file>
:Show the Access Control List (ACL) information for a file or directory
 
;setfacl -m <nowiki>u:<username>:<perm> <file></nowiki>
:Add <perm> for <username> to <file>
;setfacl -d -m <nowiki>u:<username>:<perm> <dir></nowiki>
:-d makes that all files in <dir> will get the <username>:<perm> added to the ACL


;mount -t <fstype> -o <options> <devicefile> <mountpoint>  
;mount -t <fstype> -o <options> <devicefile> <mountpoint>  
:Mount a filesystem (fstype and options can be omitted often)
:Mount a filesystem (fstype and options can be omitted often)


;mount -a
:Mount all filesystems in [[#fstab|/etc/fstab]] with the <code>auto</code> option.
;mount -o loop /path/to/my-iso-image.iso /mnt/iso
;mount -o loop /path/to/my-iso-image.iso /mnt/iso
:Mount an .iso file  
:Mount an .iso file  


==fstab==
Configuration file to store mounts. Example for NFS mounts:
;<code><host>:<path> <mountpoint>   nfs   defaults   0      0</code>
:Enable mount by; <code>mount <mountpoint></code>
:Mount the <path> exported by <host> on directory <mountpoint> using the NFS protocol with default setting (see below), do not automatically backup when dump is executed and do not fsck when mounted at boot time.
;<code><host>:<path> <mountpoint>   nfs   defaults,noauto   0      0</code>
:Same as above but do not mount at boot-time
Defaults (specified by defaults) are for ext3 filesystems: rw,suid,dev,exec,auto,nouser,async (read/write, set userID, dev?, allow execution of executables, mount during boot and when <code>mount -a</code> is done,  only root can mount this, do not wait for the host to have written to storage)
See the [https://en.wikipedia.org/wiki/Fstab fstab wikipedia page] for more.


==Performance==
==Performance==
The graphical utility '''Disks''' has a benchmark option.
The graphical utility '''Disks''' has a benchmark option.


;dd if=/dev/zero of=./test.tmp bs=1G count=1 oflag=dsync;rm -f ./test.tmp
:Check plain write speed
;dd if=/dev/zero of=./test.tmp bs=512 count=1000 oflag=dsync;rm -f ./test.tmp
:Latency test
On an empty disk you can do:
;dd if=/dev/zero of=/dev/sdb bs=8k count=10k
;dd if=/dev/zero of=/dev/sdb bs=8k count=10k
:Test disk write speed if no filesystems exists
:Test disk write speed if no filesystem exists
 
;dd if=/dev/zero of=/tmp/output bs=8k count=10k; rm -f /tmp/output
:Test disk write speed on existing filesystems


==Misc==
==Misc==

Latest revision as of 10:23, 10 March 2026


badblocks -v- s /dev/sdb >badblocks.log
Check a device for bad blocks
fdisk /dev/sdb # Deprecated
gdisk /dev/sdb
Manage disk (GPT) partitions
df -h
Show filesystem block usage in human friendly format
df -i
Show filesystem inode usage
df -P
Report file-system information in parseble format.
du -shx *
Report disk usage for all files and directories in the current directory. Do not count files on other filesystems (-x) and do not follow symbolic links (default)
ls -i <file>
Show inode of <file>
stat <file>
Show about all there is to know about <file>
getfacl <file>
Show the Access Control List (ACL) information for a file or directory
setfacl -m u:<username>:<perm> <file>
Add <perm> for <username> to <file>
setfacl -d -m u:<username>:<perm> <dir>
-d makes that all files in <dir> will get the <username>:<perm> added to the ACL
mount -t <fstype> -o <options> <devicefile> <mountpoint>
Mount a filesystem (fstype and options can be omitted often)
mount -a
Mount all filesystems in /etc/fstab with the auto option.
mount -o loop /path/to/my-iso-image.iso /mnt/iso
Mount an .iso file

fstab

Configuration file to store mounts. Example for NFS mounts:

<host>:<path> <mountpoint> nfs defaults 0 0
Enable mount by; mount <mountpoint>
Mount the <path> exported by <host> on directory <mountpoint> using the NFS protocol with default setting (see below), do not automatically backup when dump is executed and do not fsck when mounted at boot time.
<host>:<path> <mountpoint> nfs defaults,noauto 0 0
Same as above but do not mount at boot-time

Defaults (specified by defaults) are for ext3 filesystems: rw,suid,dev,exec,auto,nouser,async (read/write, set userID, dev?, allow execution of executables, mount during boot and when mount -a is done, only root can mount this, do not wait for the host to have written to storage)

See the fstab wikipedia page for more.

Performance

The graphical utility Disks has a benchmark option.

dd if=/dev/zero of=./test.tmp bs=1G count=1 oflag=dsync;rm -f ./test.tmp
Check plain write speed
dd if=/dev/zero of=./test.tmp bs=512 count=1000 oflag=dsync;rm -f ./test.tmp
Latency test

On an empty disk you can do:

dd if=/dev/zero of=/dev/sdb bs=8k count=10k
Test disk write speed if no filesystem exists

Misc

/dev/null
The unix black hole. Write always succeeds with no effect at all.
/dev/zero
Provides an unlimited amount of null characters (ASCII 0). Can be used for cleaning disks or benchmarking (see #Performance)
Writing to /dev/zero is the same as writing to /dev/null