Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: How to format a new hard disk.

  1. #1
    Join Date
    Sep 2005
    Beans
    109

    Question How to format a new hard disk.

    How to "format" a new hard disk.
    So, you have been visited by the gigabyte fairy and you have a brand new external USB hard drive, you might be irked to find that it's already formatted with the NTFS filesystem because it's a default world out there ...
    What to do?

    (This will work for any old hard drive, so even if you have an internal one - you're good )

    Stuff I assume
    Your drive needs to be plugged-in and your system must see it. You should see an icon appear on your desktop. If not then open a console and try this:
    If you have an external USB drive:
    Code:
    cd /dev
    ls s*
    If you have an internal drive:
    Code:
    cd /dev
    ls hd*
    You should see a list of things something like this for example:
    Code:
    sda  sda1  sdb  sdb1
    That shows you that your system knows about two physical external drives (sda and sdb) as well as the partition that is on each. So, now you know that your machine knows about your new drive(s).

    Make sure that your new drive is not mounted. Let's assume it's name is sda1 (please substitute your own details), at the console type:
    Code:
    mount | grep sda1
    If you see any results then it's mounted, so do this:
    Code:
    umount -l /dev/sda1
    Warning
    Please ensure that you know exactly which drive you are going to erase and format... I speak from experience, hoo-boy! So, make sure you know which name identifies your drive. hdb or sda or sdc or whatever. Be sure. If you are not sure, then use whatever built-in tools that your distro has to try and get yourself oriented. You can also do this at the console:
    Code:
    fdisk -l
    Now look at all the drives carefully, look at their types and sizes and make your mind up.

    GUIs and Consoles
    I use Kubuntu 6.06. I quite frankly could not figure out how to prepare my new USB drive from any of the system control panels. It was too confusing and ambigous. I don't know (and can only hope) whether Ubuntu is any better. The upshot? I will use the command line!

    Let's get going!
    Removing and creating a partition
    Having decided your drive's name (let's call it sda) we must now remove the default partition that the manafacturer put there:
    Code:
    sudo fdisk /dev/sda
    This will start fdisk. We want to remove the partion(s), there should only be one.
    Press d <enter>(for delete).
    It might ask you for the partition number, press 1 and enter. If there are more then delete them too.

    Now to make a new partition.
    Press n <enter> (for new), then p <enter> (for primary), then 1 <enter> and then simply press enter for the next two questions.
    This will make a new partition that uses the entire disk. If you want more complex partitioning then read the fdisk manual (man fdisk) or use parted or some other app.
    Here's what we did with n, the values will differ from yours:
    Code:
    Command (m for help): n                                                      
    Command action                                                               
       e   extended                                                              
       p   primary partition (1-4)                                               
    p                                                                            
    Partition number (1-4): 1                                                    
    First cylinder (197-621, default 197):                               
    Using default value 197                                                      
    Last cylinder or +size or +sizeM or +sizeK (197-621, default 621): +128M
    Now to write the new partion and exit, press w and enter.
    You should be ready to make a filesystem now.

    Making a filesystem : "Formatting"
    You need to put a system in-place, on the disk, such that it can handle files. This is called (unsurprisingly) a filesystem.
    The one we are going to use is called "ext3". On Gnu/Linux we are spoiled for choice and there are loads of filesystems you can use, go do some research if you want to.
    So, let's make the filesystem:
    Code:
    sudo mkfs.ext3 /dev/sda1
    * Note the 1 at the end, because we are making the filesystem in that partition (thanks Mike)

    Now it will go off and do strange stuff, simply wait for it to finish.

    Using the new file system
    Well, at this point you should be able to right-click on the icon (on your Desktop) and choose "mount" (I assume that's the verb it will present to you). After that you should be able to open a window and use the drive*
    * all this assumes it's an external USB drive.
    If you cannot then you will need to mount it yourself, try:
    Code:
    sudo mkdir /media/sda1
    sudo mount /dev/sda1 /media/sda1
    Note: We are actually mounting the first partition on the drive, hence the 1 at the end: sda1
    And the mounted directory can be anywhere you like, but its common location is /media.

    If those two steps worked then you are 90% done.

    You may need to make a single folder in the new drive and give it your user permissions:
    Code:
    cd /media/sda1
    sudo mkdir afolder
    chown you:you afolder
    Where you insert your username and desired folder name as appropriate.

    Please search around on the subject of your fstab and getting the drive to mount automatically when you reboot. There are plenty of howto's out there on that subject. I must post and run now.

    HTH

    Keywords for searching:
    format filesystem ext ext2 ext3 NTFS linux make new external internal USB drive disk partition
    Last edited by Bigglez; October 8th, 2006 at 11:32 PM. Reason: Fix errors
    (K)Ubuntu User # 5935
    Need a TTF Font Manager for Gnu/Linux? Try Fonty Python!

  2. #2
    Join Date
    Jul 2006
    Location
    Various parts of the US
    Beans
    108

    Re: How to format a new hard disk.

    I think you intend to mkfs.ext3 the partition, not the whole device, hence:
    Code:
    sudo mkfs.ext3 /dev/sda1
    Also, you need to specify a mount point for the device, since it's new, it won't be in fstab, so this:

    Code:
    sudo mount /dev/sda1
    Should be this:

    Code:
    sudo mkdir /where/you/want/this/drive/to/be/mounted
    sudo mount /dev/sda1 /where/you/want/this/drive/to/be/mounted
    - Mike
    -- Mike

  3. #3
    Join Date
    Sep 2005
    Beans
    109

    Re: How to format a new hard disk.

    When it comes to external USB drives I have since found it best not to create any mount points (i.e. folders in /media) for the devices. This is because it gets done automagically by Ubuntu.

    If you run into trouble and it cannot mount things, then look into making your own mountpoints.


    /d
    (K)Ubuntu User # 5935
    Need a TTF Font Manager for Gnu/Linux? Try Fonty Python!

  4. #4
    Join Date
    Sep 2006
    Beans
    11

    Re: How to format a new hard disk.

    hi I'm trying to make new virutal hd work in vmware (ubuntu under windows host)
    i add new HD boot system and follow this tutorial and everything is ok until I get to part when I type in command

    sudo mkfs.ext3 /dev/sdb1
    i get this error

    mke2fs 1.40.2 (12-Jul-2007)
    mkfs.ext3: inode_size (128) * inodes_count (0) too big for a
    filesystem with 0 blocks, specify higher inode_ratio (-i)
    or lower inode count (-N).
    anyone know what the problem might be

  5. #5
    Join Date
    Feb 2008
    Beans
    8
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: How to format a new hard disk.

    ok
    Last edited by gamont; May 9th, 2008 at 09:34 PM.

  6. #6
    Join Date
    Aug 2006
    Beans
    48

    Re: How to format a new hard disk.

    This has been very handy! Thanks a bunch! Worked well with my new USB drive

  7. #7
    Join Date
    Mar 2005
    Beans
    139

    Re: How to format a new hard disk.

    Can't we just use GParted?

    For a new SATA hard disk, GParted must be the easiest option surely. Does it not work for a USB drive?

  8. #8
    Join Date
    Dec 2007
    Beans
    1

    Re: How to format a new hard disk.

    Quote Originally Posted by Dabrorius View Post
    hi I'm trying to make new virutal hd work in vmware (ubuntu under windows host)
    i add new HD boot system and follow this tutorial and everything is ok until I get to part when I type in command



    i get this error



    anyone know what the problem might be
    After you ran sudo fdisk /dev/sdb1 , and deleted the existing partitions by hitting the d key and creating a new one by hitting n, did you choose 'p' (primary) or 'e' (extended).

    If you chose 'e', re-run the command and choose 'p' instead. That should solve your problem.

  9. #9
    Join Date
    Aug 2010
    Location
    Philippines
    Beans
    192
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How to format a new hard disk.

    geee.. thanks for this one... finding solution for formatting my new hard disk.
    -ubuntu philippines member id -Website : Jcyberinux
    -rjdreyes po, tangkilikin ang atin. - LINUX USER : 525764


  10. #10
    Join Date
    Oct 2007
    Beans
    183
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: How to format a new hard disk.

    Quote Originally Posted by sml View Post
    For a new SATA hard disk, GParted must be the easiest option surely. Does it not work for a USB drive?
    It does: I just repartitioned and reformatted an external USB SATA (Samsung HM641JI) using gparted, and all seems well.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •