User Tools

Site Tools


devices-and-file-system

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
devices-and-file-system [2019/10/23 14:24]
Miroslav Bernát
devices-and-file-system [2020/05/26 22:51]
Miroslav Bernát
Line 10: Line 10:
 | **lsblk** (<​device/​partition>​) | prints information about all or specified block devices in a tree-like format (device name, major and minor number, whether or not the device is removable, size of the device, whether or not the device is read only, type of device and mount point), **-a** including empty devices, **-f** file system type, **-m** owner, group and permissions,​ **-p** full device paths, **-S** SCSI devices only, **-o** <​list>​ specifies information (columns) to be displayed, **-l** output in the form of a list\\ ''​$ lsblk -o NAME,​SIZE''​ | | **lsblk** (<​device/​partition>​) | prints information about all or specified block devices in a tree-like format (device name, major and minor number, whether or not the device is removable, size of the device, whether or not the device is read only, type of device and mount point), **-a** including empty devices, **-f** file system type, **-m** owner, group and permissions,​ **-p** full device paths, **-S** SCSI devices only, **-o** <​list>​ specifies information (columns) to be displayed, **-l** output in the form of a list\\ ''​$ lsblk -o NAME,​SIZE''​ |
 | **blkid** (<​partition/​LV>​) | prints attributes of all or specified block devices (UUID, LABEL, TYPE), **-L** <​LABEL>​ prints a partition that uses the specified LABEL, **-U** <​UUID>​ prints a partition that uses the specified UUID | | **blkid** (<​partition/​LV>​) | prints attributes of all or specified block devices (UUID, LABEL, TYPE), **-L** <​LABEL>​ prints a partition that uses the specified LABEL, **-U** <​UUID>​ prints a partition that uses the specified UUID |
 +| **multipath** (<​device>​) | detects multiple paths to remote devices, **-ll** prints the current multipath topology, **-f** removes a multipath unused device map specified as a parameter, **-F** removes all unused multipath device maps |
 | **lsof** (<​file/​device>​) | prints information about all or specified open files/​devices – their name, the program that uses the file/​device,​ PID, user name, file descriptor, file type, major and minor number of the device, file size in B and the i-node number, **-l** prints UID, **-p** <PID> by specified process, **-u** <​user>​ by specified user, **-r** <n> refreshes the list every //n// seconds\\ ''​$ lsof /​dev/​cdrom''​\\ ''​$ lsof /​dev/​snd/​*''​\\ ''​$ lsof -p $$''​\\ (prints open files from the current shell) | | **lsof** (<​file/​device>​) | prints information about all or specified open files/​devices – their name, the program that uses the file/​device,​ PID, user name, file descriptor, file type, major and minor number of the device, file size in B and the i-node number, **-l** prints UID, **-p** <PID> by specified process, **-u** <​user>​ by specified user, **-r** <n> refreshes the list every //n// seconds\\ ''​$ lsof /​dev/​cdrom''​\\ ''​$ lsof /​dev/​snd/​*''​\\ ''​$ lsof -p $$''​\\ (prints open files from the current shell) |
 | **iotop** | displays I/O disk usage, the speed of read and written data and a detailed, interactive list of all running processes in the system (the output changes according to the current state), **-o** active processes only, **-u** <​user>​ processes of a specified user, **-p** <PID> a specified process only, **q** quits the program | | **iotop** | displays I/O disk usage, the speed of read and written data and a detailed, interactive list of all running processes in the system (the output changes according to the current state), **-o** active processes only, **-u** <​user>​ processes of a specified user, **-p** <PID> a specified process only, **q** quits the program |
Line 26: Line 27:
 ^ FILE SYSTEM & SWAP ^ ^ ^ FILE SYSTEM & SWAP ^ ^
 | **cat /​proc/​partitions** | displays partitions, the number of physical disk blocks contained in the particular partition and the major and minor numbers of the devices | | **cat /​proc/​partitions** | displays partitions, the number of physical disk blocks contained in the particular partition and the major and minor numbers of the devices |
