Table des matières
Version : 2021.01
Updated : 2021/11/01 15:52
LCE504 - Managing Disks and Filesystems
Contents
- LCE504 - Managing Disks and Filesystems
- Contents
- Peripherals
- Partitions
- Partitioning
- LAB #1 - Partioning your Disk with the fdisk Command
- LAB #2 - Modifier les Drapeaux des Partitions avec fdisk
- Logical Volume Manager (LVM)
- LAB #3 - Linear Logical Volumes
- Physical Volumes (PV)
- Volume Groups (VG) and Physical Extents (PE)
- Logical Volumes (LV)
- LAB #4 - Grow a Volume
- LAB #5 - Snapshots
- LAB #6 - Deleting Volumes
- LAB #7 - Mirrored Volumes
- LAB #8 - Changing LVM Attributes
- LAB #9 - Striped Volumes
- LAB #10 - Managing Meta-data
- Journaled Filesystems
- Ext3
- Managing Ext3
- LAB #11 - Converting Ext3 to Ext2
- LAB #12 - Converting Ext2 to Ext3
- LAB #13 - Using another PArtition for the Journal
- LAB #14 - Changing the File System Check interval on an ext3 Filesystem
- Ext4
- LAB #15 - Creating an Ext4 Filesystem
- LAB #16 - Adding a Label to an Ext4 Filesystem
- LAB #17 - Converting Ext3 to Ext4
- XFS
- LAB #18 - Creating an XFS Filesystem
- LAB #19 - Adding a Label to an XFS Filesystem
Peripherals
- hd[a-d]
- IDE and ATAPI
- sd[a-z]
- SCSI and SATA
- mmcblk[0-7]
- SD/MMC
- scd[0-7]
- SCSI CDRoms
- xd[a-d]
- IBM XT disks
- fd[0-7]
- Diskettes
- st[0-7]
- SCSI/SATA streamers that can rewind
- nst[0-7]
- SCSI/SATA streamers that cannot rewind
- ht[0-7]
- PATA streamers that can rewind
- nht[0-7]
- PATA streamers that cannot rewind
- rmt8, rmt16, tape-d, tape-reset
- QIC-80
- ram[0-15]
- Virtual disks
- Périphériques loop
- Used to access a filesystem in a file
- md[x]
- MetaDevice - Software RAID
- vg[x]
- Volume Group
- lv[x]
- Logical Volume
Partitions
The number of partitions is limited :
- IDE,
- Up to 63,
- SCSI,
- Up to 15,
- Disks using the API libata,
- Up to 15.
Partitioning
LAB #1 - Partioning your Disk with the fdisk Command
[root@centos8 ~]# fdisk /dev/sdb Welcome to fdisk (util-linux 2.32.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table. Created a new DOS disklabel with disk identifier 0xb0dacb39. Command (m for help):
Command (m for help): m Help: DOS (MBR) a toggle a bootable flag b edit nested BSD disklabel c toggle the dos compatibility flag Generic d delete a partition F list free unpartitioned space l list known partition types n add a new partition p print the partition table t change a partition type v verify the partition table i print information about a partition Misc m print this menu u change display/entry units x extra functionality (experts only) Script I load disk layout from sfdisk script file O dump disk layout to sfdisk script file Save & Exit w write table to disk and exit q quit without saving changes Create a new label g create a new empty GPT partition table G create a new empty SGI (IRIX) partition table o create a new empty DOS partition table s create a new empty Sun partition table Command (m for help):
Create the following partitions:
Partition | Type | Size |
---|---|---|
/dev/sdb1 | Primary | 100 MB |
/dev/sdb2 | Primary | 100 MB |
/dev/sdb3 | Primary | 100 MB |
/dev/sdb4 | Extended | From the first available to the last available sectors |
/dev/sdb5 | Logical | 500 MB |
/dev/sdb6 | Logical | 200 MB |
/dev/sdb7 | Logical | 300 MB |
/dev/sda8 | Logical | 500 MB |
/dev/sdb9 | Logical | 400 MB |
/dev/sdb10 | Logical | 500 MB |
/dev/sdb11 | Logical | 500 MB |
/dev/sdb12 | Logical | 200 MB |
Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): Using default response p. Partition number (1-4, default 1): First sector (2048-8388607, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-8388607, default 8388607): +100M Created a new partition 1 of type 'Linux' and of size 100 MiB. Command (m for help): n Partition type p primary (1 primary, 0 extended, 3 free) e extended (container for logical partitions) Select (default p): Using default response p. Partition number (2-4, default 2): First sector (206848-8388607, default 206848): Last sector, +sectors or +size{K,M,G,T,P} (206848-8388607, default 8388607): +100M Created a new partition 2 of type 'Linux' and of size 100 MiB. Command (m for help): n Partition type p primary (2 primary, 0 extended, 2 free) e extended (container for logical partitions) Select (default p): Using default response p. Partition number (3,4, default 3): First sector (411648-8388607, default 411648): Last sector, +sectors or +size{K,M,G,T,P} (411648-8388607, default 8388607): +100M Created a new partition 3 of type 'Linux' and of size 100 MiB. Command (m for help):
Command (m for help): n Partition type p primary (3 primary, 0 extended, 1 free) e extended (container for logical partitions) Select (default e): e Selected partition 4 First sector (616448-8388607, default 616448): Last sector, +sectors or +size{K,M,G,T,P} (616448-8388607, default 8388607): Created a new partition 4 of type 'Extended' and of size 3.7 GiB. Command (m for help):
Command (m for help): n All primary partitions are in use. Adding logical partition 5 First sector (618496-8388607, default 618496): Last sector, +sectors or +size{K,M,G,T,P} (618496-8388607, default 8388607): +500M Created a new partition 5 of type 'Linux' and of size 500 MiB. Command (m for help): n All primary partitions are in use. Adding logical partition 6 First sector (1644544-8388607, default 1644544): Last sector, +sectors or +size{K,M,G,T,P} (1644544-8388607, default 8388607): +200M Created a new partition 6 of type 'Linux' and of size 200 MiB. Command (m for help): n All primary partitions are in use. Adding logical partition 7 First sector (2056192-8388607, default 2056192): Last sector, +sectors or +size{K,M,G,T,P} (2056192-8388607, default 8388607): +300M Created a new partition 7 of type 'Linux' and of size 300 MiB. Command (m for help): n All primary partitions are in use. Adding logical partition 8 First sector (2672640-8388607, default 2672640): Last sector, +sectors or +size{K,M,G,T,P} (2672640-8388607, default 8388607): +500M Created a new partition 8 of type 'Linux' and of size 500 MiB. Command (m for help): n All primary partitions are in use. Adding logical partition 9 First sector (3698688-8388607, default 3698688): Last sector, +sectors or +size{K,M,G,T,P} (3698688-8388607, default 8388607): +400M Created a new partition 9 of type 'Linux' and of size 400 MiB. Command (m for help): n All primary partitions are in use. Adding logical partition 10 First sector (4519936-8388607, default 4519936): Last sector, +sectors or +size{K,M,G,T,P} (4519936-8388607, default 8388607): +500M Created a new partition 10 of type 'Linux' and of size 500 MiB. Command (m for help): n All primary partitions are in use. Adding logical partition 11 First sector (5545984-8388607, default 5545984): Last sector, +sectors or +size{K,M,G,T,P} (5545984-8388607, default 8388607): +500M Created a new partition 11 of type 'Linux' and of size 500 MiB. Command (m for help): n All primary partitions are in use. Adding logical partition 12 First sector (6572032-8388607, default 6572032): Last sector, +sectors or +size{K,M,G,T,P} (6572032-8388607, default 8388607): +200M Created a new partition 12 of type 'Linux' and of size 200 MiB. Command (m for help):
Command (m for help): p Disk /dev/sdb: 4 GiB, 4294967296 bytes, 8388608 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xb0dacb39 Device Boot Start End Sectors Size Id Type /dev/sdb1 2048 206847 204800 100M 83 Linux /dev/sdb2 206848 411647 204800 100M 83 Linux /dev/sdb3 411648 616447 204800 100M 83 Linux /dev/sdb4 616448 8388607 7772160 3.7G 5 Extended /dev/sdb5 618496 1642495 1024000 500M 83 Linux /dev/sdb6 1644544 2054143 409600 200M 83 Linux /dev/sdb7 2056192 2670591 614400 300M 83 Linux /dev/sdb8 2672640 3696639 1024000 500M 83 Linux /dev/sdb9 3698688 4517887 819200 400M 83 Linux /dev/sdb10 4519936 5543935 1024000 500M 83 Linux /dev/sdb11 5545984 6569983 1024000 500M 83 Linux /dev/sdb12 6572032 6981631 409600 200M 83 Linux Command (m for help):
Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks. [root@centos8 ~]# partprobe [root@centos8 ~]#
[root@centos8 ~]# fdisk /dev/sdb Welcome to fdisk (util-linux 2.32.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p Disk /dev/sdb: 4 GiB, 4294967296 bytes, 8388608 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xb0dacb39 Device Boot Start End Sectors Size Id Type /dev/sdb1 2048 206847 204800 100M 83 Linux /dev/sdb2 206848 411647 204800 100M 83 Linux /dev/sdb3 411648 616447 204800 100M 83 Linux /dev/sdb4 616448 8388607 7772160 3.7G 5 Extended /dev/sdb5 618496 1642495 1024000 500M 83 Linux /dev/sdb6 1644544 2054143 409600 200M 83 Linux /dev/sdb7 2056192 2670591 614400 300M 83 Linux /dev/sdb8 2672640 3696639 1024000 500M 83 Linux /dev/sdb9 3698688 4517887 819200 400M 83 Linux /dev/sdb10 4519936 5543935 1024000 500M 83 Linux /dev/sdb11 5545984 6569983 1024000 500M 83 Linux /dev/sdb12 6572032 6981631 409600 200M 83 Linux Command (m for help):
Command (m for help): d Partition number (1-12, default 12): 12 Partition 12 has been deleted. Command (m for help): p Disk /dev/sdb: 4 GiB, 4294967296 bytes, 8388608 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xb0dacb39 Device Boot Start End Sectors Size Id Type /dev/sdb1 2048 206847 204800 100M 83 Linux /dev/sdb2 206848 411647 204800 100M 83 Linux /dev/sdb3 411648 616447 204800 100M 83 Linux /dev/sdb4 616448 8388607 7772160 3.7G 5 Extended /dev/sdb5 618496 1642495 1024000 500M 83 Linux /dev/sdb6 1644544 2054143 409600 200M 83 Linux /dev/sdb7 2056192 2670591 614400 300M 83 Linux /dev/sdb8 2672640 3696639 1024000 500M 83 Linux /dev/sdb9 3698688 4517887 819200 400M 83 Linux /dev/sdb10 4519936 5543935 1024000 500M 83 Linux /dev/sdb11 5545984 6569983 1024000 500M 83 Linux Command (m for help):
Command (m for help): q [root@centos8 ~]# fdisk /dev/sdb Welcome to fdisk (util-linux 2.32.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p Disk /dev/sdb: 4 GiB, 4294967296 bytes, 8388608 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xb0dacb39 Device Boot Start End Sectors Size Id Type /dev/sdb1 2048 206847 204800 100M 83 Linux /dev/sdb2 206848 411647 204800 100M 83 Linux /dev/sdb3 411648 616447 204800 100M 83 Linux /dev/sdb4 616448 8388607 7772160 3.7G 5 Extended /dev/sdb5 618496 1642495 1024000 500M 83 Linux /dev/sdb6 1644544 2054143 409600 200M 83 Linux /dev/sdb7 2056192 2670591 614400 300M 83 Linux /dev/sdb8 2672640 3696639 1024000 500M 83 Linux /dev/sdb9 3698688 4517887 819200 400M 83 Linux /dev/sdb10 4519936 5543935 1024000 500M 83 Linux /dev/sdb11 5545984 6569983 1024000 500M 83 Linux /dev/sdb12 6572032 6981631 409600 200M 83 Linux Command (m for help):
LAB #2 - Modifier les Drapeaux des Partitions avec fdisk
Size | Type |
---|---|
500 MB | RAID (fd) |
200 MB | Linux LVM (8e) |
300 MB | Linux LVM (8e) |
500 MB | RAID (fd) |
400 MB | Linux LVM (8e) |
500 MB | RAID (fd) |
500 MB | RAID (fd) |
200 MB | Do not change |
Command (m for help): t Partition number (1-12, default 12): 5 Hex code (type L to list all codes): fd Changed type of partition 'Linux' to 'Linux raid autodetect'. Command (m for help): t Partition number (1-12, default 12): 6 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM'. Command (m for help): t Partition number (1-12, default 12): 7 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM'. Command (m for help): t Partition number (1-12, default 12): 8 Hex code (type L to list all codes): fd Changed type of partition 'Linux' to 'Linux raid autodetect'. Command (m for help): t Partition number (1-12, default 12): 9 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM'. Command (m for help): t Partition number (1-12, default 12): 10 Hex code (type L to list all codes): fd Changed type of partition 'Linux' to 'Linux raid autodetect'. Command (m for help): t Partition number (1-12, default 12): 11 Hex code (type L to list all codes): fd Changed type of partition 'Linux' to 'Linux raid autodetect'.
Command (m for help): p Disk /dev/sdb: 4 GiB, 4294967296 bytes, 8388608 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xb0dacb39 Device Boot Start End Sectors Size Id Type /dev/sdb1 2048 206847 204800 100M 83 Linux /dev/sdb2 206848 411647 204800 100M 83 Linux /dev/sdb3 411648 616447 204800 100M 83 Linux /dev/sdb4 616448 8388607 7772160 3.7G 5 Extended /dev/sdb5 618496 1642495 1024000 500M fd Linux raid autodetect /dev/sdb6 1644544 2054143 409600 200M 8e Linux LVM /dev/sdb7 2056192 2670591 614400 300M 8e Linux LVM /dev/sdb8 2672640 3696639 1024000 500M fd Linux raid autodetect /dev/sdb9 3698688 4517887 819200 400M 8e Linux LVM /dev/sdb10 4519936 5543935 1024000 500M fd Linux raid autodetect /dev/sdb11 5545984 6569983 1024000 500M fd Linux raid autodetect /dev/sdb12 6572032 6981631 409600 200M 83 Linux Command (m for help):
Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks. [root@centos8 ~]# partprobe
Command Line Switches
The command line switches of this command are:
[root@centos8 ~]# fdisk --help Usage: fdisk [options] <disk> change partition table fdisk [options] -l [<disk>] list partition table(s) Display or manipulate a disk partition table. Options: -b, --sector-size <size> physical and logical sector size -B, --protect-boot don't erase bootbits when creating a new label -c, --compatibility[=<mode>] mode is 'dos' or 'nondos' (default) -L, --color[=<when>] colorize output (auto, always or never) colors are enabled by default -l, --list display partitions and exit -o, --output <list> output columns -t, --type <type> recognize specified partition table type only -u, --units[=<unit>] display units: 'cylinders' or 'sectors' (default) -s, --getsz display device size in 512-byte sectors [DEPRECATED] --bytes print SIZE in bytes rather than in human readable format -w, --wipe <mode> wipe signatures (auto, always or never) -W, --wipe-partitions <mode> wipe signatures from new partitions (auto, always or never) -C, --cylinders <number> specify the number of cylinders -H, --heads <number> specify the number of heads -S, --sectors <number> specify the number of sectors per track -h, --help display this help -V, --version display version Available output columns: gpt: Device Start End Sectors Size Type Type-UUID Attrs Name UUID dos: Device Start End Sectors Cylinders Size Type Id Attrs Boot End-C/H/S Start-C/H/S bsd: Slice Start End Sectors Cylinders Size Type Bsize Cpg Fsize sgi: Device Start End Sectors Cylinders Size Type Id Attrs sun: Device Start End Sectors Cylinders Size Type Id Flags For more details see fdisk(8).
Logical Volume Manager (LVM)
LAB #3 - Linear Logical Volumes
/dev/sdb6 1644544 2054143 409600 200M 8e Linux LVM /dev/sdb7 2056192 2670591 614400 300M 8e Linux LVM /dev/sdb9 3698688 4517887 819200 400M 8e Linux LVM
[root@centos8 ~]# vgscan Found volume group "cl_centos8" using metadata type lvm2
The command line switches of this command are:
[root@centos8 ~]# vgscan --longhelp vgscan - Search for all volume groups vgscan [ --ignorelockingfailure ] [ --mknodes ] [ --notifydbus ] [ --reportformat basic|json ] [ COMMON_OPTIONS ] Common options for lvm: [ -d|--debug ] [ -h|--help ] [ -q|--quiet ] [ -v|--verbose ] [ -y|--yes ] [ -t|--test ] [ --commandprofile String ] [ --config String ] [ --driverloaded y|n ] [ --nolocking ] [ --lockopt String ] [ --longhelp ] [ --profile String ] [ --version ] Common variables for lvm: Variables in option or position args are capitalized, e.g. PV, VG, LV, Size, Number, String, Tag. PV Physical Volume name, a device path under /dev. For commands managing physical extents, a PV positional arg generally accepts a suffix indicating a range (or multiple ranges) of PEs. When the first PE is omitted, it defaults to the start of the device, and when the last PE is omitted it defaults to the end. PV[:PE-PE]... is start and end range (inclusive), PV[:PE+PE]... is start and length range (counting from 0). LV Logical Volume name. See lvm(8) for valid names. An LV positional arg generally includes the VG name and LV name, e.g. VG/LV. LV followed by _<type> indicates that an LV of the given type is required. (raid represents raid<N> type). The _new suffix indicates that the LV name is new. Tag Tag name. See lvm(8) for information about tag names and using tags in place of a VG, LV or PV. Select Select indicates that a required positional arg can be omitted if the --select option is used. No arg appears in this position. Size[UNIT] Size is an input number that accepts an optional unit. Input units are always treated as base two values, regardless of capitalization, e.g. 'k' and 'K' both refer to 1024. The default input unit is specified by letter, followed by |UNIT. UNIT represents other possible input units: BbBsSkKmMgGtTpPeE. (This should not be confused with the output control --units, where capital letters mean multiple of 1000.)
Physical Volume (PV)
[root@centos8 ~]# pvcreate /dev/sdb6 /dev/sdb7 /dev/sdb9 Physical volume "/dev/sdb6" successfully created. Physical volume "/dev/sdb7" successfully created. Physical volume "/dev/sdb9" successfully created.
The command line switches of this command are:
[root@centos8 ~]# pvcreate --longhelp pvcreate - Initialize physical volume(s) for use by LVM pvcreate PV ... [ -f|--force ] [ -M|--metadatatype lvm2 ] [ -u|--uuid String ] [ -Z|--zero y|n ] [ --dataalignment Size[k|UNIT] ] [ --dataalignmentoffset Size[k|UNIT] ] [ --bootloaderareasize Size[m|UNIT] ] [ --labelsector Number ] [ --pvmetadatacopies 0|1|2 ] [ --metadatasize Size[m|UNIT] ] [ --metadataignore y|n ] [ --norestorefile ] [ --setphysicalvolumesize Size[m|UNIT] ] [ --reportformat basic|json ] [ --restorefile String ] [ COMMON_OPTIONS ] Common options for lvm: [ -d|--debug ] [ -h|--help ] [ -q|--quiet ] [ -v|--verbose ] [ -y|--yes ] [ -t|--test ] [ --commandprofile String ] [ --config String ] [ --driverloaded y|n ] [ --nolocking ] [ --lockopt String ] [ --longhelp ] [ --profile String ] [ --version ] Common variables for lvm: Variables in option or position args are capitalized, e.g. PV, VG, LV, Size, Number, String, Tag. PV Physical Volume name, a device path under /dev. For commands managing physical extents, a PV positional arg generally accepts a suffix indicating a range (or multiple ranges) of PEs. When the first PE is omitted, it defaults to the start of the device, and when the last PE is omitted it defaults to the end. PV[:PE-PE]... is start and end range (inclusive), PV[:PE+PE]... is start and length range (counting from 0). LV Logical Volume name. See lvm(8) for valid names. An LV positional arg generally includes the VG name and LV name, e.g. VG/LV. LV followed by _<type> indicates that an LV of the given type is required. (raid represents raid<N> type). The _new suffix indicates that the LV name is new. Tag Tag name. See lvm(8) for information about tag names and using tags in place of a VG, LV or PV. Select Select indicates that a required positional arg can be omitted if the --select option is used. No arg appears in this position. Size[UNIT] Size is an input number that accepts an optional unit. Input units are always treated as base two values, regardless of capitalization, e.g. 'k' and 'K' both refer to 1024. The default input unit is specified by letter, followed by |UNIT. UNIT represents other possible input units: BbBsSkKmMgGtTpPeE. (This should not be confused with the output control --units, where capital letters mean multiple of 1000.)
[root@centos8 ~]# pvdisplay /dev/sdb6 /dev/sdb7 /dev/sdb9 "/dev/sdb6" is a new physical volume of "200.00 MiB" --- NEW Physical volume --- PV Name /dev/sdb6 VG Name PV Size 200.00 MiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID xsAjLA-sUEU-dexm-H7G1-Dsi4-q6qW-8Tqkay "/dev/sdb7" is a new physical volume of "300.00 MiB" --- NEW Physical volume --- PV Name /dev/sdb7 VG Name PV Size 300.00 MiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID WpssK3-sThn-3nS0-80O3-NcW3-23e0-gxejn4 "/dev/sdb9" is a new physical volume of "400.00 MiB" --- NEW Physical volume --- PV Name /dev/sdb9 VG Name PV Size 400.00 MiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID rqaB99-3UdD-pJxE-Z1Eo-h9yv-tZ41-r4UJSY
The command line switches of this command are:
[root@centos8 ~]# pvdisplay --longhelp pvdisplay - Display various attributes of physical volume(s) pvdisplay [ -a|--all ] [ -c|--colon ] [ -C|--columns ] [ -m|--maps ] [ -o|--options String ] [ -S|--select String ] [ -s|--short ] [ -O|--sort String ] [ --aligned ] [ --binary ] [ --configreport log|vg|lv|pv|pvseg|seg ] [ --foreign ] [ --ignorelockingfailure ] [ --logonly ] [ --noheadings ] [ --nosuffix ] [ --readonly ] [ --reportformat basic|json ] [ --separator String ] [ --shared ] [ --unbuffered ] [ --units r|R|h|H|b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|E ] [ COMMON_OPTIONS ] [ PV|Tag ... ] Common options for lvm: [ -d|--debug ] [ -h|--help ] [ -q|--quiet ] [ -v|--verbose ] [ -y|--yes ] [ -t|--test ] [ --commandprofile String ] [ --config String ] [ --driverloaded y|n ] [ --nolocking ] [ --lockopt String ] [ --longhelp ] [ --profile String ] [ --version ] Common variables for lvm: Variables in option or position args are capitalized, e.g. PV, VG, LV, Size, Number, String, Tag. PV Physical Volume name, a device path under /dev. For commands managing physical extents, a PV positional arg generally accepts a suffix indicating a range (or multiple ranges) of PEs. When the first PE is omitted, it defaults to the start of the device, and when the last PE is omitted it defaults to the end. PV[:PE-PE]... is start and end range (inclusive), PV[:PE+PE]... is start and length range (counting from 0). LV Logical Volume name. See lvm(8) for valid names. An LV positional arg generally includes the VG name and LV name, e.g. VG/LV. LV followed by _<type> indicates that an LV of the given type is required. (raid represents raid<N> type). The _new suffix indicates that the LV name is new. Tag Tag name. See lvm(8) for information about tag names and using tags in place of a VG, LV or PV. Select Select indicates that a required positional arg can be omitted if the --select option is used. No arg appears in this position. Size[UNIT] Size is an input number that accepts an optional unit. Input units are always treated as base two values, regardless of capitalization, e.g. 'k' and 'K' both refer to 1024. The default input unit is specified by letter, followed by |UNIT. UNIT represents other possible input units: BbBsSkKmMgGtTpPeE. (This should not be confused with the output control --units, where capital letters mean multiple of 1000.)
Volume Groups (VG) and Physical Extents (PE)
[root@centos8 ~]# vgcreate -s 8M vg0 /dev/sdb6 /dev/sdb7 /dev/sdb9 Volume group "vg0" successfully created
The command line switches of this command are:
[root@centos8 ~]# vgcreate --help vgcreate - Create a volume group vgcreate VG_new PV ... [ -A|--autobackup y|n ] [ -c|--clustered y|n ] [ -l|--maxlogicalvolumes Number ] [ -p|--maxphysicalvolumes Number ] [ -M|--metadatatype lvm2 ] [ -s|--physicalextentsize Size[m|UNIT] ] [ -f|--force ] [ -Z|--zero y|n ] [ --addtag Tag ] [ --alloc contiguous|cling|cling_by_tags|normal|anywhere|inherit ] [ --metadataprofile String ] [ --labelsector Number ] [ --metadatasize Size[m|UNIT] ] [ --pvmetadatacopies 0|1|2 ] [ --vgmetadatacopies all|unmanaged|Number ] [ --reportformat basic|json ] [ --dataalignment Size[k|UNIT] ] [ --dataalignmentoffset Size[k|UNIT] ] [ --shared ] [ --systemid String ] [ --locktype sanlock|dlm|none ] [ COMMON_OPTIONS ] Common options for lvm: [ -d|--debug ] [ -h|--help ] [ -q|--quiet ] [ -v|--verbose ] [ -y|--yes ] [ -t|--test ] [ --commandprofile String ] [ --config String ] [ --driverloaded y|n ] [ --nolocking ] [ --lockopt String ] [ --longhelp ] [ --profile String ] [ --version ] Use --longhelp to show all options and advanced commands.
[root@centos8 ~]# vgdisplay vg0 --- Volume group --- VG Name vg0 System ID Format lvm2 Metadata Areas 3 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 3 Act PV 3 VG Size 880.00 MiB PE Size 8.00 MiB Total PE 110 Alloc PE / Size 0 / 0 Free PE / Size 110 / 880.00 MiB VG UUID 6cO8IX-xhvn-5J4z-Em2t-7RAq-u3y8-1cVZln
The command line switches of this command are:
[root@centos8 ~]# vgdisplay --help vgdisplay - Display volume group information vgdisplay [ -A|--activevolumegroups ] [ -c|--colon ] [ -C|--columns ] [ -o|--options String ] [ -S|--select String ] [ -s|--short ] [ -O|--sort String ] [ --aligned ] [ --binary ] [ --configreport log|vg|lv|pv|pvseg|seg ] [ --foreign ] [ --ignorelockingfailure ] [ --logonly ] [ --noheadings ] [ --nosuffix ] [ --readonly ] [ --reportformat basic|json ] [ --shared ] [ --separator String ] [ --unbuffered ] [ --units r|R|h|H|b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|E ] [ COMMON_OPTIONS ] [ VG|Tag ... ] Common options for lvm: [ -d|--debug ] [ -h|--help ] [ -q|--quiet ] [ -v|--verbose ] [ -y|--yes ] [ -t|--test ] [ --commandprofile String ] [ --config String ] [ --driverloaded y|n ] [ --nolocking ] [ --lockopt String ] [ --longhelp ] [ --profile String ] [ --version ] Use --longhelp to show all options and advanced commands.
Logical Volumes (LV)
[root@centos8 ~]# lvcreate -L 350 -n lv0 vg0 Rounding up size to full physical extent 352.00 MiB Logical volume "lv0" created.
Important - Note that the LV size is a multiple of the PE size.
The command line switches of this command are:
[root@centos8 ~]# lvcreate --help lvcreate - Create a logical volume Create a linear LV. lvcreate -L|--size Size[m|UNIT] VG [ -l|--extents Number[PERCENT] ] [ --type linear ] [ COMMON_OPTIONS ] [ PV ... ] Create a striped LV (infers --type striped). lvcreate -i|--stripes Number -L|--size Size[m|UNIT] VG [ -l|--extents Number[PERCENT] ] [ -I|--stripesize Size[k|UNIT] ] [ COMMON_OPTIONS ] [ PV ... ] Create a raid1 or mirror LV (infers --type raid1|mirror). lvcreate -m|--mirrors Number -L|--size Size[m|UNIT] VG [ -l|--extents Number[PERCENT] ] [ -R|--regionsize Size[m|UNIT] ] [ --mirrorlog core|disk ] [ --minrecoveryrate Size[k|UNIT] ] [ --maxrecoveryrate Size[k|UNIT] ] [ COMMON_OPTIONS ] [ PV ... ] Create a raid LV (a specific raid level must be used, e.g. raid1). lvcreate --type raid -L|--size Size[m|UNIT] VG [ -l|--extents Number[PERCENT] ] [ -m|--mirrors Number ] [ -i|--stripes Number ] [ -I|--stripesize Size[k|UNIT] ] [ -R|--regionsize Size[m|UNIT] ] [ --minrecoveryrate Size[k|UNIT] ] [ --maxrecoveryrate Size[k|UNIT] ] [ --raidintegrity y|n ] [ --raidintegritymode String ] [ --raidintegrityblocksize Number ] [ COMMON_OPTIONS ] [ PV ... ] Create a raid10 LV. lvcreate -m|--mirrors Number -i|--stripes Number -L|--size Size[m|UNIT] VG [ -l|--extents Number[PERCENT] ] [ -I|--stripesize Size[k|UNIT] ] [ -R|--regionsize Size[m|UNIT] ] [ --minrecoveryrate Size[k|UNIT] ] [ --maxrecoveryrate Size[k|UNIT] ] [ COMMON_OPTIONS ] [ PV ... ] Create a COW snapshot LV of an origin LV. lvcreate -s|--snapshot -L|--size Size[m|UNIT] LV [ -l|--extents Number[PERCENT] ] [ -i|--stripes Number ] [ -I|--stripesize Size[k|UNIT] ] [ -c|--chunksize Size[k|UNIT] ] [ --type snapshot ] [ COMMON_OPTIONS ] [ PV ... ] Create a thin pool. lvcreate --type thin-pool -L|--size Size[m|UNIT] VG [ -l|--extents Number[PERCENT] ] [ -c|--chunksize Size[k|UNIT] ] [ -i|--stripes Number ] [ -I|--stripesize Size[k|UNIT] ] [ --thinpool LV_new ] [ --poolmetadatasize Size[m|UNIT] ] [ --poolmetadataspare y|n ] [ --discards passdown|nopassdown|ignore ] [ --errorwhenfull y|n ] [ COMMON_OPTIONS ] [ PV ... ] Create a cache pool. lvcreate --type cache-pool -L|--size Size[m|UNIT] VG [ -l|--extents Number[PERCENT] ] [ -H|--cache ] [ -c|--chunksize Size[k|UNIT] ] [ --poolmetadatasize Size[m|UNIT] ] [ --poolmetadataspare y|n ] [ --cachemode writethrough|writeback|passthrough ] [ --cachepolicy String ] [ --cachesettings String ] [ --cachemetadataformat auto|1|2 ] [ COMMON_OPTIONS ] [ PV ... ] Create a thin LV in a thin pool (infers --type thin). lvcreate -V|--virtualsize Size[m|UNIT] --thinpool LV_thinpool VG [ -T|--thin ] [ --type thin ] [ --discards passdown|nopassdown|ignore ] [ --errorwhenfull y|n ] [ COMMON_OPTIONS ] Create a thin LV that is a snapshot of an existing thin LV (infers --type thin). lvcreate -s|--snapshot LV_thin [ --type thin ] [ --discards passdown|nopassdown|ignore ] [ --errorwhenfull y|n ] [ COMMON_OPTIONS ] Create a thin LV that is a snapshot of an external origin LV. lvcreate --type thin --thinpool LV_thinpool LV [ -T|--thin ] [ -c|--chunksize Size[k|UNIT] ] [ --poolmetadatasize Size[m|UNIT] ] [ --poolmetadataspare y|n ] [ --discards passdown|nopassdown|ignore ] [ --errorwhenfull y|n ] [ COMMON_OPTIONS ] Create a LV that returns VDO when used. lvcreate --type vdo -L|--size Size[m|UNIT] VG [ -l|--extents Number[PERCENT] ] [ -V|--virtualsize Size[m|UNIT] ] [ -i|--stripes Number ] [ -I|--stripesize Size[k|UNIT] ] [ --vdo ] [ --vdopool LV_new ] [ --compression y|n ] [ --deduplication y|n ] [ COMMON_OPTIONS ] [ PV ... ] Create a thin LV, first creating a thin pool for it, where the new thin pool is named by the --thinpool arg. lvcreate --type thin -V|--virtualsize Size[m|UNIT] -L|--size Size[m|UNIT] --thinpool LV_new [ -l|--extents Number[PERCENT] ] [ -T|--thin ] [ -c|--chunksize Size[k|UNIT] ] [ -i|--stripes Number ] [ -I|--stripesize Size[k|UNIT] ] [ --poolmetadatasize Size[m|UNIT] ] [ --poolmetadataspare y|n ] [ --discards passdown|nopassdown|ignore ] [ --errorwhenfull y|n ] [ COMMON_OPTIONS ] [ PV ... ] Create a new LV, then attach the specified cachepool which converts the new LV to type cache. lvcreate --type cache -L|--size Size[m|UNIT] --cachepool LV_cachepool VG [ -l|--extents Number[PERCENT] ] [ -H|--cache ] [ -c|--chunksize Size[k|UNIT] ] [ -i|--stripes Number ] [ -I|--stripesize Size[k|UNIT] ] [ --poolmetadatasize Size[m|UNIT] ] [ --poolmetadataspare y|n ] [ --cachemode writethrough|writeback|passthrough ] [ --cachepolicy String ] [ --cachesettings String ] [ --cachemetadataformat auto|1|2 ] [ COMMON_OPTIONS ] [ PV ... ] Create a new LV, then attach the specified cachevol which converts the new LV to type cache. lvcreate --type cache -L|--size Size[m|UNIT] --cachevol LV VG [ -l|--extents Number[PERCENT] ] [ -c|--chunksize Size[k|UNIT] ] [ -i|--stripes Number ] [ -I|--stripesize Size[k|UNIT] ] [ --cachemode writethrough|writeback|passthrough ] [ --cachepolicy String ] [ --cachesettings String ] [ --cachemetadataformat auto|1|2 ] [ COMMON_OPTIONS ] [ PV ... ] Create a new LV, then attach a cachevol created from the specified cache device, which converts the new LV to type cache. lvcreate --type cache -L|--size Size[m|UNIT] --cachedevice PV VG [ -l|--extents Number[PERCENT] ] [ -c|--chunksize Size[k|UNIT] ] [ -i|--stripes Number ] [ -I|--stripesize Size[k|UNIT] ] [ --cachemode writethrough|writeback|passthrough ] [ --cachepolicy String ] [ --cachesettings String ] [ --cachemetadataformat auto|1|2 ] [ --cachesize Size[m|UNIT] ] [ COMMON_OPTIONS ] [ PV ... ] Create a new LV, then attach the specified cachevol which converts the new LV to type writecache. lvcreate --type writecache -L|--size Size[m|UNIT] --cachevol LV VG [ -l|--extents Number[PERCENT] ] [ -i|--stripes Number ] [ -I|--stripesize Size[k|UNIT] ] [ --cachesettings String ] [ COMMON_OPTIONS ] [ PV ... ] Create a new LV, then attach a cachevol created from the specified cache device, which converts the new LV to type writecache. lvcreate --type writecache -L|--size Size[m|UNIT] --cachedevice PV VG [ -l|--extents Number[PERCENT] ] [ -i|--stripes Number ] [ -I|--stripesize Size[k|UNIT] ] [ --cachesize Size[m|UNIT] ] [ --cachesettings String ] [ COMMON_OPTIONS ] [ PV ... ] Common options for command: [ -a|--activate y|n|ay ] [ -A|--autobackup y|n ] [ -C|--contiguous y|n ] [ -M|--persistent y|n ] [ -j|--major Number ] [ -k|--setactivationskip y|n ] [ -K|--ignoreactivationskip ] [ -n|--name String ] [ -p|--permission rw|r ] [ -r|--readahead auto|none|Number ] [ -W|--wipesignatures y|n ] [ -Z|--zero y|n ] [ --addtag Tag ] [ --alloc contiguous|cling|cling_by_tags|normal|anywhere|inherit ] [ --ignoremonitoring ] [ --metadataprofile String ] [ --minor Number ] [ --monitor y|n ] [ --nosync ] [ --noudevsync ] [ --reportformat basic|json ] Common options for lvm: [ -d|--debug ] [ -h|--help ] [ -q|--quiet ] [ -v|--verbose ] [ -y|--yes ] [ -t|--test ] [ --commandprofile String ] [ --config String ] [ --driverloaded y|n ] [ --nolocking ] [ --lockopt String ] [ --longhelp ] [ --profile String ] [ --version ] Use --longhelp to show all options and advanced commands.
[root@centos8 ~]# mkdir /mnt/lvm
[root@centos8 ~]# mke2fs -j /dev/vg0/lv0 mke2fs 1.45.6 (20-Mar-2020) Creating filesystem with 360448 1k blocks and 90112 inodes Filesystem UUID: 87b6d526-d379-4e0c-8984-94811f1cee33 Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729, 204801, 221185 Allocating group tables: done Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done
[root@centos8 ~]# mount -t ext3 /dev/vg0/lv0 /mnt/lvm
[root@centos8 ~]# cp -a /home /mnt/lvm
[root@centos8 ~]# ls -l /mnt/lvm total 14 drwxr-xr-x. 5 root root 1024 Apr 20 14:35 home drwx------. 2 root root 12288 May 26 17:00 lost+found
[root@centos8 ~]# df -h /mnt/lvm Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg0-lv0 333M 17M 314M 1% /mnt/lvm
LAB #4 - Growing a Volume
[root@centos8 ~]# lvextend -L +100M /dev/vg0/lv0 Rounding size to boundary between physical extents: 104.00 MiB. Size of logical volume vg0/lv0 changed from 352.00 MiB (44 extents) to 456.00 MiB (57 extents). Logical volume vg0/lv0 successfully resized.
The command line switches of this command are:
[root@centos8 ~]# lvextend --help lvextend - Add space to a logical volume Extend an LV by a specified size. lvextend -L|--size [+]Size[m|UNIT] LV [ -l|--extents [+]Number[PERCENT] ] [ -r|--resizefs ] [ -i|--stripes Number ] [ -I|--stripesize Size[k|UNIT] ] [ --poolmetadatasize [+]Size[m|UNIT] ] [ COMMON_OPTIONS ] [ PV ... ] Extend an LV by specified PV extents. lvextend LV PV ... [ -r|--resizefs ] [ -i|--stripes Number ] [ -I|--stripesize Size[k|UNIT] ] [ COMMON_OPTIONS ] Extend a pool metadata SubLV by a specified size. lvextend --poolmetadatasize [+]Size[m|UNIT] LV_thinpool [ -i|--stripes Number ] [ -I|--stripesize Size[k|UNIT] ] [ COMMON_OPTIONS ] [ PV ... ] Extend an LV according to a predefined policy. lvextend --usepolicies LV_snapshot_thinpool [ -r|--resizefs ] [ COMMON_OPTIONS ] [ PV ... ] Common options for command: [ -A|--autobackup y|n ] [ -f|--force ] [ -m|--mirrors Number ] [ -n|--nofsck ] [ --alloc contiguous|cling|cling_by_tags|normal|anywhere|inherit ] [ --nosync ] [ --noudevsync ] [ --reportformat basic|json ] [ --type linear|striped|snapshot|mirror|raid|thin|cache|vdo|thin-pool|cache-pool|vdo-pool ] Common options for lvm: [ -d|--debug ] [ -h|--help ] [ -q|--quiet ] [ -v|--verbose ] [ -y|--yes ] [ -t|--test ] [ --commandprofile String ] [ --config String ] [ --driverloaded y|n ] [ --nolocking ] [ --lockopt String ] [ --longhelp ] [ --profile String ] [ --version ] Use --longhelp to show all options and advanced commands.
[root@centos8 ~]# resize2fs /dev/vg0/lv0 resize2fs 1.45.6 (20-Mar-2020) Filesystem at /dev/vg0/lv0 is mounted on /mnt/lvm; on-line resizing required old_desc_blocks = 2, new_desc_blocks = 2 The filesystem on /dev/vg0/lv0 is now 466944 (1k) blocks long.
[root@centos8 ~]# df -h /mnt/lvm Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg0-lv0 434M 17M 395M 5% /mnt/lvm
LAB #5 - Snapshots
[root@centos8 ~]# dd if=/dev/zero of=/mnt/lvm/10M bs=1048576 count=10 10+0 records in 10+0 records out 10485760 bytes (10 MB, 10 MiB) copied, 0.0281282 s, 373 MB/s
[root@centos8 ~]# lvcreate -s -L 18M -n testsnap /dev/vg0/lv0 Rounding up size to full physical extent 24.00 MiB Logical volume "testsnap" created.
[root@centos8 ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root cl_centos8 -wi-ao---- 27.79g swap cl_centos8 -wi-ao---- 3.20g lv0 vg0 owi-aos--- 456.00m testsnap vg0 swi-a-s--- 24.00m lv0 0.05
Important - Note that the snapshot is created in the same VG as the original LV.
The command line switches of this command are:
[root@centos8 ~]# lvs --help lvs - Display information about logical volumes lvs [ -H|--history ] [ -a|--all ] [ -o|--options String ] [ -S|--select String ] [ -O|--sort String ] [ --segments ] [ --aligned ] [ --binary ] [ --configreport log|vg|lv|pv|pvseg|seg ] [ --foreign ] [ --ignorelockingfailure ] [ --logonly ] [ --nameprefixes ] [ --noheadings ] [ --nosuffix ] [ --readonly ] [ --reportformat basic|json ] [ --rows ] [ --separator String ] [ --shared ] [ --unbuffered ] [ --units r|R|h|H|b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|E ] [ --unquoted ] [ COMMON_OPTIONS ] [ VG|LV|Tag ... ] Common options for lvm: [ -d|--debug ] [ -h|--help ] [ -q|--quiet ] [ -v|--verbose ] [ -y|--yes ] [ -t|--test ] [ --commandprofile String ] [ --config String ] [ --driverloaded y|n ] [ --nolocking ] [ --lockopt String ] [ --longhelp ] [ --profile String ] [ --version ] Use --longhelp to show all options and advanced commands.
[root@centos8 ~]# mkdir /mnt/testsnap
[root@centos8 ~]# mount /dev/vg0/testsnap /mnt/testsnap
[root@centos8 ~]# ls -l /mnt/lvm total 10296 -rw-r--r--. 1 root root 10485760 Jun 24 04:41 10M drwxr-xr-x. 3 root root 1024 Jun 16 06:39 home drwx------. 2 root root 12288 Jun 24 04:20 lost+found [root@centos8 ~]# ls -l /mnt/testsnap/ total 10296 -rw-r--r--. 1 root root 10485760 Jun 24 04:41 10M drwxr-xr-x. 3 root root 1024 Jun 16 06:39 home drwx------. 2 root root 12288 Jun 24 04:20 lost+found
[root@centos8 ~]# rm /mnt/lvm/10M rm: remove regular file '/mnt/lvm/10M'? y
[root@centos8 ~]# df -Ph /mnt/lvm Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg0-lv0 434M 17M 395M 5% /mnt/lvm [root@centos8 ~]# df -Ph /mnt/testsnap/ Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg0-testsnap 434M 27M 385M 7% /mnt/testsnap [root@centos8 ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root cl_centos8 -wi-ao---- 27.79g swap cl_centos8 -wi-ao---- 3.20g lv0 vg0 owi-aos--- 456.00m testsnap vg0 swi-aos--- 24.00m lv0 0.24
To do - Restore the 10M file.
LAB #6 - Deleting Volumes
[root@centos8 ~]# umount /mnt/testsnap/ [root@centos8 ~]# lvremove /dev/vg0/testsnap Do you really want to remove active logical volume vg0/testsnap? [y/n]: y Logical volume "testsnap" successfully removed [root@centos8 ~]# umount /mnt/lvm [root@centos8 ~]# lvremove /dev/vg0/lv0 Do you really want to remove active logical volume vg0/lv0? [y/n]: y Logical volume "lv0" successfully removed
The command line switches of this command are:
[root@centos8 ~]# lvremove --help lvremove - Remove logical volume(s) from the system lvremove VG|LV|Tag|Select ... [ -A|--autobackup y|n ] [ -f|--force ] [ -S|--select String ] [ --nohistory ] [ --noudevsync ] [ --reportformat basic|json ] [ COMMON_OPTIONS ] Common options for lvm: [ -d|--debug ] [ -h|--help ] [ -q|--quiet ] [ -v|--verbose ] [ -y|--yes ] [ -t|--test ] [ --commandprofile String ] [ --config String ] [ --driverloaded y|n ] [ --nolocking ] [ --lockopt String ] [ --longhelp ] [ --profile String ] [ --version ] Use --longhelp to show all options and advanced commands
[root@centos8 ~]# vgremove vg0 Volume group "vg0" successfully removed
The command line switches of this command are:
[root@centos8 ~]# vgremove --help vgremove - Remove volume group(s) vgremove VG|Tag|Select ... [ -f|--force ] [ -S|--select String ] [ --noudevsync ] [ --reportformat basic|json ] [ COMMON_OPTIONS ] Common options for lvm: [ -d|--debug ] [ -h|--help ] [ -q|--quiet ] [ -v|--verbose ] [ -y|--yes ] [ -t|--test ] [ --commandprofile String ] [ --config String ] [ --driverloaded y|n ] [ --nolocking ] [ --lockopt String ] [ --longhelp ] [ --profile String ] [ --version ] Use --longhelp to show all options and advanced commands.
[root@centos8 ~]# pvremove /dev/sdb6 /dev/sdb7 /dev/sdb9 Labels on physical volume "/dev/sdb6" successfully wiped. Labels on physical volume "/dev/sdb7" successfully wiped. Labels on physical volume "/dev/sdb9" successfully wiped.
The command line switches of this command are:
[root@centos8 ~]# pvremove --help pvremove - Remove LVM label(s) from physical volume(s) pvremove PV ... [ -f|--force ] [ --reportformat basic|json ] [ COMMON_OPTIONS ] Common options for lvm: [ -d|--debug ] [ -h|--help ] [ -q|--quiet ] [ -v|--verbose ] [ -y|--yes ] [ -t|--test ] [ --commandprofile String ] [ --config String ] [ --driverloaded y|n ] [ --nolocking ] [ --lockopt String ] [ --longhelp ] [ --profile String ] [ --version ] Use --longhelp to show all options and advanced commands.
LAB #7 - Mirrored Volumes
[root@centos8 ~]# pvcreate /dev/sdb6 /dev/sdb7 /dev/sdb9 Physical volume "/dev/sdb6" successfully created. Physical volume "/dev/sdb7" successfully created. Physical volume "/dev/sdb9" successfully created. [root@centos8 ~]# vgcreate -s 8M vg0 /dev/sdb6 /dev/sdb7 /dev/sdb9 Volume group "vg0" successfully created
[root@centos8 ~]# lvcreate -m 1 -L 100M -n lv1 vg0 Rounding up size to full physical extent 104.00 MiB Logical volume "lv1" created.
[root@centos8 ~]# lvdisplay -m /dev/vg0/lv1 --- Logical volume --- LV Path /dev/vg0/lv1 LV Name lv1 VG Name vg0 LV UUID lJQQWs-n05T-pxzi-Zq2R-UzRI-kYZf-hsNPYQ LV Write Access read/write LV Creation host, time centos8.ittraining.loc, 2021-06-02 07:37:28 -0400 LV Status available # open 0 LV Size 104.00 MiB Current LE 13 Mirrored volumes 2 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:4 --- Segments --- Logical extents 0 to 12: Type raid1 Monitoring monitored Raid Data LV 0 Logical volume lv1_rimage_0 Logical extents 0 to 12 Raid Data LV 1 Logical volume lv1_rimage_1 Logical extents 0 to 12 Raid Metadata LV 0 lv1_rmeta_0 Raid Metadata LV 1 lv1_rmeta_1
[root@centos8 ~]# pvdisplay -m /dev/sdb6 /dev/sdb7 /dev/sdb9 --- Physical volume --- PV Name /dev/sdb6 VG Name vg0 PV Size 200.00 MiB / not usable 8.00 MiB Allocatable yes PE Size 8.00 MiB Total PE 24 Free PE 10 Allocated PE 14 PV UUID lxuKRI-l3Dd-jhsv-OWtw-au2c-0ti0-XGnt1E --- Physical Segments --- Physical extent 0 to 0: Logical volume /dev/vg0/lv1_rmeta_0 Logical extents 0 to 0 Physical extent 1 to 13: Logical volume /dev/vg0/lv1_rimage_0 Logical extents 0 to 12 Physical extent 14 to 23: FREE --- Physical volume --- PV Name /dev/sdb7 VG Name vg0 PV Size 300.00 MiB / not usable 4.00 MiB Allocatable yes PE Size 8.00 MiB Total PE 37 Free PE 23 Allocated PE 14 PV UUID QDmfcX-Pv8o-hapq-TJOI-RaPH-qecT-VUMY4v --- Physical Segments --- Physical extent 0 to 0: Logical volume /dev/vg0/lv1_rmeta_1 Logical extents 0 to 0 Physical extent 1 to 13: Logical volume /dev/vg0/lv1_rimage_1 Logical extents 0 to 12 Physical extent 14 to 36: FREE --- Physical volume --- PV Name /dev/sdb9 VG Name vg0 PV Size 400.00 MiB / not usable 8.00 MiB Allocatable yes PE Size 8.00 MiB Total PE 49 Free PE 49 Allocated PE 0 PV UUID ZTQV1b-Ha76-BQtB-zJEU-kfyK-ausJ-CxnRwg --- Physical Segments --- Physical extent 0 to 48: FREE
[root@centos8 ~]# lvconvert -m 0 /dev/vg0/lv1 /dev/sdb7 Are you sure you want to convert raid1 LV vg0/lv1 to type linear losing all resilience? [y/n]: y Logical volume vg0/lv1 successfully converted.
[root@centos8 ~]# lvconvert -m 1 /dev/vg0/lv1 Are you sure you want to convert linear LV vg0/lv1 to raid1 with 2 images enhancing resilience? [y/n]: y Logical volume vg0/lv1 successfully converted.
[root@centos8 ~]# lvconvert -m 0 /dev/vg0/lv1 /dev/sdb7 Are you sure you want to convert raid1 LV vg0/lv1 to type linear losing all resilience? [y/n]: y Logical volume vg0/lv1 successfully converted.
The command line switches of this command are:
[root@centos8 ~]# lvconvert --help lvconvert - Change logical volume layout Convert LV to linear. lvconvert --type linear LV [ COMMON_OPTIONS ] [ PV ... ] Convert LV to striped. lvconvert --type striped LV [ -I|--stripesize Size[k|UNIT] ] [ -R|--regionsize Size[m|UNIT] ] [ -i|--interval Number ] [ --stripes Number ] [ COMMON_OPTIONS ] [ PV ... ] Convert LV to type mirror (also see type raid1), lvconvert --type mirror LV [ -m|--mirrors [+|-]Number ] [ -I|--stripesize Size[k|UNIT] ] [ -R|--regionsize Size[m|UNIT] ] [ -i|--interval Number ] [ --stripes Number ] [ --mirrorlog core|disk ] [ COMMON_OPTIONS ] [ PV ... ] Convert LV to raid or change raid layout (a specific raid level must be used, e.g. raid1). lvconvert --type raid LV [ -m|--mirrors [+|-]Number ] [ -I|--stripesize Size[k|UNIT] ] [ -R|--regionsize Size[m|UNIT] ] [ -i|--interval Number ] [ --stripes Number ] [ COMMON_OPTIONS ] [ PV ... ] Convert LV to raid1 or mirror, or change number of mirror images. lvconvert -m|--mirrors [+|-]Number LV [ -R|--regionsize Size[m|UNIT] ] [ -i|--interval Number ] [ --mirrorlog core|disk ] [ COMMON_OPTIONS ] [ PV ... ] Convert raid LV to change number of stripe images. lvconvert --stripes Number LV_raid [ -i|--interval Number ] [ -R|--regionsize Size[m|UNIT] ] [ -I|--stripesize Size[k|UNIT] ] [ COMMON_OPTIONS ] [ PV ... ] Convert raid LV to change the stripe size. lvconvert -I|--stripesize Size[k|UNIT] LV_raid [ -i|--interval Number ] [ -R|--regionsize Size[m|UNIT] ] [ COMMON_OPTIONS ] Split images from a raid1 or mirror LV and use them to create a new LV. lvconvert --splitmirrors Number -n|--name LV_new LV_cache_mirror_raid1 [ COMMON_OPTIONS ] [ PV ... ] Split images from a raid1 LV and track changes to origin for later merge. lvconvert --splitmirrors Number --trackchanges LV_cache_raid1 [ COMMON_OPTIONS ] [ PV ... ] Merge LV images that were split from a raid1 LV. lvconvert --mergemirrors VG|LV_linear_raid|Tag ... [ COMMON_OPTIONS ] Convert LV to a thin LV, using the original LV as an external origin. lvconvert --type thin --thinpool LV LV_linear_striped_thin_cache_raid [ -T|--thin ] [ -r|--readahead auto|none|Number ] [ -c|--chunksize Size[k|UNIT] ] [ -Z|--zero y|n ] [ --originname LV_new ] [ --poolmetadata LV ] [ --poolmetadatasize Size[m|UNIT] ] [ --poolmetadataspare y|n ] [ --metadataprofile String ] [ COMMON_OPTIONS ] Attach a cache pool to an LV, converts the LV to type cache. lvconvert --type cache --cachepool LV LV_linear_striped_thinpool_vdo_vdopool_vdopooldata_raid [ -H|--cache ] [ -Z|--zero y|n ] [ -r|--readahead auto|none|Number ] [ -c|--chunksize Size[k|UNIT] ] [ --cachemetadataformat auto|1|2 ] [ --cachemode writethrough|writeback|passthrough ] [ --cachepolicy String ] [ --cachesettings String ] [ --poolmetadata LV ] [ --poolmetadatasize Size[m|UNIT] ] [ --poolmetadataspare y|n ] [ --metadataprofile String ] [ COMMON_OPTIONS ] Attach a writecache to an LV, converts the LV to type writecache. lvconvert --type writecache --cachevol LV LV_linear_striped_raid [ --cachesettings String ] [ COMMON_OPTIONS ] Attach a cache to an LV, converts the LV to type cache. lvconvert --type cache --cachevol LV LV_linear_striped_thinpool_raid [ -H|--cache ] [ -Z|--zero y|n ] [ -c|--chunksize Size[k|UNIT] ] [ --cachemetadataformat auto|1|2 ] [ --cachemode writethrough|writeback|passthrough ] [ --cachepolicy String ] [ --cachesettings String ] [ --poolmetadatasize Size[m|UNIT] ] [ COMMON_OPTIONS ] Add a writecache to an LV, using a specified cache device. lvconvert --type writecache --cachedevice PV LV_linear_striped_raid [ --cachesize Size[m|UNIT] ] [ --cachesettings String ] [ COMMON_OPTIONS ] Add a cache to an LV, using a specified cache device. lvconvert --type cache --cachedevice PV LV_linear_striped_thinpool_raid [ --cachesize Size[m|UNIT] ] [ --cachesettings String ] [ COMMON_OPTIONS ] Convert LV to type thin-pool. lvconvert --type thin-pool LV_linear_striped_cache_raid [ -I|--stripesize Size[k|UNIT] ] [ -r|--readahead auto|none|Number ] [ -c|--chunksize Size[k|UNIT] ] [ -Z|--zero y|n ] [ --stripes Number ] [ --discards passdown|nopassdown|ignore ] [ --poolmetadata LV ] [ --poolmetadatasize Size[m|UNIT] ] [ --poolmetadataspare y|n ] [ --metadataprofile String ] [ COMMON_OPTIONS ] [ PV ... ] Convert LV to type cache-pool. lvconvert --type cache-pool LV_linear_striped_raid [ -Z|--zero y|n ] [ -r|--readahead auto|none|Number ] [ -c|--chunksize Size[k|UNIT] ] [ --cachemetadataformat auto|1|2 ] [ --cachemode writethrough|writeback|passthrough ] [ --cachepolicy String ] [ --cachesettings String ] [ --poolmetadata LV ] [ --poolmetadatasize Size[m|UNIT] ] [ --poolmetadataspare y|n ] [ --metadataprofile String ] [ COMMON_OPTIONS ] [ PV ... ] Convert LV to type vdopool. lvconvert --type vdo-pool LV_linear_striped_cache_raid [ -n|--name LV_new ] [ -V|--virtualsize Size[m|UNIT] ] [ --compression y|n ] [ --deduplication y|n ] [ COMMON_OPTIONS ] Detach a cache from an LV. lvconvert --splitcache LV_thinpool_cache_cachepool_vdopool_writecache [ COMMON_OPTIONS ] Merge thin LV into its origin LV. lvconvert --mergethin LV_thin ... [ COMMON_OPTIONS ] Merge COW snapshot LV into its origin. lvconvert --mergesnapshot LV_snapshot ... [ -i|--interval Number ] [ COMMON_OPTIONS ] Combine a former COW snapshot (second arg) with a former origin LV (first arg) to reverse a splitsnapshot command. lvconvert --type snapshot LV LV_linear_striped [ -s|--snapshot ] [ -c|--chunksize Size[k|UNIT] ] [ -Z|--zero y|n ] [ COMMON_OPTIONS ] Replace failed PVs in a raid or mirror LV. Repair a thin pool. Repair a cache pool. lvconvert --repair LV_thinpool_cache_cachepool_mirror_raid [ -i|--interval Number ] [ --usepolicies ] [ --poolmetadataspare y|n ] [ COMMON_OPTIONS ] [ PV ... ] Replace specific PV(s) in a raid LV with another PV. lvconvert --replace PV LV_raid [ COMMON_OPTIONS ] [ PV ... ] Poll LV to continue conversion. lvconvert --startpoll LV_mirror_raid [ COMMON_OPTIONS ] Add or remove data integrity checksums to raid images. lvconvert --raidintegrity y|n LV_raid [ --raidintegritymode String ] [ --raidintegrityblocksize Number ] [ COMMON_OPTIONS ] [ PV ... ] Common options for command: [ -b|--background ] [ -f|--force ] [ --alloc contiguous|cling|cling_by_tags|normal|anywhere|inherit ] [ --noudevsync ] Common options for lvm: [ -d|--debug ] [ -h|--help ] [ -q|--quiet ] [ -v|--verbose ] [ -y|--yes ] [ -t|--test ] [ --commandprofile String ] [ --config String ] [ --driverloaded y|n ] [ --nolocking ] [ --lockopt String ] [ --longhelp ] [ --profile String ] [ --version ] Use --longhelp to show all options and advanced commands.
LAB #8 - Changing LVM Attributes
[root@centos8 ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root cl_centos8 -wi-ao---- 27.79g swap cl_centos8 -wi-ao---- 3.20g lv1 vg0 -wi-a----- 104.00m
See this page .
[root@centos8 ~]# vgs VG #PV #LV #SN Attr VSize VFree cl_centos8 1 2 0 wz--n- <31.00g 0 vg0 3 1 0 wz--n- 880.00m 776.00m
See this page.
[root@centos8 ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 cl_centos8 lvm2 a-- <31.00g 0 /dev/sdb6 vg0 lvm2 a-- 192.00m 88.00m /dev/sdb7 vg0 lvm2 a-- 296.00m 296.00m /dev/sdb9 vg0 lvm2 a-- 392.00m 392.00m
See this page.
[root@centos8 ~]# lvchange -a n /dev/vg0/lv1
[root@centos8 ~]# lvchange -a y /dev/vg0/lv1
The command line switches of this command are:
[root@centos8 ~]# lvchange --help lvchange - Change the attributes of logical volume(s) Change a general LV attribute. For options listed in parentheses, any one is required, after which the others are optional. lvchange ( -C|--contiguous y|n, -p|--permission rw|r, -r|--readahead auto|none|Number, -k|--setactivationskip y|n, -Z|--zero y|n, -M|--persistent n, --addtag Tag, --deltag Tag, --alloc contiguous|cling|cling_by_tags|normal|anywhere|inherit, --compression y|n, --deduplication y|n, --detachprofile, --metadataprofile String, --profile String, --errorwhenfull y|n, --discards passdown|nopassdown|ignore, --cachemode writethrough|writeback|passthrough, --cachepolicy String, --cachesettings String, --minrecoveryrate Size[k|UNIT], --maxrecoveryrate Size[k|UNIT], --writebehind Number, --writemostly PV[:t|n|y] ) VG|LV|Tag|Select ... [ -a|--activate y|n|ay ] [ --poll y|n ] [ --monitor y|n ] [ COMMON_OPTIONS ] Resyncronize a mirror or raid LV. Use to reset 'R' attribute on a not initially synchronized LV. lvchange --resync VG|LV_mirror_raid|Tag|Select ... [ -a|--activate y|n|ay ] [ COMMON_OPTIONS ] Resynchronize or check a raid LV. lvchange --syncaction check|repair VG|LV_raid|Tag|Select ... [ COMMON_OPTIONS ] Reconstruct data on specific PVs of a raid LV. lvchange --rebuild PV VG|LV_raid|Tag|Select ... [ COMMON_OPTIONS ] Activate or deactivate an LV. lvchange -a|--activate y|n|ay VG|LV|Tag|Select ... [ -P|--partial ] [ -K|--ignoreactivationskip ] [ --activationmode partial|degraded|complete ] [ --poll y|n ] [ --monitor y|n ] [ --ignorelockingfailure ] [ --sysinit ] [ --readonly ] [ COMMON_OPTIONS ] Reactivate an LV using the latest metadata. lvchange --refresh VG|LV|Tag|Select ... [ -P|--partial ] [ --activationmode partial|degraded|complete ] [ --poll y|n ] [ --monitor y|n ] [ COMMON_OPTIONS ] Start or stop monitoring an LV from dmeventd. lvchange --monitor y|n VG|LV|Tag|Select ... [ COMMON_OPTIONS ] Start or stop processing an LV conversion. lvchange --poll y|n VG|LV|Tag|Select ... [ --monitor y|n ] [ COMMON_OPTIONS ] Make the minor device number persistent for an LV. lvchange -M|--persistent y --minor Number LV [ -j|--major Number ] [ -a|--activate y|n|ay ] [ --poll y|n ] [ --monitor y|n ] [ COMMON_OPTIONS ] Common options for command: [ -A|--autobackup y|n ] [ -f|--force ] [ -S|--select String ] [ --ignoremonitoring ] [ --noudevsync ] [ --reportformat basic|json ] Common options for lvm: [ -d|--debug ] [ -h|--help ] [ -q|--quiet ] [ -v|--verbose ] [ -y|--yes ] [ -t|--test ] [ --commandprofile String ] [ --config String ] [ --driverloaded y|n ] [ --nolocking ] [ --lockopt String ] [ --longhelp ] [ --profile String ] [ --version ] Use --longhelp to show all options and advanced commands.
LAB #9 - Striped Volumes
- -i - number of stripes,
- -I - size of stripe in KB.
[root@centos8 ~]# lvcreate -i2 -I64 -n lv2 -L 100M vg0 /dev/sdb7 /dev/sdb9 Rounding up size to full physical extent 104.00 MiB Rounding size 104.00 MiB (13 extents) up to stripe boundary size 112.00 MiB(14 extents). Logical volume "lv2" created.
[root@centos8 ~]# lvdisplay -m /dev/vg0/lv2 --- Logical volume --- LV Path /dev/vg0/lv2 LV Name lv2 VG Name vg0 LV UUID MmXbPt-ZF8u-rnIv-3YU9-m64J-RCz2-6NzAuG LV Write Access read/write LV Creation host, time centos8.ittraining.loc, 2021-06-02 07:47:38 -0400 LV Status available # open 0 LV Size 112.00 MiB Current LE 14 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1 --- Segments --- Logical extents 0 to 13: Type striped Stripes 2 Stripe size 64.00 KiB Stripe 0: Physical volume /dev/sdb7 Physical extents 0 to 6 Stripe 1: Physical volume /dev/sdb9 Physical extents 0 to 6
[root@centos8 ~]# lvs -o +devices LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert Devices root cl_centos8 -wi-ao---- 27.79g /dev/sda2(820) swap cl_centos8 -wi-ao---- 3.20g /dev/sda2(0) lv1 vg0 -wi-a----- 104.00m /dev/sdb6(1) lv2 vg0 -wi-a----- 112.00m /dev/sdb7(0),/dev/sdb9(0)
Journaled Filrsystems
Ext3
Managing Ext3
[root@centos8 ~]# fdisk -l Disk /dev/sdb: 4 GiB, 4294967296 bytes, 8388608 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xb0dacb39 Device Boot Start End Sectors Size Id Type /dev/sdb1 2048 206847 204800 100M 83 Linux /dev/sdb2 206848 411647 204800 100M 83 Linux /dev/sdb3 411648 616447 204800 100M 83 Linux /dev/sdb4 616448 8388607 7772160 3.7G 5 Extended /dev/sdb5 618496 1642495 1024000 500M fd Linux raid autodetect /dev/sdb6 1644544 2054143 409600 200M 8e Linux LVM /dev/sdb7 2056192 2670591 614400 300M 8e Linux LVM /dev/sdb8 2672640 3696639 1024000 500M fd Linux raid autodetect /dev/sdb9 3698688 4517887 819200 400M 8e Linux LVM /dev/sdb10 4519936 5543935 1024000 500M fd Linux raid autodetect /dev/sdb11 5545984 6569983 1024000 500M fd Linux raid autodetect /dev/sdb12 6572032 6981631 409600 200M 83 Linux Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x70b17285 Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 616447 614400 300M 83 Linux /dev/sda2 616448 4712447 4096000 2G 82 Linux swap / Solaris /dev/sda3 4712448 35432447 30720000 14.7G 83 Linux Disk /dev/mapper/vg0-lv1: 104 MiB, 109051904 bytes, 212992 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/vg0-lv2: 112 MiB, 117440512 bytes, 229376 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 65536 bytes / 131072 bytes
Créez un filesystem Ext3 sur /dev/sdb12 en utilisant la commande mke2fs -j :
[root@centos8 ~]# mke2fs -j /dev/sdb12 mke2fs 1.45.6 (20-Mar-2020) Creating filesystem with 204800 1k blocks and 51200 inodes Filesystem UUID: a2515f45-a32a-4e87-b7e6-170448f3f803 Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Allocating group tables: done Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done
The command line switches of this command are:
[root@centos8 ~]# mke2fs --help mke2fs: invalid option -- '-' Usage: mke2fs [-c|-l filename] [-b block-size] [-C cluster-size] [-i bytes-per-inode] [-I inode-size] [-J journal-options] [-G flex-group-size] [-N number-of-inodes] [-d root-directory] [-m reserved-blocks-percentage] [-o creator-os] [-g blocks-per-group] [-L volume-label] [-M last-mounted-directory] [-O feature[,...]] [-r fs-revision] [-E extended-option[,...]] [-t fs-type] [-T usage-type ] [-U UUID] [-e errors_behavior][-z undo_file] [-jnqvDFSV] device [blocks-count]
LAB #11 - Converting Ext3 to Ext2
[root@centos8 ~]# dumpe2fs -h /dev/sdb12 dumpe2fs 1.45.6 (20-Mar-2020) Filesystem volume name: <none> Last mounted on: <not available> Filesystem UUID: a2515f45-a32a-4e87-b7e6-170448f3f803 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal ext_attr resize_inode dir_index filetype sparse_super large_file Filesystem flags: signed_directory_hash Default mount options: user_xattr acl Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 51200 Block count: 204800 Reserved block count: 10240 Free blocks: 192674 Free inodes: 51189 First block: 1 Block size: 1024 Fragment size: 1024 Reserved GDT blocks: 256 Blocks per group: 8192 Fragments per group: 8192 Inodes per group: 2048 Inode blocks per group: 256 Filesystem created: Wed Jun 2 07:55:24 2021 Last mount time: n/a Last write time: Wed Jun 2 07:55:24 2021 Mount count: 0 Maximum mount count: -1 Last checked: Wed Jun 2 07:55:24 2021 Check interval: 0 (<none>) Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root) First inode: 11 Inode size: 128 Journal inode: 8 Default directory hash: half_md4 Directory Hash Seed: faee0b81-0538-4c06-8d86-468bc0c760ac Journal backup: inode blocks Journal features: (none) Journal size: 4096k Journal length: 4096 Journal sequence: 0x00000001 Journal start: 0
Important : The Filesystem features: has_journal … shows that Ext3 is on the partition.
The command line switches of this command are:
[root@centos8 ~]# dumpe2fs --help dumpe2fs 1.45.6 (20-Mar-2020) dumpe2fs: invalid option -- '-' Usage: dumpe2fs [-bfghimxV] [-o superblock=<num>] [-o blocksize=<num>] device
[root@centos8 ~]# tune2fs -O ^has_journal /dev/sdb12 tune2fs 1.45.6 (20-Mar-2020)
The command line switches of this command are:
[root@centos8 ~]# tune2fs --help tune2fs 1.45.6 (20-Mar-2020) tune2fs: invalid option -- '-' Usage: tune2fs [-c max_mounts_count] [-e errors_behavior] [-f] [-g group] [-i interval[d|m|w]] [-j] [-J journal_options] [-l] [-m reserved_blocks_percent] [-o [^]mount_options[,...]] [-r reserved_blocks_count] [-u user] [-C mount_count] [-L volume_label] [-M last_mounted_dir] [-O [^]feature[,...]] [-Q quota_options] [-E extended-option[,...]] [-T last_check_time] [-U UUID] [-I new_inode_size] [-z undo_file] device
[root@centos8 ~]# dumpe2fs -h /dev/sdb12 dumpe2fs 1.45.6 (20-Mar-2020) Filesystem volume name: <none> Last mounted on: <not available> Filesystem UUID: a2515f45-a32a-4e87-b7e6-170448f3f803 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: ext_attr resize_inode dir_index filetype sparse_super large_file Filesystem flags: signed_directory_hash Default mount options: user_xattr acl Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 51200 Block count: 204800 Reserved block count: 10240 Free blocks: 196787 Free inodes: 51189 First block: 1 Block size: 1024 Fragment size: 1024 Reserved GDT blocks: 256 Blocks per group: 8192 Fragments per group: 8192 Inodes per group: 2048 Inode blocks per group: 256 Filesystem created: Wed Jun 2 07:55:24 2021 Last mount time: n/a Last write time: Wed Jun 2 07:59:01 2021 Mount count: 0 Maximum mount count: -1 Last checked: Wed Jun 2 07:55:24 2021 Check interval: 0 (<none>) Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root) First inode: 11 Inode size: 128 Default directory hash: half_md4 Directory Hash Seed: faee0b81-0538-4c06-8d86-468bc0c760ac Journal backup: inode blocks
[root@centos8 ~]# fsck /dev/sdb12 fsck from util-linux 2.32.1 e2fsck 1.45.6 (20-Mar-2020) /dev/sdb12: clean, 11/51200 files, 8013/204800 blocks
[root@centos8 ~]# mkdir /mnt/sdb12
[root@centos8 ~]# mount -t ext3 /dev/sdb12 /mnt/sdb12 mount: /mnt/sdb12: wrong fs type, bad option, bad superblock on /dev/sdb12, missing codepage or helper program, or other error.
[root@centos8 ~]# mount -t ext2 /dev/sdb12 /mnt/sdb12
LAB #12 - Converting Ext2 to Ext3
[root@centos8 ~]# umount /mnt/sdb12 [root@centos8 ~]# tune2fs -j /dev/sdb12 tune2fs 1.45.6 (20-Mar-2020) Creating journal inode: done
LAB #13 - Using another Partition for the Journal
[root@centos8 ~]# mke2fs -O journal_dev /dev/sdb11 mke2fs 1.45.6 (20-Mar-2020) Creating filesystem with 512000 1k blocks and 0 inodes Filesystem UUID: 23327281-e88a-4da0-bafa-50ee10c52937 Superblock backups stored on blocks: Zeroing journal device:
Important : Note the -O switch.
[root@centos8 ~]# mke2fs -j -J device=/dev/sdb11 /dev/sdb12 mke2fs 1.45.6 (20-Mar-2020) Using journal device's blocksize: 1024 /dev/sdb12 contains a ext3 file system last mounted on Wed Jun 2 08:03:11 2021 Proceed anyway? (y,N) y Creating filesystem with 204800 1k blocks and 51200 inodes Filesystem UUID: 0e783411-6407-4cba-8db5-0e2729000c9e Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Allocating group tables: done Writing inode tables: done Adding journal to device /dev/sdb11: done Writing superblocks and filesystem accounting information: done
LAB #14 - Changing the File System Check interval on an ext3 Filesystem
Use the -c or -i switches:
[root@centos8 ~]# tune2fs -i 100d /dev/sdb12 tune2fs 1.45.6 (20-Mar-2020) Setting interval between checks to 8640000 seconds
[root@centos8 ~]# dumpe2fs /dev/sdb12 | grep UUID dumpe2fs 1.45.6 (20-Mar-2020) Filesystem UUID: 0e783411-6407-4cba-8db5-0e2729000c9e Journal UUID: 23327281-e88a-4da0-bafa-50ee10c52937
Ext4
LAB #15 - Creating an Ext4 Filesystem
[root@centos8 ~]# mkfs.ext4 /dev/sdb11 mke2fs 1.45.6 (20-Mar-2020) /dev/sdb11 contains a jbd file system Proceed anyway? (y,N) y Creating filesystem with 512000 1k blocks and 128016 inodes Filesystem UUID: 72a6ad08-7023-4561-adcb-d434e00afed1 Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409 Allocating group tables: done Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done
The command line switches of this command are:
[root@centos8 ~]# mkfs.ext4 --help mkfs.ext4: invalid option -- '-' Usage: mkfs.ext4 [-c|-l filename] [-b block-size] [-C cluster-size] [-i bytes-per-inode] [-I inode-size] [-J journal-options] [-G flex-group-size] [-N number-of-inodes] [-d root-directory] [-m reserved-blocks-percentage] [-o creator-os] [-g blocks-per-group] [-L volume-label] [-M last-mounted-directory] [-O feature[,...]] [-r fs-revision] [-E extended-option[,...]] [-t fs-type] [-T usage-type ] [-U UUID] [-e errors_behavior][-z undo_file] [-jnqvDFSV] device [blocks-count]
[root@centos8 ~]# dumpe2fs /dev/sdb11 | more dumpe2fs 1.45.6 (20-Mar-2020) Filesystem volume name: <none> Last mounted on: <not available> Filesystem UUID: 72a6ad08-7023-4561-adcb-d434e00afed1 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal ext_attr resize_inode dir_index filetype e xtent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize meta data_csum Filesystem flags: signed_directory_hash Default mount options: user_xattr acl Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 128016 Block count: 512000 Reserved block count: 25600 Free blocks: 485316 Free inodes: 128005 First block: 1 Block size: 1024 Fragment size: 1024 Group descriptor size: 64 Reserved GDT blocks: 256 --More--
LAB #16 - Adding a Label to an Ext4 Filesystem
[root@centos8 ~]# e2label /dev/sdb11 my_ext4 [root@centos8 ~]# dumpe2fs /dev/sdb11 | more dumpe2fs 1.45.6 (20-Mar-2020) Filesystem volume name: my_ext4 Last mounted on: <not available> Filesystem UUID: 72a6ad08-7023-4561-adcb-d434e00afed1 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal ext_attr resize_inode dir_index filetype e xtent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize meta data_csum Filesystem flags: signed_directory_hash Default mount options: user_xattr acl Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 128016 Block count: 512000 Reserved block count: 25600 Free blocks: 485316 Free inodes: 128005 First block: 1 Block size: 1024 Fragment size: 1024 Group descriptor size: 64 Reserved GDT blocks: 256 --More--
Important - Note that the labal is limited to 16 characters.
[root@centos8 ~]# mkdir /mnt/sdb11 [root@centos8 ~]# mount -t ext3 /dev/sdb11 /mnt/sdb11 mount: /mnt/sdb11: wrong fs type, bad option, bad superblock on /dev/sdb11, missing codepage or helper program, or other error..
[root@centos8 ~]# mount /dev/sdb11 /mnt/sdb11 [root@centos8 ~]# mount | grep sdb11 /dev/sdb11 on /mnt/sdb11 type ext4 (rw,relatime,seclabel)
LAB #17 - Converting Ext3 to Ext4
[root@centos8 ~]# mkfs.ext3 /dev/sdb12 mke2fs 1.45.6 (20-Mar-2020) /dev/sdb12 contains a ext3 file system created on Wed Jun 2 08:10:40 2021 Proceed anyway? (y,N) y Creating filesystem with 204800 1k blocks and 51200 inodes Filesystem UUID: b73322d4-f2e4-43bc-96ae-422d4584f3de Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Allocating group tables: done Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done
[root@centos8 ~]# mount /dev/sdb12 /mnt/sdb12 [root@centos8 ~]# ls -l /mnt/sdb12 total 12 drwx------. 2 root root 12288 Jun 2 08:42 lost+found
[root@centos8 ~]# touch /mnt/sdb12/check_file
[root@centos8 ~]# echo "check file" > /mnt/sdb12/check_file [root@centos8 ~]# umount /dev/sdb12
[root@centos8 ~]# e2fsck /dev/sdb12 e2fsck 1.45.6 (20-Mar-2020) /dev/sdb12: clean, 12/51200 files, 12128/204800 blocks
[root@centos8 ~]# tune2fs -O extents,uninit_bg,dir_index /dev/sdb12 tune2fs 1.45.6 (20-Mar-2020)
[root@centos8 ~]# e2fsck -fDC0 /dev/sdb12 e2fsck 1.45.6 (20-Mar-2020) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 3A: Optimizing directories Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/sdb12: ***** FILE SYSTEM WAS MODIFIED ***** /dev/sdb12: 12/51200 files (0.0% non-contiguous), 12128/204800 blocks
[root@centos8 ~]# mount -t ext3 /dev/sdb12 /mnt/sdb12 mount: /mnt/sdb12: wrong fs type, bad option, bad superblock on /dev/sdb12, missing codepage or helper program, or other error.
[root@centos8 ~]# mount /dev/sdb12 /mnt/sdb12 [root@centos8 ~]# ls -l /mnt/sdb12 total 14 -rw-r--r--. 1 root root 11 Jun 2 08:45 check_file drwx------. 2 root root 12288 Jun 2 08:42 lost+found [root@centos8 ~]# cat /mnt/sdb12/check_file check file
[root@centos8 ~]# dumpe2fs /dev/sdb11 | grep UUID dumpe2fs 1.45.6 (20-Mar-2020) Filesystem UUID: 72a6ad08-7023-4561-adcb-d434e00afed1 [root@centos8 ~]# dumpe2fs /dev/sdb12 | grep UUID dumpe2fs 1.45.6 (20-Mar-2020) Filesystem UUID: b73322d4-f2e4-43bc-96ae-422d4584f3de
XFS
Important : XFS allows you to extend a filesystem but not reduce it.
LAB #18 - Creating an XFS Filesystem
[root@centos8 ~]# umount /dev/sdb12
[root@centos8 ~]# mkfs.xfs -f /dev/sdb12 meta-data=/dev/sdb12 isize=512 agcount=4, agsize=12800 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 data = bsize=4096 blocks=51200, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0, ftype=1 log =internal log bsize=4096 blocks=1368, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0
Important - Note the use of the -f switch.
The command line switches of this command are:
[root@centos8 ~]# mkfs.xfs --help mkfs.xfs: invalid option -- '-' unknown option -- Usage: mkfs.xfs /* blocksize */ [-b size=num] /* metadata */ [-m crc=0|1,finobt=0|1,uuid=xxx,rmapbt=0|1,reflink=0|1] /* data subvol */ [-d agcount=n,agsize=n,file,name=xxx,size=num, (sunit=value,swidth=value|su=num,sw=num|noalign), sectsize=num /* force overwrite */ [-f] /* inode size */ [-i log=n|perblock=n|size=num,maxpct=n,attr=0|1|2, projid32bit=0|1,sparse=0|1] /* no discard */ [-K] /* log subvol */ [-l agnum=n,internal,size=num,logdev=xxx,version=n sunit=value|su=num,sectsize=num,lazy-count=0|1] /* label */ [-L label (maximum 12 characters)] /* naming */ [-n size=num,version=2|ci,ftype=0|1] /* no-op info only */ [-N] /* prototype file */ [-p fname] /* quiet */ [-q] /* realtime subvol */ [-r extsize=num,size=num,rtdev=xxx] /* sectorsize */ [-s size=num] /* version */ [-V] devicename <devicename> is required unless -d name=xxx is given. <num> is xxx (bytes), xxxs (sectors), xxxb (fs blocks), xxxk (xxx KiB), xxxm (xxx MiB), xxxg (xxx GiB), xxxt (xxx TiB) or xxxp (xxx PiB). <value> is xxx (512 byte blocks).
[root@centos8 ~]# xfs_info /dev/sdb12 meta-data=/dev/sdb12 isize=512 agcount=4, agsize=12800 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 data = bsize=4096 blocks=51200, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0, ftype=1 log =internal log bsize=4096 blocks=1368, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0
The command line switches of this command are:
[root@centos8 ~]# xfs_info --help /usr/sbin/xfs_info: illegal option -- - Usage: xfs_info [-V] [-t mtab] [mountpoint|device|file]
===LAB #19 - Adding a Label to an XFS Filesyst
[root@centos8 ~]# xfs_admin -L my_xfs /dev/sdb12 xfs_admin: /dev/sdb12 contains a mounted filesystem fatal error -- couldn't initialize XFS library [root@centos8 ~]# umount /dev/sdb12 [root@centos8 ~]# xfs_admin -L my_xfs /dev/sdb12 writing all SBs new label = "my_xfs"
Pour voir l'étiquette, utilisez la commande suivante :
[root@centos8 ~]# xfs_admin -l /dev/sdb12 label = "my_xfs"
Important - Note the Label cannot be longer that 12 characters.
The command line switches of this command are:
[root@centos8 ~]# xfs_admin --help /usr/sbin/xfs_admin: illegal option -- - Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-U uuid] device
[root@centos8 ~]# xfs_admin -u /dev/sdb12 UUID = 15db1b62-0866-4aa4-9ac1-3ac325a4e20f
<html> <div align=“center”> Copyright © 2021 Hugh Norris. </html> </code>