How To Format A Hard Drive In Ubuntu

While it’s not every day you need to add a new hard drive to your computer, it’s not too complicated. Use this guide to help you install a new hard drive with an existing Ubuntu system and partition it for use. Before you start, you need to consider what hard drive you will be using.

  • Will the drive be used only with Ubuntu?
  • Does the drive need to be accessible from both Ubuntu and Windows?
  • How do you want to divide the free space? As a single partition or multiple partitions?
  • Do you want any partitions larger than 2 TB?

This guide presents the procedure for installing only a single partition drive. Installing a multi-partition drive isn’t that difficult, and you can figure it out using this guide; however, make sure you add an entry in /etc/fstab for each partition, not just the drive. Read: how to format hard drive in ubuntuNote about File System:Drives used only in Ubuntu must be formatted with the ext3/ext4 file system (depending on the version of Ubuntu you use and whether you need Linux backwards compatibility). For sharing between Ubuntu and Windows, FAT32 is usually the recommended file system, although NTFS also works quite well. If you are new to file systems and partitions, please do some preliminary research on the two systems before you go through this procedure. to the new hard drive, open a terminal and run: sudo lshw -C diskIconsPage / example.png This will produce output similar to this sample: * -Disk Description: ATA Disk Product: IC25N040ATCS04-0 Vendor: Hitachi physical id: 0 bus info: [email protected] logical name: /dev /sdb version: CA4OA71A serial: CSH405DCLSHK6B size: 37GB Capacity: 37GB Remember to note the “logical name” entry, as it will be used many times throughout this tutorial. If the drive is still empty and unformatted, then you have two options: format the drive using the command line or install GParted for a graphical approach. Decide if you want the drive to contain a single partition or if you want to split the space between two or more partitions.

Partition using GParted

Contents

If System > Administration > GNOME Partition Editor (or ‘Partition Editor’) is not available, install “GParted” using “sudo apt-get install gparted” from the command line, “Add/Remove software” (or “Add/Remove…”) from the Applications menu or “Synaptic Package Manager” from the System > Administration menu. Open GParted and get started. Gksudo gpartedIconsPage / note.png Always use gksu or gksudo for graphical applications like gparted and sudo for command line applications, like apt-getIn the top right corner of the window, select your new hard drive from the drop-down list, going back to the previous “logical name”. The window will refresh and show you a representation of the new drive. Assuming that the drive is still unused, a white bar will run across the window. Use these steps to partition the drive with a single partition… 1) Right click on the white bar and select “New.” 2) For “New Size”, the number must be the maximum allowed, to fill the entire disk. 3) Select “Primary Partition” 4) Now decide on a file system. Use “ext3” if the drive is to be used only with Ubuntu. To share files between Ubuntu and Windows, you should use “fat32”. If you are unsure, search wikis and forums for advice. 5) Now click Add to calculate the partition. The graphical display will update to show a new partition that covers the entire disk. 6) To finish, click “Apply” or Edit > Apply. Then the disk will be partitioned and formatted. You can now close GParted.

See Also  How To Build A Fishing Rod Power Wrapper

Command line partition

There are two commands that can be used in the command line to partition a new drive: fdisk and parted. fdisk is an older program and its main drawback is that it can only create MBR partitions. parted allows you to create MBR or GPT partitions.

GPT vs MBR

MBR (Master Boot Record) has two main limitations: you cannot have one partition larger than 2 TB and you cannot have more than 4 primary partitions. GPT (GUID Partition Table) can do both of these, but it is part of the EFI standard. This means that your kernel must support EFI. The latest version of the kernel supports EFI, and so do most of the latest distros.

fdisk

