Friday, April 17, 2020

Creating FAT Filesystems in Linux Embedded Board

Sometime we need to allocate much more space to run code which require large of space to run and return trace log.

For example with Board Linux NXP
- Show available space:
dh -h

- Lisk all block existed in Board
lsblk

Installing Required Tools:

You can easily format USB flash drives as FAT. In order to do that, you need to have dosfstools installed.  The package name is that same in all the common Linux distributions. It should already be installed on your computer. If it isn’t, just use your package manager to install dosfstools.
On Ubuntu/Debian, you can install dosfstools with the following command:
sudo apt install dosfstools -y
On CentOS 7 or RHEL 7, you can install dosfstools with the following command:
sudo yum install dosfstools -y

Formatting a USB Flash Drive as FAT:

Now, insert the USB flash drive that you want to format as FAT.
Then, run the following command to find the device name of your USB flash drive.
sudo lsblk
As you can see, the 4 GB USB flash drive has the device name sdb in my case. So, I can access it as /dev/sdb. It may be different for you. Make sure you replace it with yours from now on.
As you can see, I already have a partition /dev/sdb1 on my USB flash drive. So, I don’t have to create a partition. But if you don’t have a partition already, then you should create one first.
If you do have a partition, then unmount the partition first if it is mounted (as in my case). Otherwise, you won’t be able to format it.

To unmount the partition, run the following command:
sudo umount /dev/sdb1
Suppose you don’t have a partition on your USB flash drive for some reason. You can use fdisk to easily create one.
To do that, open /dev/sdb with fdisk as follows:
sudo fdisk /dev/sdb
Now, press o and press <Enter> to create a new DOS partition table.
Now, to create a new partition, press n and then press <Enter>. You should see the following options. We want to create a primary partition. So, just press <Enter> (to select the default option).

No comments:

Post a Comment

Back to Top