Skip to main content

Linux Hard Drive Management

Mounting a new drive

lsblk # Find the drive you want to use
fdisk /dev/sdc # sdc is an example, change accordingly.
g # make a new GPT table (wipe out old partitions, start fresh)
n
# enter enter enter (use 1 partition, use entire disk)
w # write changes
reboot now # might not be needed, just look at output of fdisk.
mkfs.ext4 /dev/sdc1 # make that blank partition -> ext4
blkid /dev/sdc1 # grab UUID for drive for next step
mkdir /mnt/driveName # driveName can be whatever you want
vim /etc/fstab # place in here so it auto mounts on boot
# Place the following into that file:
UUID=XXXXXXX /mnt/driveName ext4 defaults 0 0
# save & exit
mount -a
cd /mnt/driveName # Done.

Growing an existing partition

  1. Resize (virtual) disk with any solution (GParted, etc).
  2. Use lsblk to get the partition you want to expand.
  3. sudo growpart /dev/sda 2 # 2 is the partition you want to increase in size.
  4. sudo resize2fs /dev/sda2