Refer back to the logical name you noted earlier. To illustrate, I’ll use /dev/sdb and assume that you want a single partition on the disk, taking up all the free space. If the number of cylinders in the disk is greater than 1024 (and large hard drives always have more), it can, in certain setups, cause problems with:

  • software that runs at boot time (e.g. older versions of LILO)
  • boot and partition software from other operating systems (e.g. DOS FDISK, OS/2 FDISK)
  • Read more: How to keep the canopy from blowing out, on the other hand, this won’t negatively affect you. 1) Start fdisk with the following command: 2) Fdisk will display the following menu:

    • Command (m for help): m action command a toggle boot flag b edit bsd disklabel c toggle dos compatibility flag d delete partition l list known partition types m print this menu n add new partition o create new empty partition table DOS p prints the partition table q exits without saving changes s creates a new blank disk label Sun disklabel t changes the partition’s system id u change the display unit/entry v verify the partition table w write the table to disk and exit x extra function (experts only) Command (m for help):

    3) We want to add a new partition. Type “n” and press enter. Command action e expands primary partition p (1-4) 4) We want a primary partition. Type “p” and enter. Partition number (1-4): 5) Since this will be the only partition on the drive, number 1. Type “1” and enter. Command (m for help): If it asks about the first cylinder, just type “1” and enter. (We are creating 1 partition to use the entire disk, so it will start from scratch.) 6) Now that the partition is imported, select the “w” option to write the partition table to disk. Type “w” and enter. The partition table has been changed! 7) If all went well, you now have a properly partitioned hard drive ready to be formatted. Since this is the first partition, Linux will recognize it as /dev/sdb1, while plate which partition is on is still /dev/sdb.

    Break up

    Refer back to the logical name you noted earlier. To illustrate, I’ll use /dev/sdb and assume that you want a single partition on the disk, taking up all the free space. 1) Start parted like this: sudo parted /dev/sdb2) Create a GPT disklabel (aka partition table) 🙁 parted) mklabel gpt3) Set default unit to TB: (parted) unit TB4) Create one partition takes up all the space on the drive. For 4TB drive: (partitioned) mkpart Partition name? []? main file system type? [ext2]? ext4 Getting started? 0 End? 45) Check if the result is correct: (parted) print There must be one partition taking up the entire drive. 6) Save and exit “parted” 🙁 parted) exit

    Command line format

    To format the new partition as an ext4 file system (best to use in Ubuntu):

    • sudo mkfs -t ext4 /dev/sdb1

    To format the new partition as a fat32 file system (best for use in Ubuntu & Windows):

    • sudo mkfs -t fat32 /dev/sdb1

    As usual, replace “/dev/sdb1” with the path of your own partition. the operating system can still write to the disk even if it is full. However, for disks containing only data, this is not necessary. NOTE: You can run this command on the fat32 file system, but it won’t do anything; Therefore, I strongly advise against running it. Read more: how to add favorites on exodus You can adjust the percentage of reserved space with the “tune2fs” command, like this: sudo tune2fs -m 1 /dev/sdb1 This example takes 1% of the space – Change this number if you want to Create a mount point Now that the drive is partitioned and formatted, you need to select a mount point. This will be the location where you will access the drive in the future. I recommend using the mount point with “/media”, as it is the default setting used by Ubuntu. For this example we will use the path “/media/mynewdrive”

    • sudo mkdir /media/mynewdrive

    Now we are ready to mount the drive to the mount point. Number of Drives You can choose to mount the drive automatically every time you start your computer, or manually only when you need to use it.

    Auto mount on boot

    Note: Ubuntu now recommends using UUIDs instead, see instructions here: https://help.ubuntu.com/community/UsingUUIDYou will need to edit /etc/fstab: or in terminal: Add this line end (for ext3 file system):

    • /dev/sdb1/media/mynewdrive ext3 default 0 2

    Add this line at the end (for fat32 file system):

    • /dev/sdb1/media/mynewdrive vfat defaults 0 2 The defaults can be read, but not write. To write other partitions and specific options FAT must be used. If gnome nautilus is in use, use the mount method, right click from the desktop folder. Then launch mount command from terminal, no options. The last entry should be a FAT drive and should look like: /dev/sda5 on /media/mynewdrive type vfat (rw, nosuid, nodev, uhelper=hal, shortname=mix, uid=1000, utf8, umask=077, flush) All parts between parentheses are mount options and will replace “default” in the fstab file. The “2” at the end instructs your system to run a quick file system check on the hard drive each time it boots. Changing it to “0” will ignore this. Run ‘man fstab’ for more info here.

    You can now run “sudo mount -a” (or restart your computer) for the changes to take effect. If you want to allow normal users to create files on this drive, you can give this user ownership of the drive filesystem’s top directory: (replace ACCOUNT NAME with username)

    • sudo chown -R USERNAME: USERNAME / media / mynewdrive

    or in a more flexible way, realistically if you have multiple users, such as allowing users in the plugdev group (usually those with removable disk capabilities, desktop users) to create files, and subdirectories on disk:

    • sudo chgrp plugdev /media / mynewdrive sudo chmod g + w / media / mynewdrive sudo chmod + t / media / mynewdrive

    Finally “chmod + t” adds the sticky bit, so that people can only delete their own files and subdirectories in a directory, even if they have write permission to it (see man chmod).

    Manual mount

    Alternatively, you may want to manually mount the drive whenever you need it. To mount manually, use the following command: sudo mount /dev/sdb1/media/mynewdrive. /media/mynewdrive Smile :)Need more help?IconsPage / question.png

    • If you have problems or need more help, search the wiki or forum at topqa.info. If you can’t find what you’re looking for, just ask for help.

    Category Software Read more: How to paint wicker furniture with chalk paint

    Last, Wallx.net sent you details about the topic “How To Format A Hard Drive In Ubuntu❤️️”.Hope with useful information that the article “How To Format A Hard Drive In Ubuntu” It will help readers to be more interested in “How To Format A Hard Drive In Ubuntu [ ❤️️❤️️ ]”.

    Posts “How To Format A Hard Drive In Ubuntu” posted by on 2021-10-20 10:59:07. Thank you for reading the article at wallx.net

    Rate this post
    Back to top button