Attaching >2Tb disks to Linux

HDD

Here is the sequence of commands to make disk space usable in Linux for disks >2Tb (so your regular fdisk won’t help you here).


There are tons of variations of different tools, so these commands are for CentOS 6, I’m attaching a 3Tb RAID1 via USB3.

  • BEFORE connecting the disk run ls /dev/sd*
  • Connect the disk
  • Run ls /dev/sd* again. The difference (let’s assume it’s /dev/sdc) is your new disk
  • Run “parted /dev/sdc”, where /dev/sdc is your new disk. Remember to replace /dev/sdc everywhere with your actual disk name or you will destroy information on your existing drive and ti will be non-trivial to restore.
  • In parted run mklabel gpt
  • I want to create single partition that will occupy entire disk, so I run mkpart primary ext4 0% 100%
  • Run p in parted, it will display the current disk partitioning, something like
    (parted) p                                                                
    Model: JMicron H/W RAID1 (scsi)
    Disk /dev/sdc: 3001GB
    Sector size (logical/physical): 512B/4096B
    Partition Table: gpt
    Number  Start   End     Size    File system  Name     Flags
     1      1049kB  3001GB  3001GB               primary
    

  • I do not plan to use logical volume management (LVM), so nothing else should be done here, quit from partd quit
  • Create new ext4 filesystem on the new partition (don’t forget to replace /dev/sdc1 with the actual disk/partition name) mkfs -t ext4 /dev/sdc1
  • Now new partition should be formatted, you need to mount it
    vi /etc/fstab
    mkdir /data
    # append this in the fstab, don't forget to replace /dev/sdc with your actual drive name
    /dev/sdc1 /data ext4 defaults 1 1
  • finally mount the new partition mount /data
  • Your 3Tb disk space is now available:
    # df -k /data
    Filesystem      1K-blocks   Used  Available Use% Mounted on
    /dev/sdc1      2884231392 205808 2737515044   1% /data
    

Leave a Reply