Monday, December 8, 2014

Adding Disks under Linux

Adding Disks under Linux

Once the disk has been physically connected, the system should detect it during the boot process. The dmesg command can be used to check the boot messages:

  Vendor: HP        Model: C3724S            Rev: 5173
  Type:   Direct-Access                      ANSI SCSI revision: 02
Detected scsi disk sdc at scsi0, id 3, lun 0

Device nodes

It may be necessary to create device nodes for the new disk. Under Linux, device nodes use the format /dev/[r]sdXN, where X is a letter specifying the drive number (with a being the lowest SCSI ID, bbeing the next highest, etc), and N is the partition number on that drive. The MAKEDEV command is used to create new device nodes. For example, to create a device node for the third SCSI disk:

# cd /dev; MAKEDEV sdc

It is important to note that disk ordering is done at boot time, so there is not a direct mapping between the letter used to identify the drive and the SCSI ID of that drive. If the SCSI ID of the new drive is lower than that of one of the existing drives, the naming scheme for all of the higher-numbered will be changed, possibly causing problems in the /etc/fstab configuration.

Partitioning

Partitioning and labeling a disk under Linux is done with the fdisk command. There is also a screen-oriented version called cfdisk, which has essentially the same commands.
For instructions on how to use fdisk to partition a drive, see the Linux Installation and Getting Started guide, particularly the section on Creating Linux partitions

Making new filesystems

To create a new filesystem on the disk, use the mkfs command:
# mkfs -t ext2 /dev/sdc1
This will create an ext2 type filesystem on the third SCSI disk, first partition.
To check the new filesystem for integrity, use fsck# fsck -f -y /dev/sdc1 The -f option forces fsck to check the new filesystem, even if it is considered to be clean. The -y option tells fsck to assume a "yes" answer to any questions normally posed to the user.

No comments:

Post a Comment

  How to Change Instance Type & Security Group of EC2 in AWS By David Taylor Updated April 29, 2023 EC2 stands for Elastic Compute Cloud...