How to create a block device on CentOS 7

General support questions
cuian01
Posts: 1
Joined: 2018/04/23 09:25:39

How to create a block device on CentOS 7

Postby cuian01 » 2018/04/23 09:29:41

Dear All,
I got a VM which has CentOS 7 installed. I have to get a block device ready in the system (not mounted) for a software.

Can you help to show the instruction or link to the instructions how to do it?

Thanks

User avatar
TrevorH
Forum Moderator
Posts: 22590
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How to create a block device on CentOS 7

Postby TrevorH » 2018/04/23 09:45:04

Attach device to VM, load driver (probably done automatically by udev/kernel), done.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

hunter86_bg
Posts: 1103
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: How to create a block device on CentOS 7

Postby hunter86_bg » 2018/04/23 10:31:14

1. Attach the disk to the VM
2. Verify that the kernel detected it:

Code: Select all

dmesg -T
should indicate new block device.

Otherwise scan the scsi hosts.To find your scsi hosts:

Code: Select all

find /sys -type f -name "scan" -print

Then do this for each host:

Code: Select all

echo "- - -" > /sys/path/to/hostX/scan

Check again with dmesg.

3. Work with the block device.If you use LVM (by default) then:

Code: Select all

pvcreate /dev/new_block_device

Then extend/create the VG which this block device will be a member of.
Next, extend or create a Logical Volume which will be the block device that the system will be actually using.
Last, create and mount your File System.Note that XFS cannot be shrink in any circumstances.
WARNING: ALWAYS MAKE BACKUP AND SNAPSHOT WHEN WORKING WITH BLOCK DEVICES !

bigdaddy68
Posts: 5
Joined: 2018/04/23 20:16:34

Re: How to create a block device on CentOS 7

Postby bigdaddy68 » 2018/04/23 21:45:36

i always thought that 'mknod' was able to create a block or char device in /dev