Skip to content

Instantly share code, notes, and snippets.

@CodeWire
Last active August 11, 2016 19:30
Show Gist options
  • Save CodeWire/4013d4cce07ce4bf315528f8eaaa1ddb to your computer and use it in GitHub Desktop.
Save CodeWire/4013d4cce07ce4bf315528f8eaaa1ddb to your computer and use it in GitHub Desktop.
How to fix partition issues in Linux and format the drive in terminal

How to fix partition issues in Linux and format the drive in terminal

I created this tutorial for a close friend of mine. He had an issue when trying to use the disk partition for Ubuntu 14.04. The issue he was facing during a fresh install using a USB pen drive and partitioning an existing drive. So I hope this helps you bro

I think his exact words where something like

Trav, you have to help me bro! I completely jacked up my computers hard drive and don't know what to do. I have a 30 page paper due tomorrow and I am tripping out that tried to do a fresh install at the worst time. Can you please help? -James

1. Boot from CD or USB into Try Ubuntu. Then open terminal.

Keyboard Shortcuts for Linux Terminal PC: Ctrl + Alt+ T or Ctrl + Alt + F1 if you are seeing a Ubuntu try and load

2. Enter the code below to change directories to dev

cd /dev

3. List the available drives with the code below.

ls sd*

4. Once you locate the drive, then enter it in replace of sda code below.

If your using windows the example above most likely will match your system however, you want to double check as the proceeding steps will delete all data on the drive.

sudo cfdisk sda

5. You should now see the Linux partition window. Use your keyboard the select the following:

Now use your keyboard to arrows or Tab key to select the following

  1. Delete
  2. New > select Primary,
  3. Write > enter yes
  4. Quit

If you completed 1-4 then you have successfully formatted your drive as a primary drive and you should be looking at terminal again. If you're not looking at the main terminal window then you have not quit Linux partition or you might want to repeat step 4 and 5 again.

6. From inside terminal we will use Make File System to format the partition you just created in step 4 and 5.

mkfs : Make File System

sudo mkfs /dev/sda1

Congrats, you can now install your favorite Linux distribution on your drive. Unless you fudged another drive on your multi-drive machine, then just repeat steps 1-6 again for the other drive

Here is a quick checklist of what we just covered...

  • Open Terminal
  • Change Current Directory
  • List Hard Drives
  • Enter then use Linux Terminal Partition & Follow
  • Make File System from Partition

Tutorial On YouTube by: @CodeWire

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment