Add disk and create new volume group and logical volume
Posted: Wed Mar 22, 2023 7:34 pm
Rescan SCSI BUS:
for host in `ls /sys/class/scsi_host/`;do echo "- - -" >/sys/class/scsi_host/${host}/scan; done
fdisk -l
Disk /dev/sdb: 400 GiB, 429496729600 bytes, 838860800 sectors
Disk model: Virtual disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
root@mail:~# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
root@mail:~#vgcreate userdata-vg /dev/sdb
root@mail:~#lvcreate -l 100%FREE -n userdata-lv userdata-vg
root@mail:~#mkfs.ext4 /dev/userdata-vg/userdata-lv
root@mail:~# blkid /dev/userdata-vg/userdata-lv
/dev/userdata-vg/userdata-lv: UUID="1a439a4d-e071-4887-a3fb-6014b3a2e54f" BLOCK_SIZE="4096" TYPE="ext4"
root@mail:~# vim /etc/fstab
ADD:
/dev/disk/by-uuid/1a439a4d-e071-4887-a3fb-6014b3a2e54f /home/user-data ext4 defaults 0 1
for host in `ls /sys/class/scsi_host/`;do echo "- - -" >/sys/class/scsi_host/${host}/scan; done
fdisk -l
Disk /dev/sdb: 400 GiB, 429496729600 bytes, 838860800 sectors
Disk model: Virtual disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
root@mail:~# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
root@mail:~#vgcreate userdata-vg /dev/sdb
root@mail:~#lvcreate -l 100%FREE -n userdata-lv userdata-vg
root@mail:~#mkfs.ext4 /dev/userdata-vg/userdata-lv
root@mail:~# blkid /dev/userdata-vg/userdata-lv
/dev/userdata-vg/userdata-lv: UUID="1a439a4d-e071-4887-a3fb-6014b3a2e54f" BLOCK_SIZE="4096" TYPE="ext4"
root@mail:~# vim /etc/fstab
ADD:
/dev/disk/by-uuid/1a439a4d-e071-4887-a3fb-6014b3a2e54f /home/user-data ext4 defaults 0 1