'Formating' hard drive

Goss

New Member
Joined
May 3, 2019
Messages
13
Reaction score
11
Credits
29
Hey,

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!
 
Last edited:


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
 
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
 
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?
 
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.
 
Is there any file system that should be used for all 3 : Linux/Mac/Windows?

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
 
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,

(NTFS do, so exFAT and FAT32 DONT)
supports file permissions for security, a change journal that can help quickly recover errors if your computer crashes, shadow copies for backups, encryption, disk quota limits, hard links, and various other features. Many of these are crucial for an operating system drive—especially file permissions.
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
 
Last edited:

Members online


Latest posts

Top