Disk management
Commands:
fdisk -l
- list disks and partitionsfdisk /dev/sdX
- access the disk with fdisk utilitymount /dev/sdX1 /mnt/...
- mount a partitionumount /mnt/...
- unmount a partitionmkfs.ext4 /dev/sdX1
- format a partition with ext4 file systemlsblk
- list block devices (disks and partitions)
Tip
fdisk
is a command-line utility that provides disk partitioning functions
How to format disk with NTFS file system on Linux:
fdisk -l
- list disks and partitionsfdisk /dev/sdX
- access the disk with fdisk utility to create a partitionn
- create a new partitionp
- primary partition1
- partition numberEnter
- default first sectorEnter
- default last sectorw
- write table to disk and exitmkfs.ntfs /dev/sdX1
- format a partition with NTFS file system
How to use a disk on Windows, that has been formatted on Linux:
Note
If you want to use this disk on Windows, you will need to change the partition type from 0x83
to 0x07
. You can do this with fdisk
utility.
fdisk -l
- list disks and partitionsfdisk /dev/sdX
- access the disk with fdisk utilityp
- identify the partition by printing the partition tablet
- change partition type7
- select partition type0x07
(HPFS/NTFS/exFAT)w
- write table to disk and exit
Note
Now you can use this disk on Windows. But if you want to use it on Linux again, you can run a command ntfsfix /dev/sdX1
.