Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Formatting a USB flash drive for in Linux using the command line interface (CLI):
- # How to Format a USB Flash Drive for Windows and Linux in CLI
- # Check the List of Drives and Partitions (List All Block Devices)
- lsblk
- Note: Identify the correct disk carefully by its size. Selecting the incorrect disk may result in data loss.
- In my case, the target disk is:
- - sdb (Disk MOUNT)
- - sda1 (Partition MOUNT
- # List Selected Disk and Partitions (Disk on the First Line, Partitions Below)
- lsblk -fp /dev/sda
- # Before Formatting the Disk, First Unmount It from the Linux Machine
- sudo umount /dev/sda1
- # Wipe Data from /dev/sda (All Partitions Will Be Deleted)
- sudo wipefs -a /dev/sda
- # Check the Disk and Observe that the Partition Table Should Be Deleted
- sudo fdisk -l /dev/sda
- # Create a Partition from Unallocated Space
- sudo cfdisk /dev/sda
- - Choose label type as DOS
- - Select New > Enter
- - Choose Primary > Enter
- - Select Type > Enter > Choose c W95 FAT32 (LBA) > Enter
- - Select Write > Enter > Type Yes > Enter
- - Select Quit
- # Check the Flash Drive for File System (No Partition Created Yet)
- sudo fdisk -l /dev/sda
- # Format the Disk Partition with FAT32 File System (To Create the Partition)
- sudo mkfs.vfat -n "USBFAT32" /dev/sda1
- # Check the File System of the Disk with Partition 1
- lsblk -fp /dev/sda
- # Format with NTFS File System
- sudo mkntfs -Q -L "USBNTFS" /dev/sdb1
- # Format with ext4 (Linux-Based) File System
- sudo mkfs.ext4 -L "USBEXT4" /dev/sdb1
- # Change the File System to Windows Compatible (FAT32)
- sudo mkfs.vfat -n "USBFAT32" /dev/sdb1
- # Eject the Flash Drive
- sudo eject /dev/sdb
- options used in the commands:
- -n: Sets the volume label for the filesystem being created.
- -L: Specifies the label for the filesystem (used with mkfs commands).
- -Q: Performs a quick format (used with NTFS formatting).
- -a: Wipes all filesystem signatures from the specified device (used with wipefs).
- -l: Lists partition tables and details (used with fdisk).
- -f: Forces the operation (used with lsblk to show more details).
- -p: Prints the UUIDs and labels of the partitions (used with lsblk).
- Download the file here https://t.me/c/1480784123/2509/3953
- Admin at t.me/efxtv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement