Packetwatch.net

Add a hard drive in Red Hat Enterprise Linux



Last modified: April 22, 2016

Contents
1 - Summary
2 - Device information
3 - Create partition
4 - Format partition
5 - Mount partition
6 - Modify fstab


1 - Summary

This guide will show how to add a new hard drive in Red Hat Enterprise Linux.
It explains how to partition, format and mount a EXT4 partition. This has been
tested in Red Hat Enterprise Linux 6.


2 - Device information

Find the device information. In our example, it's sdi.
# dmesg | tail -n 21
usb 10-1: new SuperSpeed USB device number 10 using xhci_hcd
usb 10-1: New USB device found, idVendor=174c, idProduct=55aa
usb 10-1: New USB device strings: Mfr=2, Product=3, SerialNumber=1
usb 10-1: Product: 012345678901234567890123456789012345678901234567
usb 10-1: Manufacturer: 01234567890123456789012345678901234567890123
usb 10-1: SerialNumber: 0123456789ABCDEF
usb 10-1: configuration #1 chosen from 1 choice
scsi22 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 10
usb-storage: waiting for device to settle before scanning
usb-storage: device scan complete
scsi 22:0:0:0: Direct-Access     ST320006 44NS             GG18 PQ: 0 ANSI: 5
sd 22:0:0:0: Attached scsi generic sg10 type 0
sd 22:0:0:0: [sdi] 3907029168 512-byte logical blocks: (2.00 TB/1.81 TiB)
sd 22:0:0:0: [sdi] Write Protect is off
sd 22:0:0:0: [sdi] Mode Sense: 43 00 00 00
sd 22:0:0:0: [sdi] Assuming drive cache: write through
sd 22:0:0:0: [sdi] Assuming drive cache: write through
 sdi: unknown partition table
sd 22:0:0:0: [sdi] Assuming drive cache: write through
sd 22:0:0:0: [sdi] Attached SCSI disk


3 - Create partition

Create a partition. We will create a EXT4 partition.
# parted /dev/sdi
GNU Parted 2.1
Using /dev/sdi
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
(parted) print
Model: ST320006 44NS (scsi)
Disk /dev/sdi: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start  End  Size  File system  Name  Flags

(parted) mkpart
Partition name?  []?
File system type?  [ext2]?
Start? 0
End? -1
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I
(parted) print
Model: ST320006 44NS (scsi)
Disk /dev/sdi: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name  Flags
 1      17.4kB  2000GB  2000GB

(parted) quit
Information: You may need to update /etc/fstab.


4 - Format partition

Format the partition.
# ls -1 /dev/sdi*
/dev/sdi
/dev/sdi1
# sudo mkfs.ext4 /dev/sdi1
Password:
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
122101760 inodes, 488378397 blocks
24418919 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
14905 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
        102400000, 214990848

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.


5 - Mount partition

Create a mount point and mount the partition.
# sudo mkdir /backups
Password:
# sudo mount -t ext4 -o nodev,nosuid /dev/sdi1 /backups
Password:
# df -h /backups
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdi1       1.8T   68M  1.7T   1% /backups


6 - Modify fstab

Finally, modify /etc/fstab for the new partition. If it's a USB drive, you can
modify /etc/rc.local to mount it on startup.


Last modified: Thu Jan 1 00:00:00 1970 UTC
Packetwatch Research 2002-2024.