Pragmatism in the real world

Setting up a new hard drive in Linux

I recently added a second SSD to my Linux server and had to look up how to format it and set it up, having not taken notes for the first one. These are the notes I took the second time.

This is all done from the command line and the monospace text is to be typed directly – though change the identifiers if requried.

  1. sudo lshw -C disk to confirm disk is seen by the BIOS and work out it’s path. In this case, it’s /dev/sdb
  2. Partition the disk with a single partition:
    1. sudo parted /dev/sdb
    2. mklabel gpt
    3. unit TB
    4. mkpart
      • Partition Name: primary
      • File system type: ext4
      • Start: 0%
      • End: 100%
    5. print to check everything is correct
    6. quit to save and exit
  3. Format the disk:
    1. sudo mkfs -t ext4 /dev/sdb1
    2. (press the <return> key to create the journal)
  4. Create mount point:
    1. sudo mkdir /media/ssd2
  5. Update the filesystem table:
    1. sudo vim /etc/fstab
    2. Add this line: /dev/sdb1 /media/ssd2 ext4 defaults 0 2
    3. Mount it now: sudo mount -a
  6. Set permissions:
    1. sudo chgrp plugdev /media/ssd2
    2. sudo chmod g+rws /media/ssd2
    3. sudo chmod +t /media/ssd2

All done and working. I then updated by backup scripts to back this drive up to an external hard drive too.

Thoughts? Leave a reply

Your email address will not be published. Required fields are marked *