13

I have just installed Debian 8.4 (Jessie, MATE desktop). For some reason the following command is not recognized:

mkfs.ext4 -L hdd_misha /dev/sdb1

The error I get:

bash: mkfs.ext4: command not found

I have googled and I actually can't seen to find Debian-specific instructions on how to create an ext4 filesystem. Any help much appreciated!

misha256
  • 547
  • 1
  • 5
  • 14
  • 1
    do you have `/sbin` in your path? are you running this as a normal user or as root? unless you've added it yourself (e.g. in `~/.bashrc` or `/etc/profile` etc), root has `/sbin` and `/usr/sbin` in $PATH, but normal users don't by default. – cas Apr 23 '16 at 05:04

4 Answers4

20

Do you have /sbin in your path?

Most likely you are trying to run mkfs.ext4 as a normal user.

Unless you've added it yourself (e.g. in ~/.bashrc or /etc/profile etc), root has /sbin and /usr/sbin in $PATH, but normal users don't by default.

Try running it from a root shell (e.g. after sudo -i) or as:

sudo mkfs.ext4 -L hdd_misha /dev/sdb1

BTW, normal users usually don't have the necessary permissions to use mkfsto format a partition (although they can format a disk-image file that they own - e.g. for use with FUSE or in a VM with, say, VirtualBox).

Formatting a partition requires root privs unless someone has seriously messed up the block device permissions in /dev.

cas
  • 1
  • 7
  • 119
  • 185
1

On some very slimmed down distributions (e.g. Ubuntu Server) it's possible that you don't have mkfs installed. In which case, you can install it with:

sudo apt-get install dosfstools

You may also want ntfsprogs for mkfs.ntfs.

(The package name should be the same in other distros e.g pacman -S dosfstools)

Josh
  • 141
  • 3
1

On some systems it is possible that you have mkfs installed and /sbin in your path, but ext2, ext3 and ext4 utilities are not installed. You can install them with e2fsprogs:

sudo apt install e2fsprogs
Idle
  • 11
  • 1
1

I just ran into a similar issue on Ubuntu server 20.04.4 LTS arm. The solution was to install exfat-utils.

Here was my error message.

$ sudo mkfs.exfat /dev/sdb1
sudo: mkfs.exfat: command not found

I attempted to run the command as the root user after issuing

$ sudo -i

This time it prompted me to install exfat-utils

root@ubuntu:~# mkfs.exfat /dev/sdb1
Command 'mkfs.exfat' not found, but can be installed with:
apt install exfat-utils

After this I moved back to normal user and the format command was successful.

$ sudo mkfs.exfat -n toshiba_silver /dev/sdb1
mkexfatfs 1.3.0
Creating... done.
Flushing... done.
File system created successfully.
David P
  • 11
  • 2