How to create LVM on Fedora 34
- 00:45 cat /etc/os-release
- 00:55 lsblk
- 01:04 fdisk /dev/sdb
- 01:53 partprobe
- 02:10 lsblk
- 02:22 pvcreate /dev/sdb1
- 02:30 vgcreate test /dev/sdb1
- 02:44 lvcreate -n check -L 8G test
- 02:53 lsblk
- 03:06 mkdir /test
- 03:20 mkfs.xfs /dev/test/check
- 03:35 blkid
- 03:53 vim /etc/fstab
- 06:16 mount -a
- 06:18 lsblk
- 06:29 umount /dev/test/check
- 06:40 vim /etc/fstab
- 06:52 lsblk
- 07:11 lvremove /dev/test/check
- 07:27 vgremove /dev/test
- 07:35 pvremove /dev/sdb1
- 07:46 lsblk
- 07:52 fdisk /dev/sdb
- 08:19 partprobe
- 08:33 lsblk
To Create And Manage LVM on Fedora 34.
Introduction:
Logical volume management (LVM) is a form of storage virtualization that offers system administrators a more flexible approach to managing disk storage space than traditional partitioning. This type of virtualization tool is located within the device-driver stack on the operating system.
Step 1: Check the OS version by using the below command.
[root@linuxhelp ~]# cat /etc/os-release
NAME=Fedora
VERSION="34 (Workstation Edition)"
ID=fedora
VERSION_ID=34
VERSION_CODENAME=""
PLATFORM_ID="platform:f34"
PRETTY_NAME="Fedora 34 (Workstation Edition)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:34"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/34/system-administrators-guide/"
Step 2: Check the disk block by using the below command
[root@linuxhelp ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part /home
sdb 8:16 0 30G 0 disk
sdc 8:32 0 10G 0 disk
sr0 11:0 1 1.9G 0 rom /run/media/linuxhelp/Fedora-WS-Live-34-1-2
zram0 252:0 0 4.1G 0 disk [SWAP]
Step 3: Create a new Partition by using the below command.
[root@linuxhelp ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.36.2).
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 0xed5cec9d.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-62914559, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-62914559, default 62914559): +10G
Created a new partition 1 of type 'Linux' and of size 10 GiB.
Command (m for help): t
Selected partition 1
Hex code or alias (type L to list all): l
00 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
01 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
02 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
03 XENIX usr 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT-
04 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx
05 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
06 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / .
07 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility
08 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt
09 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
0a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
0b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
0c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi ea Linux extended
0e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs
0f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT
10 OPUS 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f1 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f4 SpeedStor
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fb VMware VMFS
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fc VMware VMKCORE
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fd Linux raid auto
1c Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fe LANstep
1e Hidden W95 FAT1 80 Old Minix be Solaris boot ff BBT
Aliases:
linux - 83
swap - 82
extended - 05
uefi - EF
raid - FD
lvm - 8E
linuxex - 85
Hex code or alias (type L to list all): 8e
Changed type of partition 'Linux' to 'Linux LVM'.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Step 4: Once all the modification is done in the partition, restart it by using the below command.
[root@linuxhelp ~]# partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
Step 5: Now Check the disk block by using the below command
[root@linuxhelp ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part /home
sdb 8:16 0 30G 0 disk
└─sdb1 8:17 0 10G 0 part
sdc 8:32 0 10G 0 disk
sr0 11:0 1 1.9G 0 rom /run/media/linuxhelp/Fedora-WS-Live-34-1-2
zram0 252:0 0 4.1G 0 disk [SWAP]
Step 6: Create the Physical volume by using the below command.
[root@linuxhelp ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
Step 7: Create the Volume group by using the below command
[root@linuxhelp ~]# vgcreate test /dev/sdb1
Volume group "test" successfully created
Step 8: Create a Logical volume by using the below command.
[root@linuxhelp ~]# lvcreate -n check -L 8G test
Logical volume "check" created.
Step 9: Check the disk block by using the below command.
[root@linuxhelp ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part /home
sdb 8:16 0 30G 0 disk
└─sdb1 8:17 0 10G 0 part
└─test-check 253:0 0 8G 0 lvm
sdc 8:32 0 10G 0 disk
sr0 11:0 1 1.9G 0 rom /run/media/linuxhelp/Fedora-WS-Live-34-1-2
zram0 252:0 0 4.1G 0 disk [SWAP]
Step 10: Make the directory by using the below command.
[root@linuxhelp ~]# mkdir /test
Step 11: Make the file system by using the below command.
[root@linuxhelp ~]# mkfs.ext4 /dev/test/check
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 2097152 4k blocks and 524288 inodes
Filesystem UUID: e53bc8f0-8c55-495d-b9ad-b7783f4e7ef1
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
Step 12: Check the file type by using the below command.
[root@linuxhelp ~]# blkid
/dev/sr0: BLOCK_SIZE="2048" UUID="2021-04-23-11-17-40-00" LABEL="Fedora-WS-Live-34-1-2" TYPE="iso9660" PTUUID="6b5ab614" PTTYPE="dos"
/dev/sda1: UUID="b4ac53c1-c48c-450a-be62-525868adfd5a" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="3f94edf1-01"
/dev/sda2: LABEL="fedora_localhost-live" UUID="89d93d80-44ff-48c1-a84b-293ca2db9b3c" UUID_SUB="fc6cdf76-8e4e-4827-8821-aefedc9b76f6" BLOCK_SIZE="4096" TYPE="btrfs" PARTUUID="3f94edf1-02"
/dev/sdb1: UUID="h26Z9p-LEJj-WWxe-Nor2-EohF-k18P-izPD6P" TYPE="LVM2_member" PARTUUID="ed5cec9d-01"
/dev/zram0: LABEL="zram0" UUID="099d2ce6-edd7-4808-a5d0-7719e84a3cd5" TYPE="swap"
/dev/mapper/test-check: UUID="e53bc8f0-8c55-495d-b9ad-b7783f4e7ef1" BLOCK_SIZE="4096" TYPE="ext4"
Step 13: Open the fstab configuration file by using the below command.
[root@linuxhelp ~]# vim /etc/fstab
/dev/sda2: LABEL="fedora_localhost-live" UUID="89d93d80-44ff-48c1-a84b-293ca2db9b3c" UUID_SUB="fc6cdf76-8e4e-4827-8821-aefedc9b76f6" BLOCK_SIZE="4096" TYPE="btrfs" PARTUUID="3f94edf1-02"
/dev/sdb1: UUID="h26Z9p-LEJj-WWxe-Nor2-EohF-k18P-izPD6P" TYPE="LVM2_member" PARTUUID="ed5cec9d-01"
/dev/zram0: LABEL="zram0" UUID="099d2ce6-edd7-4808-a5d0-7719e84a3cd5" TYPE="swap"
/dev/mapper/test-check: UUID="e53bc8f0-8c55-495d-b9ad-b7783f4e7ef1" BLOCK_SIZE="4096" TYPE="ext4"
Step 14: To Mount use the below command.
[root@linuxhelp ~]# mount -a
mount: /dev/mapper/test-check: mount point is not a directory.
Step 15: To change the directory and list the files use the below command
[root@linuxhelp ~]# cd /dev/test/
[root@linuxhelp test]# ls -l
total 0
lrwxrwxrwx 1 root root 7 Dec 7 21:15 check -> ../dm-0
Step 16: To move the files source to destination and change directory use the below command.
[root@linuxhelp test]# mv check1 check
mv: cannot stat 'check1': No such file or directory
[root@linuxhelp test]# cd
Step 17: change the directory by using the below command.
[root@linuxhelp ~]# cd /dev/test/
[root@linuxhelp test]# ls -l
total 0
lrwxrwxrwx 1 root root 7 Dec 7 21:15 check -> ../dm-0
Step 18: Make the directory by using the below command.
[root@linuxhelp test]# mkdir check1
Step 19: To move the directory and list the file use the below command.
[root@linuxhelp test]# mv check check1
[root@linuxhelp test]# ls -l
total 0
drwxr-xr-x 2 root root 60 Dec 7 21:24 check1
Step 20: To make the directory use the below command.
[root@linuxhelp test]# mkdir check
Step 21: To mount and list the directory use the below command.
[root@linuxhelp test]# mount -a
[root@linuxhelp test]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part /home
sdb 8:16 0 30G 0 disk
└─sdb1 8:17 0 10G 0 part
└─test-check 253:0 0 8G 0 lvm /dev/test/check
sdc 8:32 0 10G 0 disk
sr0 11:0 1 1.9G 0 rom /run/media/linuxhelp/Fedora-WS-Live-34-1-2
zram0 252:0 0 4.1G 0 disk [SWAP]
The process of installing how to create and manage LVM on Fedora 34 has come to an End
Comments ( 0 )
No comments available