Difference between revisions of "Adding a new drive from the command line"

From Da Nerd Mage Wiki
Jump to navigation Jump to search
Line 9: Line 9:


* <code>sudo fdisk -l</code>
* <code>sudo fdisk -l</code>
[[image:Fdisk example 0.png{{!}}300px{{!}}thumb{{!}}'''fdisk -l''' example]]
'''fdisk''' is a dialog-driven program for creation and manipulation of partition tables.
'''fdisk''' is a dialog-driven program for creation and manipulation of partition tables.
* <code>man fdisk</code>
* <code>man fdisk</code>
Line 16: Line 18:
* Blocks starting with '''Device Boot Start...' indicate partitions on those drives.
* Blocks starting with '''Device Boot Start...' indicate partitions on those drives.
* In the case of an unformatted new drive, you'll see a '''Disk''' block that's not followed by a '''Device''' block. Make note of it's name (/dev/sd_)
* In the case of an unformatted new drive, you'll see a '''Disk''' block that's not followed by a '''Device''' block. Make note of it's name (/dev/sd_)
* As an example, we'll pretend it was '''/dev/sdb'''
* In our example, it's '''/dev/sdb'''


= Partition the drive =
= Partition the drive =

Revision as of 03:21, 18 January 2022

Tecmint tutorial

Connect the drive

Either plug the drive into the machine with the power off or hot-swap it in if possible...

(Yes...  Adding a new drive to an ESXi VM is just like hot-swapping.)

Determine the device

  • sudo fdisk -l
fdisk -l example

fdisk is a dialog-driven program for creation and manipulation of partition tables.

  • man fdisk
    • for details...

You'll see a fair bit of output.

  • Blocks starting with Disk /dev/sd_: indicate drives and provide details about them.
  • Blocks starting with Device Boot Start...' indicate partitions on those drives.
  • In the case of an unformatted new drive, you'll see a Disk block that's not followed by a Device block. Make note of it's name (/dev/sd_)
  • In our example, it's /dev/sdb

Partition the drive

For now, we'll just make the new drive one partition.

  • sudo fdisk /dev/sdb
    • n
      • To create a new partition
    • p
      • To make it a primary partition
    • Hit Enter
      • 3 times to pick the default values.
    • w
      • To write the partition table to the drive.

Format the drive

Of course, the drive needs to be formatted before you can use it.

We'll go with Ext4 for now.

  • sudo mkfs.ext4 /dev/sdb1

Mount the drive

Create a mount point for the drive:

  • sudo mkdir /MOUNTPOINT

& mount it for use:

  • sudo mount /dev/sdb1 /MOUNTPOINT

Make the mounting automatic

  • sudo vi /etc/fstab

& add the line:

/dev/sdb1      /MOUNTPOINT      ext4   defaults      0      0