Whether it's for cross-platform compatibility or to make the most out of storage
space, partitioning a USB drive into multiple file systems is a commonly sought
task. In this article, we'll guide you through the process of partitioning a USB
drive into two file systems:
ext4 for Linux and
NTFS for Windows, using
fdisk utility on Ubuntu.
- A USB drive you'd like to format and partition.
- A system running Ubuntu.
mkfsutilities (pre-installed on most Ubuntu distributions).
Warning: The following steps will erase all data on the USB drive. Ensure you've backed up any important data.
Here is a step by step guide on how you can create a new file system and partition your USB drive in Ubuntu
1. Identify the USB Drive
First, plug in your USB drive. Then, use the
lsblk command to identify your
drive's device name:
Look for your drive based on its size and remember its device name, typically
/dev/sdb1, which represents a partition).
For the purpose of this guide, we'll assume the USB drive is
To start partitioning the drive, enter:
sudo fdisk /dev/sdb
3. Delete Existing Partitions
fdisk, you'll be presented with a command prompt. To delete
dand press Enter.
- If multiple partitions exist, you'll be asked which one to delete. Repeat this step until all partitions are deleted.
4. Create the First Partition (ext4)
nfor a new partition.
pfor a primary partition.
- For partition number, press Enter to accept the default of
- For the first sector, press Enter to accept the default.
- For the last sector, define the size you want for this partition (e.g.,
+8Gfor an 8 GB partition).
- You've now allocated space for the first partition.
5. Create the Second Partition (NTFS)
- Again, type
nfor a new partition.
- Accept the defaults for the partition number and the first sector.
- For the last sector, you can press Enter to allocate the rest of the space on the drive to this partition.
6. Write Changes
After making the above configurations:
wto write the changes. This will format the USB drive and create the two partitions.
Create File Systems on the Partitions
Create ext4 File System
sudo mkfs.ext4 /dev/sdb1
This command formats the first partition with the
ext4 file system.
Create NTFS File System
First, ensure you have the
sudo apt install ntfs-3g
Then, format the second partition:
sudo mkfs.ntfs /dev/sdb2
Your USB drive is now partitioned into two: the first partition with
suitable for Linux, and the second with
NTFS for Windows compatibility. Always
remember to safely eject your USB drive before unplugging it from any system.
This guide provides a basic understanding of partitioning with
fdisk, and the
possibilities extend far beyond this use case. Happy partitioning!
What Can You Do Next 🙏😊
If you liked the article, consider subscribing to Cloudaffle, my YouTube Channel, where I keep posting in-depth tutorials and all edutainment stuff for software developers.