Middle
How can you format a disk in Linux?
sobes.tech AI
Answer from AI
In Linux, disk formatting typically involves creating a new file system on a partition or disk. The main steps:
- Identify the device (e.g.,
/dev/sdb1) usinglsblkorfdisk -l. - If necessary, create or modify partitions using
fdisk,parted, orgdisk. - Format the partition with a file system creation command, for example:
- For ext4:
sudo mkfs.ext4 /dev/sdb1
- For xfs:
sudo mkfs.xfs /dev/sdb1
- For vfat (FAT32):
sudo mkfs.vfat /dev/sdb1
- After formatting, you can mount the partition:
sudo mount /dev/sdb1 /mnt
Important: Formatting destroys all data on the partition, so be careful and ensure you have selected the correct disk/partition.