Purchase Linux CDs / DVDs / Flash Drives at OSDisc.com

Welcome to Our Community

While Linux.org has been around for a while, we recently changed management and had to purge most of the content (including users). If you signed up before April 23rd, 2017 please sign up again. Thanks!

  1. More ways to get the info! - we shoot all of our new original content out as well as random messages on Twitter and our newsletter!. Twitter | Newsletter
    Dismiss Notice

'Formating' hard drive

Discussion in 'General Linux' started by Goss, May 7, 2019.

  1. Goss

    Goss New Member

    Joined:
    May 3, 2019
    Messages:
    11
    Likes Received:
    11
    Hey,


    (Log in to hide this advertisement)


    i have external hard drive,
    i want to sometimes format it - not necessary do
    Code:
    sudo dd if=/dev/zero of=/dev/sda1
    but just make it empty f, from terminal not GNU (i know that gparted may be my friend here)

    The thing is, that if i do
    Code:
    sudo mkfs.file_type -n drive_name /dev/sdc1
    sometimes it is empty
    sometimes i open it and content is still there

    should i make some series of steps together with fdisk?

    Thanks!
     
    #1 Goss, May 7, 2019
    Last edited: May 7, 2019
  2. wizardfromoz

    wizardfromoz Super Moderator
    Staff Member Gold Supporter

    Joined:
    Apr 30, 2017
    Messages:
    2,982
    Likes Received:
    2,348
    G'day @Goss and welcome :)

    What Linux distro (distribution) are we using here, eg Ubuntu MATE 18.04, Linux Mint 19.1 Cinnamon, &c?

    Cheers

    Chris Turner
    wizardfromoz
     
  3. dos2unix

    dos2unix New Member

    Joined:
    May 3, 2019
    Messages:
    25
    Likes Received:
    24
    I have it best to fdisk the drive first.

    fdisk -l ... to get a list of the drives. (make SURE you format the right one! :) )

    fdisk /dev/sdc
    then press "g" or "o" to get a new partition table. On disks larger than 1T, use "g". On smaller disks it doesn't matter that much.
    then press "w" to write the new partition table to the disk.

    Sometimes you will get a message about the kernel using the old table, you can reboot your computer, of if it's an external drive, just unplug it.

    After the computer comes back up, or wait a few secs and plug the drive back in. Then run the mkfs command

    I.e. mkfs.ext4 or mkfs.xfs /dev/sdc
     
    Condobloke and Goss like this.
  4. Goss

    Goss New Member

    Joined:
    May 3, 2019
    Messages:
    11
    Likes Received:
    11
    Cool,
    Very informative, thank you,

    So to erase data from partition, every time
    I have to delete the partition first, create it back again, (write), and create file system again?

    Since this is an external drive,
    Is there any file system that should be used for all 3 : Linux/Mac/Windows?

    Are there any special things I should know about, when creating exFat file system? Or would you rather recommend other?
     
  5. dos2unix

    dos2unix New Member

    Joined:
    May 3, 2019
    Messages:
    25
    Likes Received:
    24
    The two main partition table types are MBR/MS-DOS and GPT, (Guid Paritition Table)
    MBR only supports up to 2TB. If you use it on a larger disk, all you will see is 2T.
    Also (I am doing this from memory, so it may not be exactly correct) MBR only supports 3 primary partitions I think, and is it 32 secondary partitions? I really can't remember, to be honest.
    GPT supports up to 128 partitions on Windows, and even more on some UNIX's.

    It seems the most compatible cross platform filesystem is FAT (vfat, exfat, etc...) NTFS also works for some people.
    I personally have found mkfs.vfat -F32 /dev/sdX to work for most everything.

    There are two type's of BIOS's. UEFI and BIOS, actually UEFI isn't really BIOS, but I use that term because that's what most people are familiar with.
    If your BIOS is on an older computer and only works with a keyboard, it is likely BIOS. If it is a newer computer and the BIOS uses a mouses to navigate, it is probably UEFI.
    Some computers will only boot from GPT formatted disks, if they support UEFI mode. Some computers let you switch between BIOS and UEFI mode.
     
    Condobloke, Goss and atanere like this.
  6. atanere

    atanere Moderator
    Gold Supporter

    Joined:
    Apr 6, 2017
    Messages:
    1,838
    Likes Received:
    1,941
    There is no "perfect solution" for file systems. FAT32 is the most universal and can be used by all the computers, but it has limitations (it is very old). The exFAT file system is a more modern improvement, but you'll need to add some extra software to Linux for compatibility. Honestly, I've never made Linux compatible with exFAT, so I'm not even sure what's needed! :confused::D I don't use a Mac so NTFS has been a good solution for just Linux/Windows.

    Here's an article that explains it better.

    Cheers
     
    dos2unix and Goss like this.
  7. Goss

    Goss New Member

    Joined:
    May 3, 2019
    Messages:
    11
    Likes Received:
    11
    Allright,

    i made some research,
    it is possible to use exfat on linux,
    remember that exFAT dont work with linux permissions (on this later)

    A - install packages
    Code:
    sudo apt-get install exfat-fuse exfat-utils
    B - prepare
    check your drives
    Code:
    sudo fdisk -l
    && create mounting directory
    Code:
     test -d /media/your_directory || sudo mkdir /media/your_directory
    C - format MBR Master Boot Record
    Make valid partition types for MBR:
    Code:
    fdisk /dev/sd#
    delete "d" partition, create new table "g", choose number 17 Hidden HPFS/NTF, write "w" || or "t" change a partition's system id

    D - format / MaKe File System MKFS
    Code:
    sudo mkfs.exfat /dev/sd## -n your_new_label_name
    E - mount
    Code:
    sudo mount -t exfat /dev/sd## /media/your_directory
    F - unmount
    Code:
    sudo umount /dev/sd##
    When you use exFAT, remeber that exFAT do not operate with permissions for security,

    if you want to use rsync it shouldnt go with rsync -a sign because of unavoidable erros (sing -a is compilation of some other letters, check man rsync),
    rather go with -rltDv, add -z if you want to compress
    Code:
    sudo rsync -rltDv /from /to

    resources
    https://www.howtogeek.com/235655/how-to-mount-and-use-an-exfat-drive-on-linux/
    https://www.osradar.com/exfat-on-linux/
    https://www.ostechnix.com/format-usb-drives-windows-format-arch-linux/
    https://unix.stackexchange.com/questions/114485/fdisk-l-shows-ext3-file-system-as-hpfs-ntfs
     
    #7 Goss, May 7, 2019
    Last edited: May 8, 2019

Share This Page