-| **fdisk** <​device/​partition>​ | prints the number of cylinders on a disk and with the option **m** displays a menu for working with the partition table: **p** prints the partition table, **n** creates a new partition, **l** prints all available types of partitions, **t** sets the type of partition, **d** removes a partition, **q** quits the program, **w** writes changes to the disk and quits the program; **-l** lists the partition table for the specified device, if no device is specified, all mounted ​devices are used\\ ''#​ fdisk -l /​dev/​sdb''​ |+| **fdisk** <​device/​partition>​ | prints the number of cylinders on a disk and with the option **m** displays a menu for working with the partition table: **p** prints the partition table, **n** creates a new partition, **l** prints all available types of partitions, **t** sets the type of partition, **d** removes a partition, **q** quits the program, **w** writes changes to the disk and quits the program; **-l** lists the partition table for the specified device, if not specified, ​lists the partition tables for all currently ​mounted ​disks\\ ''#​ fdisk -l /​dev/​sdb''​ |
 | **parted** <​device>​ (<​command>​) | creates/​deletes disk partitions or changes their types, **print** displays the partition table, **unit** specifies units to be diplayed (e.g. "​s",​ "​B",​ "​kB",​ "​MB",​ "​MiB",​ "​GB",​ "​GiB",​ "​TB",​ "​TiB"​),​ **mklabel** creates a new disk label (e.g. "​msdos"​ or "​gpt"​),​ **mkpart** <​partition_type / partition_name>​ <​FS_type>​ <​start>​ <end> creates a new partition, **rm** <n> deletes a partition of the specified number, **select** <​device>​ selects a device to use, **set** <n> <​flag>​ <​state>​ sets the state of the flag on the partition of the specified number, **quit** quits the program; if no command is specified, it works interactively\\ ''#​ parted /dev/vda print''​\\ (displays the partition table on the /dev/vda disk)\\ ''#​ parted /dev/vda unit s print''​\\ (displays the partition table size in sectors)\\ ''#​ parted /dev/vdb mklabel msdos''​\\ (writes an MBR disk label to a disk)\\ ''#​ parted /dev/vdb mkpart primary xfs 2048s 1001MB''​\\ (creates a primary partition that is 1000 MB in size)\\ ''#​ parted /dev/vdc mklabel gpt''​\\ (writes a GPT disk label to a disk)\\ ''#​ parted /dev/vdc mkpart primary 1MiB 1001MiB; parted /dev/vdc set 1 lvm on''​\\ (creates a 1000 MiB partition with type Linux LVM)\\ ''#​ parted /dev/vdc mkpart swap1 linux-swap 1001MiB 1501MiB''​\\ (creates a swap partition named "​swap1"​) | | **parted** <​device>​ (<​command>​) | creates/​deletes disk partitions or changes their types, **print** displays the partition table, **unit** specifies units to be diplayed (e.g. "​s",​ "​B",​ "​kB",​ "​MB",​ "​MiB",​ "​GB",​ "​GiB",​ "​TB",​ "​TiB"​),​ **mklabel** creates a new disk label (e.g. "​msdos"​ or "​gpt"​),​ **mkpart** <​partition_type / partition_name>​ <​FS_type>​ <​start>​ <end> creates a new partition, **rm** <n> deletes a partition of the specified number, **select** <​device>​ selects a device to use, **set** <n> <​flag>​ <​state>​ sets the state of the flag on the partition of the specified number, **quit** quits the program; if no command is specified, it works interactively\\ ''#​ parted /dev/vda print''​\\ (displays the partition table on the /dev/vda disk)\\ ''#​ parted /dev/vda unit s print''​\\ (displays the partition table size in sectors)\\ ''#​ parted /dev/vdb mklabel msdos''​\\ (writes an MBR disk label to a disk)\\ ''#​ parted /dev/vdb mkpart primary xfs 2048s 1001MB''​\\ (creates a primary partition that is 1000 MB in size)\\ ''#​ parted /dev/vdc mklabel gpt''​\\ (writes a GPT disk label to a disk)\\ ''#​ parted /dev/vdc mkpart primary 1MiB 1001MiB; parted /dev/vdc set 1 lvm on''​\\ (creates a 1000 MiB partition with type Linux LVM)\\ ''#​ parted /dev/vdc mkpart swap1 linux-swap 1001MiB 1501MiB''​\\ (creates a swap partition named "​swap1"​) |
 | **partprobe** | informs the OS of partition table changes, **-s** prints a summary of devices and their partitions | | **partprobe** | informs the OS of partition table changes, **-s** prints a summary of devices and their partitions |
