2

My server has two hard disks. One very limited of around 500 GB and another NOT FORMATTED of more than 1 TB. I need to find this second disk to format it (and eventually mount it to my Red Hat Linux 6 enterprise).

The thing is that I cannot see this second hard disk. I tried with lshw --class disk, but I get the list of the CD ROM and the first hard disk.

How can I find where my disk is and format it?

5

Abruzzo,

In Linux, all your disks can be found under the /dev directory, depending on their type, they can be named hd or sd.

For example, if your first disk is a SATA, it will be named sda. Other entries under /dev will have the same name followed by a number meaning a partition of the disk, like sda1.

Your can find all your disks and partitions using:

ls -ltr /dev/sd*

The new disk will be named sdb.

  • 2
    This is correct, but you should also point out that it won't show any partitions if it's unformatted. It'll have /dev/sdb but not /dev/sdb1 etc. – Matt Jun 14 '13 at 0:11
  • 1
    HI. Unfortunately I cannot see /dev/sdb. I checked looking a different server available with the same specs and there, yes I can see /dev/sdb. I have also compare /dev/disk and I have more entry. Could it be that the hard disk must be ATTACHED or some other operation to show a new hardware? – Abruzzo Forte e Gentile Jun 14 '13 at 6:50
2

Use sudo fdisk (or maybe better sudo cfdisk) to create partitions on a disk. (Create partitions before formatting). With cfdisk you can see which disks have which partitions and which disks have no partitions at all.

You may probably want to create just one partition per disk. This partition's type should be set to "83" (Linux). You may also create a swap (82) partition.

After you create a partition, you can format your partition by the command:

sudo mke2fs -t ext4 /dev/sdb4

(assuming your partition is /dev/sdb4).

Use this command with extreme care as it may probably erase all information in the partition.

If you created a swap partition use the command like the following:

sudo mkswap /dev/sdb2

(assuming your partition is /dev/sdb2).

The last but not least thing to do is to edit /etc/fstab.

2

I'd use this command to list the disks:

sudo fdisk -l

2

All block devices that Linux knows about when it boots are given in /sys/block. If your device isn't there it means Linux did not register it when it booted. In this case, commands given in some of the other answers dealing with upper level filesystem or partition structures aren't relevant (/etc/fstab, fdisk, mount). If your device isn't in /sys/block, then you need to power down, make sure the device is attached and make sure the BIOS recognizes it. If your device is attached and the BIOS does not recognize it, then the device is not receiving power, malfunctioning, or its cable is bad.

1

The requestor clearly mentioned that he cannot see any device in /dev/, so all utilities which depend on this will not show the device. This looks like a hardware problem: if you can, attach the disk to another machine: if this sees it (has an entry in /dev/), the disk is ok, but you have a problem with cables or connectors in the original server. If this also fails, you've most probably got a defunct disk.

0

cat /etc/proc/partitions

or

lsblk

  • The hard disk Is not shown there. Should I look for an 'attach' new hardware operation some where? I really can't find it. Maybe using tools like 'parted' or 'gparted'? – Abruzzo Forte e Gentile Jun 14 '13 at 6:58
  • I've already said: use fdisk or cfdisk – porton Jun 14 '13 at 10:10
0

You need to backtrack and confirm that the machine's BIOS sees the drive. If it doesn't, chances of the OS seeing it are much reduced.

Yes, this means a reboot. If you have a server with a IPMI console (dell drac, hp ilo, cisco cimc, IBM rsa, etc) then there may be additional information there.

0

This is what I use to find new disks:

fdisk -lu | grep ^Disk | grep -v mapper | grep bytes > /tmp/fdisk.1
for HOST in $(cd /sys/class/scsi_host; ls -d host*)
do
   echo $HOST
   echo "- - -" > /sys/class/scsi_host/$HOST/scan
done
fdisk -lu | grep ^Disk | grep -v mapper | grep bytes > /tmp/fdisk.2
diff /tmp/fdisk.1 /tmp/fdisk.2

If you resize any of them, then you need to do this too: reread a new size on a grown disk

MYDISK=sdc
echo 1 >  /sys/block/$MYDISK/device/rescan
fdisk -lu /dev/$MYDISK

maybe - if fdisk shows the new size, but LVM (pvs) doesn't

pvresize /dev/$MYDISK
pvresize /dev/mapper/$MYDISK
multipathd resize map mpathXX

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.