Saturday, June 14, 2025

Formatting Lunix drives, USB external or internal, how to

Replace ? with your the letter that will be assigned when you plug in and power up the drive,  dmesg -T will tell you what letter has been assigned, df which show you what letters are already in use.

1) gdisk -l /dev/sd? (got the right drive??)

2) gdisk /dev/sd?

3) d = delete existing partion

4) n = create new, 8300 for Linux

5) w = write/exit

6) power off, or reread??

7) gdisk -l /dev/sd? ; umount  /run/media/charles/EFI

8) mkfs -V -t ext4 /dev/sd?1 = newfs

9) tune2fs -L seagate5 /dev/sd?1

10) tune2fs -m 0 /dev/sd?1

11) vi /etc/fstab, LABEL=seagate5  /seagate5       ext4    defaults 0 0

12) mkdir /seagate5; mount /seagate5 ; df


NOTES and example output:

If you are getting Ring error in your dmesg -T output, bad cable usually what causes that. I've had new USB cables go bad right out of the package, have a few different brands on hand!



narnia<129># gdisk /dev/sdd

GPT fdisk (gdisk) version 1.0.9


Partition table scan:

  MBR: protective

  BSD: not present

  APM: not present

  GPT: present


Found valid GPT with protective MBR; using GPT.


Command (? for help): d

Partition number (1-2): 2

or {+-}size{KMGTP}: 

Partition number (2-128, default 2): 

First sector (34-42970644445, default = 409640) or {+-}size{KMGTP}: 

Last sector (409640-42970644445, default = 42970644439) or {+-}size{KMGTP}: 


Current type is 8300 (Linux filesystem)

Hex code or GUID (L to show codes, Enter = 8300): 

Changed type of partition to 'Linux filesystem'


Command (? for help): w


Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING

PARTITIONS!!


Do you want to proceed? (Y/N): y

OK; writing new GUID partition table (GPT) to /dev/sdd.

The operation has completed succes


gdisk -l /dev/sdd

Number  Start (sector)    End (sector)  Size       Code  Name

   1              40          409639   200.0 MiB   EF00  EFI System Partition

   2          409640     42970644439   20.0 TiB    8300  Linux filesystem

narnia<136># mount  /seagate2025
mount: (hint) your fstab has been modified, but systemd still uses
       the old version; use 'systemctl daemon-reload' to reload.