Line 48: Line 49:
 | **cat /​etc/​fstab** | lists defined file systems – a device/​partition name or UUID, mount point, FS type, mount options (see „mount“ command), backup by „dump“ program („0“ = no, „1“ = yes) and check order of the FS by „fsck“ program at the system startup („0“ = no check, „1“ = first order (for FS „/“), „2“–„9“ other orders) | | **cat /​etc/​fstab** | lists defined file systems – a device/​partition name or UUID, mount point, FS type, mount options (see „mount“ command), backup by „dump“ program („0“ = no, „1“ = yes) and check order of the FS by „fsck“ program at the system startup („0“ = no check, „1“ = first order (for FS „/“), „2“–„9“ other orders) |
 | **cat /etc/mtab** / **cat /​proc/​mounts** | lists currently mounted file systems | | **cat /etc/mtab** / **cat /​proc/​mounts** | lists currently mounted file systems |
-| **df** (<​directory/​partition>​) | prints capacity usage information for all currently mounted file systems or a specified FS/​partition in kB, **-m** in MB, **-i** lists inode information instead of block usage, **-h** well-arranged output, **-l** only local FS, **-T** prints the type of all FS, **-t** <SS> only FS of the specified type, **-P** uses the POSIX output format\\ ''​$ df -P | awk '+$5 >= 90 {print}'''​\\ (prints FS usage equal to or greater than 90 %) |+| **df** (<​directory/​partition/LV>) | prints capacity usage information for all currently mounted file systems or a specified FS/​partition in kB, **-m** in MB, **-i** lists inode information instead of block usage, **-h** well-arranged output, **-l** only local FS, **-T** prints the type of all FS, **-t** <SS> only FS of the specified type, **-P** uses the POSIX output format\\ ''​$ df -P | awk '+$5 >= 90 {print}'''​\\ (prints FS usage equal to or greater than 90 %) |
 | **mkswap** <​partition/​LV>​ | creates a swap space for virtual memory, **-L** <​volume_label>​ sets a volume label | | **mkswap** <​partition/​LV>​ | creates a swap space for virtual memory, **-L** <​volume_label>​ sets a volume label |
 | **swapon** <​partition/​LV>​ | activates a swap space (to ensure permanent activation, the swap partition must be specified in ///​etc/​fstab//​ with „auto“ option), **-a** activates all swap partitions specified in ///​etc/​fstab//,​ **-s** displays active swap partitions (data from ///​proc/​swaps//​),​ **-v** detailed output (partition name, size, usage and priority) | | **swapon** <​partition/​LV>​ | activates a swap space (to ensure permanent activation, the swap partition must be specified in ///​etc/​fstab//​ with „auto“ option), **-a** activates all swap partitions specified in ///​etc/​fstab//,​ **-s** displays active swap partitions (data from ///​proc/​swaps//​),​ **-v** detailed output (partition name, size, usage and priority) |
Line 67: Line 68:
 | **photorec** | recovers lost data from a HDD or portable media of various types of FS; it works interactively and automatically detects the FS, a particular data format can also be recovered | | **photorec** | recovers lost data from a HDD or portable media of various types of FS; it works interactively and automatically detects the FS, a particular data format can also be recovered |
 \\ \\
-LVM (Logical Volume Manager) ^ dynamic disk partition management ​+^ Logical Volume Manager ​(LVM) ^ Virtualization And Dynamic Management of Disk Partitions ​^ 
-| **pvcreate** <PV> | initializes a PV (physical ​disk or partition) ​for use by LVM\\ ''#​ pvcreate /​dev/​sda4''​ |+| **Physical Volume (PV)** | **Physical Block Device Or Partition** | 
 +| **pvcreate** <PV> | initializes a physical ​volume ​for use by the LVM\\ ''#​ pvcreate /​dev/​sda4''​ |
 | **pvs** | prints information about all PVs in the system, their name, VG, attributes, size and free space | | **pvs** | prints information about all PVs in the system, their name, VG, attributes, size and free space |
 | **pvdisplay** (<​PV>​) | prints detailed information about all or specified PVs, **-m** displays the mapping of physical extents (PEs) to logical volumes (LVs) and logical extents (LEs) | | **pvdisplay** (<​PV>​) | prints detailed information about all or specified PVs, **-m** displays the mapping of physical extents (PEs) to logical volumes (LVs) and logical extents (LEs) |
Line 75: Line 77:
 | **pvmove** <​source_PV>​ (<​target_PV>​) | moves data from one PV to another, if the target PV is not specified, data are moved to any free space within the particular VG | | **pvmove** <​source_PV>​ (<​target_PV>​) | moves data from one PV to another, if the target PV is not specified, data are moved to any free space within the particular VG |
 | **pvremove** <PV> | removes a PV from use by LVM | | **pvremove** <PV> | removes a PV from use by LVM |
-| **vgcreate** <VG> <PV> | creates a VG (virtual disk) using PVs previously configured for LVM, **-s** <​size>​ sets the physical extent size on PVs of this VG (4MB by default)\\ ''#​ vgcreate root_vg /dev/sda1 /dev/sda2 /​dev/​sda3''​ |+| **Volume Group (VG)** | **Storage Pool from One Or More Physical Volumes** | 
 +| **vgcreate** <VG> <PV> | creates a volume group using PVs previously configured for LVM, **-s** <​size>​ sets the physical extent size on PVs of this VG (4MB by default)\\ ''#​ vgcreate root_vg /dev/sda1 /dev/sda2 /​dev/​sda3''​ |
 | **vgs** | prints information about all VGs in the system, their name, number of PVs/LVs, number of copies, size and free space | | **vgs** | prints information about all VGs in the system, their name, number of PVs/LVs, number of copies, size and free space |
 | **vgdisplay** (<​VG>​) | prints detailed information about all or specified VGs, **-v** including all the contained PVs and LVs | | **vgdisplay** (<​VG>​) | prints detailed information about all or specified VGs, **-v** including all the contained PVs and LVs |
Line 85: Line 88:
 | **vgimport** <VG> | imports a VG (makes exported VGs known to the system) | | **vgimport** <VG> | imports a VG (makes exported VGs known to the system) |
 | **vgremove** <VG> | removes a VG | | **vgremove** <VG> | removes a VG |
-| **lvcreate** <LV> <VG> | creates ​an LV (virtual partition), **-n** <LV> sets an LV name, **-L** <​size>​ sets an LV size, **-l** <n> sets an LV size by allocating the number of logical extents, **-m** <n> sets a number of LV copies (creates a mirror of a linear LV), **-p** <​**r**/​**w**>​ sets read / read and write permissions\\ ''#​ lvcreate -n web_lv -L 10G datavg''​ |+| **vgcfgrestore** <VG> | restores a volume group metadata from the last backup, **-l** prints a list of all archived metadata (archive files) for a volume group, **-f** <​archive_file>​ restores a volume group configuration from the specified file\\ ''#​ vgcfgrestore -f /​etc/​lvm/​archive/​vg00_00031-1442492648.vg vg00''​ | 
 +| **Logical Volume (LV)** | **Virtual Disk Partition** | 
 +| **lvcreate** <LV> <VG> | creates ​a logical volume, **-n** <LV> sets an LV name, **-L** <​size>​ sets an LV size, **-l** <n> sets an LV size by allocating the number of logical extents, **-m** <n> sets a number of LV copies (creates a mirror of a linear LV), **-p** <​**r**/​**w**>​ sets read / read and write permissions\\ ''#​ lvcreate -n web_lv -L 10G datavg''​ |
 | **lvs** | prints information about all LVs in the system, their name, VG, attributes, size and other information | | **lvs** | prints information about all LVs in the system, their name, VG, attributes, size and other information |
-| **lvdisplay** (<​LV/​VG>​) |  prints detailed information about all or specified LVs or all LVs on the specified VG, **-m** displays the mapping of logical extents (LEs) to physical volumes (PVs) and physical extents (PEs) and the type of LV (linear, mirrored, snapshot) | +| **lvdisplay** (<VG/LV<VG>) |  prints detailed information about all or specified LVs or all LVs on the specified VG, **-m** displays the mapping of logical extents (LEs) to physical volumes (PVs) and physical extents (PEs) and the type of LV (linear, mirrored, snapshot) | 
-| **lvchange** <LV> | changes attributes of an LV, **-p** <​**r**/​**w**>​ sets read / read and write permissions,​ **-a** <​**y**/​**n**>​ activates/​deactivates the LV\\ ''#​ lvchange -a n datavg/​web_lv''​ | +| **lvchange** <VG/LV> | changes attributes of an LV, **-p** <​**r**/​**w**>​ sets read / read and write permissions,​ **-a** <​**y**/​**n**>​ activates/​deactivates the LV\\ ''#​ lvchange -a n datavg/​web_lv''​ | 
-| **lvrename** ​ <old_LV> <new_LV> | renames an LV\\ ''#​ lvrename datavg/​web_lv datavg/​weblv''​ | +| **lvrename** ​ <old_VG/LV> <new_VG/LV> | renames an LV\\ ''#​ lvrename datavg/​web_lv datavg/​weblv''​ | 
-| **lvresize** <LV> | changes an LV size, **-L** (**+**/​**-**)<​size>​ sets, enlarges or shrinks an LV size to the required value in MB (M), GB (G), TB (T), PB (P), EB (E), **-l** <n> sets an LV size by allocating the number of logical extents (if the FS spreads over the whole LV and is needed to be enlarged, the underlying LV must be expanded first; if the LV is to be shrunk, it must be unmounted first, checked by „fsck“ program, the FS size must be reduced first and then the LV size can be finally shrunk, but it must not be smaller than the new size of the FS), **-r** resizes the underlying file system\\ ''#​ lvresize -rL +200M vg00/​rootlv''​\\ ''#​ lvresize -l +100%FREE /​dev/​VolGroup00/​LogVol00''​\\ (extends the LV to occupy the remaining free space in the VG) | +| **lvresize** <VG/LV> | changes an LV size, **-L** (**+**/​**-**)<​size>​ sets, enlarges or shrinks an LV size to the required value in MB (M), GB (G), TB (T), PB (P), EB (E), **-l** <n> sets an LV size by allocating the number of logical extents (if the FS spreads over the whole LV and is needed to be enlarged, the underlying LV must be expanded first; if the LV is to be shrunk, it must be unmounted first, checked by „fsck“ program, the FS size must be reduced first and then the LV size can be finally shrunk, but it must not be smaller than the new size of the FS), **-r** resizes the underlying file system\\ ''#​ lvresize -rL +200M vg00/​rootlv''​\\ ''#​ lvresize -l +100%FREE /​dev/​VolGroup00/​LogVol00''​\\ (extends the LV to occupy the remaining free space in the VG) | 
-| **lvconvert** <LV> | changes the type of LV, **-m** <n> sets a number of LV copies (creates a mirror of a linear LV), **-s** <​source_LV>​ <​target_LV>​ creates a snapshot of an LV\\ ''#​ lvconvert -s vg00/lvol1 vg00/​lvol2''​ | +| **lvconvert** <VG/LV> | changes the type of LV, **-m** <n> sets a number of LV copies (creates a mirror of a linear LV), **-s** <​source_LV>​ <​target_LV>​ creates a snapshot of an LV\\ ''#​ lvconvert -s vg00/lvol1 vg00/​lvol2''​ | 
-| **lvremove** <LV> | removes an LV |+| **lvremove** <VG/LV> / <VG> | removes an LV / all LV on a specified VG |
 \\ \\
 ^ ADVANCED STORAGE FEATURES ^ ^ ^ ADVANCED STORAGE FEATURES ^ ^