For this recipe (Ubuntu 22.04 focal), the setup has three SCSI disks that will be put into a logical volume using LVM. The disks are at /dev/sda, /dev/sdb, and /dev/sdc (ignore the OS disk).
Disk /dev/nvme0n1: 1.76 TiB, 1920383410176 bytes, 3750748848 sectors Disk model: SAMSUNG MZQL21T9HCJR-00A07 Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 131072 bytes / 131072 bytes Disklabel type: dos Disk identifier: 0x0edc49ab Device Boot Start End Sectors Size Id Type /dev/nvme0n1p1 2048 8390655 8388608 4G 82 Linux swap / Solaris /dev/nvme0n1p2 8390656 10487807 2097152 1G 83 Linux /dev/nvme0n1p3 10487808 3750746799 3740258992 1.8T 83 Linux Disk /dev/sda: 7.28 TiB, 8001563222016 bytes, 15628053168 sectors Disk model: HGST HUH721008AL Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disklabel type: gpt Disk identifier: 5DDAA99D-057D-5A45-90FF-C9DC826FCE7D Disk /dev/sdb: 7.28 TiB, 8001563222016 bytes, 15628053168 sectors Disk model: HGST HUH721008AL Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disklabel type: gpt Disk identifier: 0A481C8C-79A2-0347-94EA-B2DF6361BF5F Disk /dev/sdc: 14.57 TiB, 16000900661248 bytes, 31251759104 sectors Disk model: ST16000NM003G-2K Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disklabel type: gpt Disk identifier: E1266E34-E31B-DF45-BC60-9D5565C11BC8
First, we need to clean the drives:
root@server ~ # wipefs -a /dev/sda /dev/sda: 8 bytes were erased at offset 0x00000200 (gpt): 45 46 49 20 50 41 52 54 /dev/sda: 8 bytes were erased at offset 0x74702555e00 (gpt): 45 46 49 20 50 41 52 54 /dev/sda: 2 bytes were erased at offset 0x000001fe (PMBR): 55 aa /dev/sda: calling ioctl to re-read partition table: Success root@server ~ # wipefs -a /dev/sdb /dev/sdb: 8 bytes were erased at offset 0x00000200 (gpt): 45 46 49 20 50 41 52 54 /dev/sdb: 8 bytes were erased at offset 0x74702555e00 (gpt): 45 46 49 20 50 41 52 54 /dev/sdb: 2 bytes were erased at offset 0x000001fe (PMBR): 55 aa /dev/sdb: calling ioctl to re-read partition table: Success root@server ~ # wipefs -a /dev/sdc /dev/sdc: 8 bytes were erased at offset 0x00000200 (gpt): 45 46 49 20 50 41 52 54 /dev/sdc: 8 bytes were erased at offset 0xe8d7ffffe00 (gpt): 45 46 49 20 50 41 52 54 /dev/sdc: 2 bytes were erased at offset 0x000001fe (PMBR): 55 aa /dev/sdc: calling ioctl to re-read partition table: Success
Now we can pvcreate:
root@server ~ # pvcreate /dev/sda Physical volume "/dev/sda" successfully created. root@server ~ # pvcreate /dev/sdb Physical volume "/dev/sdb" successfully created. root@server ~ # pvcreate /dev/sdc Physical volume "/dev/sdc" successfully created.
pvs:
root@server ~ # pvs PV VG Fmt Attr PSize PFree /dev/sda lvm2 --- <7.28t <7.28t /dev/sdb lvm2 --- <7.28t <7.28t /dev/sdc lvm2 --- 14.55t 14.55t
Create a volume group
root@server ~ # vgcreate vg00 /dev/sda /dev/sdb /dev/sdc Volume group "vg00" successfully created root@server ~ # vgdisplay vg00 --- Volume group --- VG Name vg00 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 <29.11 TiB PE Size 4.00 MiB Total PE 7630353 Alloc PE / Size 0 / 0 Free PE / Size 7630353 / <29.11 TiB VG UUID CTRQ1a-MlEv-bFZy-7Ph9-eo0Q-mEQU-BBCewT
Tt is time to create one or more logical volume on top of the volume group. I’ll create a 500GB volume for system backups, and the remaining space will be used to create a second volume for media files. The -n
option is used to indicate a name for the LV, whereas -L
sets a fixed size and -l
(lowercase L) is used to indicate a percentage of the remaining space in the container VG.
root@server ~ # lvcreate -n vol_backups -L 500G vg00 Logical volume "vol_backups" created. root@server ~ # lvcreate -n vol_media -l 100%FREE vg00 Logical volume "vol_media" created.
lvsdisply:
root@server ~ # lvdisplay --- Logical volume --- LV Path /dev/vg00/vol_backups LV Name vol_backups VG Name vg00 LV UUID 4ULTFr-JTum-tOXD-byLF-FvCz-UzwJ-UsGnfq LV Write Access read/write LV Creation host, time server.darkq.net, 2023-05-10 17:15:43 +0200 LV Status available # open 0 LV Size 500.00 GiB Current LE 128000 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 --- Logical volume --- LV Path /dev/vg00/vol_media LV Name vol_media VG Name vg00 LV UUID FubLXZ-3fPe-A9fP-HYdl-eauq-vSsi-Ls3JJA LV Write Access read/write LV Creation host, time server.darkq.net, 2023-05-10 17:17:23 +0200 LV Status available # open 0 LV Size <28.62 TiB Current LE 7502353 Segments 3 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1
Now, let’s create the ext4 filesystems:
root@server ~ # mkfs.ext4 /dev/vg00/vol_backups mke2fs 1.45.5 (07-Jan-2020) Creating filesystem with 131072000 4k blocks and 32768000 inodes Filesystem UUID: 9decc28e-dae7-469f-b1de-7d6da1fd5fb0 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 102400000 Allocating group tables: done Writing inode tables: done Creating journal (262144 blocks): done Writing superblocks and filesystem accounting information: done root@server ~ # mkfs.ext4 /dev/vg00/vol_media mke2fs 1.45.5 (07-Jan-2020) Creating filesystem with 7682409472 4k blocks and 480151552 inodes Filesystem UUID: 5b262682-ba8e-4e03-98c2-c742ccebdff8 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 102400000, 214990848, 512000000, 550731776, 644972544, 1934917632, 2560000000, 3855122432, 5804752896 Allocating group tables: done Writing inode tables: done Creating journal (262144 blocks): done Writing superblocks and filesystem accounting information: done
In order to mount our new volumes, we have to create some identifiers:
root@server ~ # blkid /dev/vg00/vol_backups /dev/vg00/vol_backups: UUID="9decc28e-dae7-469f-b1de-7d6da1fd5fb0" TYPE="ext4" root@server ~ # blkid /dev/vg00/vol_media /dev/vg00/vol_media: UUID="5b262682-ba8e-4e03-98c2-c742ccebdff8" TYPE="ext4"
Now, we can mount the volumes.