xref: /haiku/docs/develop/file_systems/ufs2.rst (revision a127b88ecbfab58f64944c98aa47722a18e363b2)
1The UFS2 filesystem
2===============================
3
4While making a device for testing I have used a usb drive and formatted it to
5UFS2 by using the following commands in FreeBSD. Here da0 is usb.
6
7	gpart destroy -F /dev/da0
8
9	gpart create -s gpt /dev/da0
10
11	gpart add -t freebsd-ufs /dev/da0
12
13	newfs /dev/da0p1
14
15By running the following commands you can run the implemented code of UFS2.
16
17Commands
18--------
19
20# Building the ufs2 shell
21
22	jam -q "<build>ufs2_shell"
23
24To run it, use
25
26	jam run objects/linux/x86_64/release/tests/add-ons/kernel/file_systems/ufs2/ufs2_shell/ufs2_shell <path_to_the_image>
27
28If you are using a usb drive then you may not be able to open it so, you just
29need to add sudo in the beginning of above command and make sure that you have
30not mounted the usb drive.
31
32Alternatively you can start from an existing freebsd image, so it has some files in it:
33
34	Download FreeBSD-12.1-RELEASE-amd64-mini-memstick.img
35
36	diskimage register FreeBSD-12.1-RELEASE-amd64-mini-memstick.img to access the MBR style partitions inside it (on Linux probably using mount -o loop or something like that)
37
38	dd if=/dev/disk/virtual/files/8/1 bs=8K skip=1 of=fbsd_ufstest.img to extract the filesystem from the partition (skipping the freebsd disklabel)
39
40	Check the result: file fbsd_ufstest.img
41
42fbsd_ufstest.img: Unix Fast File system [v2] (little-endian)
43
44During the implementation of the project the following links were found useful.
45https://github.com/freebsd/freebsd/blob/master/sys/ufs/ffs/fs.h
46https://flylib.com/books/en/2.48.1/ufs2_inodes.html
47