Solved newfs for ext2/3/4

How do you use it?

I did the following below and I'm able to read/write on FreeBSD but on a Linux system was not able to mount the drive...

pkg install e2fsprogs-core

gpart destroy -F da0

gpart create -s GPT da0

mke2fs -L name_of_volume -F -E discard -t ext4 /dev/da0
(Will complete in 1-2 mins)

Now mount the drive:
mount -t ext2fs /dev/da0 /mnt

To fix premissions:
chmod g+w /dev/da0*
chgrp operator /mnt
chmod g+w /mnt


Edit:
I was able to mount the drive on Linux using:
$ sudo mkdir /mnt/some_name_for_drive
$ sudo mount -t ext4 /dev/sdx /mnt/some_name_for_drive

Need to fix premissions:
$ sudo chown $USER:$USER /mnt/stuff

Thanks.
 
To have a chance of anyone (probably not me) helping you debug this, you need to tell us more than "was not able to mount the drive". What was the exact error message? What did dmesg on Linux say?

Thanks for the reply.

I'm basically trying to create an ext2/3/4 USB SSD external drive so that I can copy files from FreeBSD to Arch Linux and vice versa.
So I do not want to depend on using Linux OS to make ext4 file system since this requires me to have a linux box.
I rather create linux file systems on FreeBSD if possible.

I'm not able to find any info on how to create ext3/4 file systems to be used for as a flash drive/thumb drive properly on FreeBSD using "ext2fs" from:

pkg install e2fsprogs-core

So I was able to create an ext4 drive using the methods on my recent previous comment, however it is really weird.
I am now able to get it to read/write on Linux but when connecting it back to FreeBSD by using:

mount -t ext2fs /dev/da0 /mnt

I now get the error on FreeBSD:
Code:
mount: /dev/da0: Operation not permitted
(Note: ran as root)

This is what I get when using:
gpart show

Code:
gpart: No such geom: da0.

When I use:
lsblk

I get the following:
Code:
DEVICE         MAJ:MIN SIZE TYPE                                          LABEL MOUNT
ada0             0:149 233G GPT                                               - -
  ada0p1         0:150 260M efi                                    gpt/efiboot0 /boot/efi
  ada0p2         0:151 512K freebsd-boot                           gpt/gptboot0 -
  <FREE>         -:-   492K -                                                 - -
  ada0p3         0:152 2.0G freebsd-swap                              gpt/swap0 SWAP
  ada0p4         0:153 231G freebsd-zfs                                gpt/zfs0 <ZFS>
  <FREE>         -:-   164K -                                                 - -
da0              1:166 233G ext2fs                        ext2fs/name_of_volume -

I am able to find "da0" but it is not able to mount on FreeBSD however it is able to mount on Linux and I created it on FreeBSD...

Thanks.

EDIT:

Alright I have followed a great guide on how create partitions for Linux file systems:

So now I did the following on FreeBSD:

pkg install e2fsprogs-core

gpart destroy -F da0

gpart create -s GPT da0

gpart add -t linux-data -s 232G /dev/da0

View the partitions:
gpart show da0

newfs -U /dev/da0p1

Next you need to create a mount point for each partition:
mkdir /mnt/volume1

Create the ext4 file system volume (Will complete in 1-2 mins):
mke2fs -L name_of_volume -F -E discard -t ext4 /dev/da0p1

To fix premissions:
chmod 777 /mnt/volume1
chmod operator /mnt/volume1
chmod g+w /mnt/volume1

Now mount the drive for FreeBSD:
mount -t ext2fs /dev/da0p1 /mnt/volume1

It mounts on FreeBSD perfectly.
However, once I plug it on Linux, I was able to plug and play the drive and mounts easily but get similar issue when trying to make it mount on FreeBSD again:

mount -t ext2fs /dev/da0p1 /mnt/volume1

Code:
mount: /dev/da0p1: Input/output error

This is what I get for:
file -s /dev/da0p1

Code:
/dev/da0p1: Linux rev 1.0 ext4 filesystem data, UUID=4bac9627-42dd-428f-b899-a202bc537fd9, volume name "name_of_volume" (extents) (64bit) (large files) (huge files)
 
newfs -U /dev/da0p1
Why are you doing this?

mke2fs -L name_of_volume -F -E discard -t ext4 /dev/da0p1
I'd avoid forcing filesystem creation at (almost) all costs.

To fix premissions:
chmod 777 /mnt/volume1
chmod operator /mnt/volume1
chmod g+w /mnt/volume1
You're not fixing permissions/ownership for given mount but rather for an empty directory. Ownership/permissions will be overwritten with whatever inode #2 (mountpoint) of that share has set.

e2fsprogs have tools to work with the FS but not to mount it. Using ext2fs(5) will give you (very) limited access to the FS. You can use sysutils/fusefs-ext2 to mount the FS though. kldload fusefs is required as a prerequisite.

You could use it as follows:
Code:
# gpart create -s gpt md0
# gpart add -t linux-data md0
# mkfs.ext4 /dev/md0p1
# kldload fusefs
# fuse-ext2 -o rw+ /dev/md0p1 /mnt/
Created under FreeBSD 13.1, tested under Debian.
 
Why are you doing this?


I'd avoid forcing filesystem creation at (almost) all costs.


You're not fixing permissions/ownership for given mount but rather for an empty directory. Ownership/permissions will be overwritten with whatever inode #2 (mountpoint) of that share has set.

e2fsprogs have tools to work with the FS but not to mount it. Using ext2fs(5) will give you (very) limited access to the FS. You can use sysutils/fusefs-ext2 to mount the FS though. kldload fusefs is required as a prerequisite.

You could use it as follows:
Code:
# gpart create -s gpt md0
# gpart add -t linux-data md0
# mkfs.ext4 /dev/md0p1
# kldload fusefs
# fuse-ext2 -o rw+ /dev/md0p1 /mnt/
Created under FreeBSD 13.1, tested under Debian.

Thank You very much for your reply.

I will try your suggestions.
 
Back
Top