3

i have installed RHEL on virtual machine using vmware. i have added the extra hard drive from vmware.

Now Linux is not showing that new hard drive installed.

HOw can i do that

6 Answers 6

6

Procedure that I use after you add the disk:

  1. Reboot the machine
  2. Check to see if the disk is present using ls -l /dev/sd*. If you started with only one disk and added another you should see /dev/sdb
  3. fdisk /dev/sdb and partition the disk. I'd recommend adding primary partition 1 using the entire disk.
  4. reboot the system to let the system create the other necessary device files. In the above case /dev/sdb1.
  5. Check to see if /dev/sdb1 is present. If so, then you can create a filesystem on the disk.
  6. mkfs -t ext3 /dev/sdb1 to create the new filesystem.
  7. I'd do the following also: tune2fs -i 0 -c 0 -m 1 -e panic /dev/sdb1. This inhibits the inconvient full fscks at mounts after a number of days and/or number of mounts. The system will still fsck the filesystem if necessary. Only reserve 1% of the diskspace for the root user. Otherwise, the default is to basically reserve 10%. Panic the system once filesystem errors are detected, default is to continue operations with the filesystem R/O.
  8. mkdir /mountpoint
    8a. chmod 755 /mountpoint. VERY important.
  9. add to the /etc/fstab:

    /dev/sdb1 /mountpoint ext3 defaults 0 1

  10. Reboot your system and and do a df and see that your mount is present and active.

  11. You are done.
1
  • 1
    These days I might be inclined to use the ext4 filesystem format instead of the ext3 filesystem format.
    – mdpc
    Jul 20, 2017 at 18:39
0

You need to use LVM. Just read section 9.5.6. Extending a volume group from http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-system-config-lvm.html

4
  • This definitely goes against VMware best-practice. LVM in a virtualized environment is an abstraction layer on top of an abstraction layer on top of an abstraction layer, and can seriously screw with efforts to align guest partitions, and there's no reason to use it to dynamically expand volumes because virtual disks can be grown while the system is running. Best practice with a Linux guest OS is to use raw disks or properly-aligned partitions, and to not place more than one partition on a virtual disk unless it's necessary. Nov 18, 2010 at 19:27
  • well, it was the only way I found to do this when I wanted to increase the size of the hard drive of my machine that is in a cloud. When I increased the hard drive size my machine could still not see the extra space and the way to increase the partition is with LVM. I presumed this is what he asked for. Nov 22, 2010 at 11:04
  • @jgoldschrafe Do you have a link/source for your best practice recommendation? Nov 6, 2015 at 17:10
  • 1
    @JoshuaHanley That comment was made back in 2010, when the default installation behaviors of most distributions were woefully unaware of partition alignment and would gleefully partition vdisks with a 63-sector offset and some arbitrary LVM metadata size, crippling I/O performance on many workloads. Most distributions are smarter now, and that recommendation probably doesn't matter much in late 2015, but I do still encourage everyone to understand the RAID stripe characteristics of their hardware configurations and their software workloads. Nov 7, 2015 at 17:59
0

If you've added the drive while the guest OS is still running, it doesn't know about the new drive yet. There are ways to force a system to look for new disks by forcing a scsi system scan. The easiest way to do this is to simply reboot the guest.

0

If you hot added a SCSI disk, you can check check dmesg to see if there is any info:

$ dmesg | grep sd

This should give you lots of information about the SCSI disks discovered. If for some reason you do not want/can reboot and the disk was not discovered, you can force a rescan of the SCSI bus by doing:

# echo "- - -" > /sys/class/scsi_host/hostX/scan

Where hostX should be a valid value, which you can get by executing:

ls /sys/class/scsi_host

If you have only one SCSI controller, then it should be host0

Once you executed this command the disk should be available if the vmware version supports hotadding disks. Look at the output of dmesg again.

If the version of vmware does not support hotadd (meaning it does not inform the guest os about this new hardware), just reboot.

After this, if the disk is not formatted you should do it. Decide whether you want to use LVM, or other type of partitions / filesystems. You could use fdisk, parted, etc, to create this partitions.

Finally you can mount the new partition by doing

# mount /dev/<device> /mount/point

Where could be something like sdb1. and /mount/point is the place on the filesystem where you want this device to be mounted /mnt, for example

0

Before adding the new drive, simply shutdown the VM then add the the new Disk then power on the VM again. Now you can check the new HDD via fdisk command:

fdisk -l (show all the available partitions and disks)

If you want to partition the new drive then use the following command

fdisk /dev/sdb (I assume sdb is the new drive, please check in your case then press n for new partition)

Then follow the screen instructions, they are pretty straightforward.

0

A better way to partition the new drive is in this good article using "parted" which I followed: https://linuxhint.com/parted_linux/

This new partition will be visible after the VM guest is rebooted.

Also, I don't think editing the /etc/fstab is the right way to do it, but can't find any Red Hat article how to do it properly in the Linux command line.

On AIX it was not recommended to edit the /etc/fstab file, there is the tool "smitty" that does that correctly.

1
  • Editing fstab is a correct way. There also may be a /etc/fstab.d directory and it may be better to add a new file there, there must be a readme file about how to use a directory. // It's a shame added disk don't appear without reboot. In Proxmox VE when you add a disk or even expand an existing disk, you may use newly allocated space immediately, without any reboots or other downtime. Feb 13, 2021 at 9:35

You must log in to answer this question.