Mounted disk does not contain SELinux labels.

After mounting the disk the listed below problem appears.

root# mount -v /dev/sdb1 /mnt/backup
mount: /mnt/backup does not contain SELinux labels.
You just mounted an file system that supports labels which does not
contain labels, onto an SELinux box. It is likely that confined
applications will generate AVC messages and not be allowed access to
this file system. For more details see restorecon(8) and mount(8).
mount: /dev/sdb1 mounted on /mnt/backup.
root#

The SELinux warning is fixed by “restorecon -R /mnt/backup“.

Find out whether a filesystem check is scheduled for the next boot.

To find out whether a filesystem check is scheduled for the next boot. Use this command: “dumpe2fs -h /dev/disk”.
Fsck will run if mount count is equal or greater than maximum mount count, or if “next check after” is passed.

Continue reading “Find out whether a filesystem check is scheduled for the next boot.”

Creating virtual disks using dd and losetup.

To create an image file, in this case a “virtual disk”, use “dd” command. The below command will write zeros to a file of a specified size.

dd if=/dev/zero of=1GB_disk.img bs=1M count=1024

Once completed, a partition can be created using cfdisk or fdisk command. Then the filesystem should be created using mkfs.ext4

cfdisk 1GB_disk.img

Now, you can proceed to setup a loop device for you image. This requires the use of “losetup”. This command will assign an available loop device (-f option to find one) to the partition on the image, and show the name a loop device (–show option):‚Äč

losetup -Pf --show 1GB_disk.img

If successful, you should be able to access the partition by mounting the image.

[root@s1 disk]# lsblk|grep loop
loop0 7:0 0 1G 0 loop /mnt/disk
[root@s1 disk]#

mount /dev/loop0 /mnt/disk

[root@s1 disk]# df -hP /mnt/disk/
Filesystem Size Used Avail Use% Mounted on
/dev/loop0 976M 46M 863M 6% /mnt/disk
[root@s1 disk]#

To remove a loop device just run:

losetup -d /dev/loop0

Removing volume group and logical volume after physical drive has been removed

root:/ # lvs
/dev/5gbdisk_vg/5gbdisk: read failed after 0 of 4096 at 1073676288: Input/output error
/dev/5gbdisk_vg/5gbdisk: read failed after 0 of 4096 at 1073733632: Input/output error
/dev/5gbdisk_vg/5gbdisk: read failed after 0 of 4096 at 0: Input/output error
/dev/5gbdisk_vg/5gbdisk: read failed after 0 of 4096 at 4096: Input/output error
/dev/sdc: read failed after 0 of 4096 at 0: Input/output error
/dev/sdc: read failed after 0 of 4096 at 10737352704: Input/output error
/dev/sdc: read failed after 0 of 4096 at 10737410048: Input/output error
/dev/sdc: read failed after 0 of 4096 at 4096: Input/output error
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
home sp3tosp4 -wi-ao--- 4.00g
var sp3tosp4 -wi-ao--- 8.00g
root:/ #

When the disk was physically removed, the /dev/sdc and this device nodes wasn’t automatically removed. The above errors are clearly indicating that /dev/sdc and /dev/myvg/mylv can no longer be read due to the removal of the disk.
Remove the stale /dev/sdc device node and clean up the stale device-mapper nodes. In the above example, this would be accomplished by either a simple reboot, or by running the following:

root:/ # dmsetup remove –force /dev/5gbdisk_vg/5gbdisk
root:/ # echo 1 > /sys/block/sdc/device/delete

root:/ # pvs
PV VG Fmt Attr PSize PFree
/dev/sdb sp3tosp4 lvm2 a-- 16.00g 4.00g
root:/ # lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
home sp3tosp4 -wi-ao--- 4.00g
var sp3tosp4 -wi-ao--- 8.00g
root:/ #

Linux force the rereading of the disk geometry.

Assuming you know the device name of the disc you have expanded /dev/sdg then you can simply issue the following command to force the rereading of the disk geometry.

debian02:~ # echo 1 > /sys/class/scsi_device/0:0:6:0/device/rescan

To determine the SCSI ID from device names enter: ls -d /sys/block/sd*/device/scsi_device/* |awk -F '[/]' '{print $4,"- SCSI",$7}'

For example:
debian02:~ # ls -d /sys/block/sd*/device/scsi_device/* |awk -F '[/]' '{print $4,"- SCSI",$7}'
sda - SCSI 0:0:0:0
sdb - SCSI 0:0:1:0
sdc - SCSI 0:0:2:0
sdd - SCSI 0:0:3:0
sde - SCSI 0:0:4:0
sdf - SCSI 0:0:5:0
sdg - SCSI 0:0:6:0
sdh - SCSI 0:0:8:0
sdi - SCSI 0:0:9:0
sdj - SCSI 0:0:10:0
sdk - SCSI 0:0:11:0
sdl - SCSI 0:0:12:0
sdm - SCSI 0:0:13:0
sdn - SCSI 0:0:14:0
sdo - SCSI 0:0:15:0
debian02:~ #

Match Linux SCSI Devices (sdX) to Virtual Disks in VMware

To determine the SCSI ID from device names enter ls -d /sys/block/sd*/device/scsi_device/*

debian02:~ # ls -d /sys/block/sd*/device/scsi_device/*
/sys/block/sda/device/scsi_device/0:0:0:0 /sys/block/sde/device/scsi_device/0:0:4:0 /s
/sys/block/sdb/device/scsi_device/0:0:1:0 /sys/block/sdf/device/scsi_device/0:0:5:0 /s
/sys/block/sdc/device/scsi_device/0:0:2:0 /sys/block/sdg/device/scsi_device/0:0:6:0 /s
/sys/block/sdd/device/scsi_device/0:0:3:0 /sys/block/sdh/device/scsi_device/0:0:8:0 /s
debian02:~ #

You can see the the device name, and 4 numbers a:b:c:d

a = Hostadapter ID
b = SCSI channel
c = Device ID
d = LUN

The Device ID is always c. At the controller, it depends whether you are using the Paravirtual (b) controller, or the LSI Logic (a) controller.

On the VMware it looks like that:

debian02

/dev/sda has the SCSI ID 0:0:0:0 which is the equivalent to 0:0 and is Hard Disk 1 on VMware.
/dev/sde has the SCSI ID 0:0:4:0 which is the equivalent to 0:4 and is Hard Disk 5 on VMware.
/dev/sdo has the SCSI ID 0:0:15:0 which is the equivalent to 0:15 and is Hard Disk 16 on VMware.

When you remove and add disks, the order might change so always double check if you want to remove disks from a Virtual Machine.

Also you can use the following command if you want an output that is better to read:

debian02:~ # ls -d /sys/block/sd*/device/scsi_device/* |awk -F '[/]' '{print $4,"- SCSI",$7}'
sda - SCSI 0:0:0:0
sdb - SCSI 0:0:1:0
sdc - SCSI 0:0:2:0
sdd - SCSI 0:0:3:0
sde - SCSI 0:0:4:0
sdf - SCSI 0:0:5:0
sdg - SCSI 0:0:6:0
sdh - SCSI 0:0:8:0
sdi - SCSI 0:0:9:0
sdj - SCSI 0:0:10:0
sdk - SCSI 0:0:11:0
sdl - SCSI 0:0:12:0
sdm - SCSI 0:0:13:0
sdn - SCSI 0:0:14:0
sdo - SCSI 0:0:15:0
debian02:~ #