xref: /haiku/docs/develop/file_systems/ufs2.rst (revision a5061ecec55353a5f394759473f1fd6df04890da)
1*a5061eceSAdrien DestuguesThe UFS2 filesystem
2*a5061eceSAdrien Destugues===============================
3*a5061eceSAdrien Destugues
4*a5061eceSAdrien DestuguesWhile making a device for testing I have used a usb drive and formatted it to
5*a5061eceSAdrien DestuguesUFS2 by using the following commands in FreeBSD. Here da0 is usb.
6*a5061eceSAdrien Destugues
7*a5061eceSAdrien Destugues	gpart destroy -F /dev/da0
8*a5061eceSAdrien Destugues
9*a5061eceSAdrien Destugues	gpart create -s gpt /dev/da0
10*a5061eceSAdrien Destugues
11*a5061eceSAdrien Destugues	gpart add -t freebsd-ufs /dev/da0
12*a5061eceSAdrien Destugues
13*a5061eceSAdrien Destugues	newfs /dev/da0p1
14*a5061eceSAdrien Destugues
15*a5061eceSAdrien DestuguesBy running the following commands you can run the implemented code of UFS2.
16*a5061eceSAdrien Destugues
17*a5061eceSAdrien DestuguesCommands
18*a5061eceSAdrien Destugues--------
19*a5061eceSAdrien Destugues
20*a5061eceSAdrien Destugues# Building the ufs2 shell
21*a5061eceSAdrien Destugues
22*a5061eceSAdrien Destugues	jam -q "<build>ufs2_shell"
23*a5061eceSAdrien Destugues
24*a5061eceSAdrien DestuguesTo run it, use
25*a5061eceSAdrien Destugues
26*a5061eceSAdrien Destugues	jam run objects/linux/x86_64/release/tests/add-ons/kernel/file_systems/ufs2/ufs2_shell/ufs2_shell <path_to_the_image>
27*a5061eceSAdrien Destugues
28*a5061eceSAdrien DestuguesIf you are using a usb drive then you may not be able to open it so, you just
29*a5061eceSAdrien Destuguesneed to add sudo in the beginning of above command and make sure that you have
30*a5061eceSAdrien Destuguesnot mounted the usb drive.
31*a5061eceSAdrien Destugues
32*a5061eceSAdrien DestuguesAlternatively you can start from an existing freebsd image, so it has some files in it:
33*a5061eceSAdrien Destugues
34*a5061eceSAdrien Destugues	Download FreeBSD-12.1-RELEASE-amd64-mini-memstick.img
35*a5061eceSAdrien Destugues
36*a5061eceSAdrien Destugues	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*a5061eceSAdrien Destugues
38*a5061eceSAdrien Destugues	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*a5061eceSAdrien Destugues
40*a5061eceSAdrien Destugues	Check the result: file fbsd_ufstest.img
41*a5061eceSAdrien Destugues
42*a5061eceSAdrien Destuguesfbsd_ufstest.img: Unix Fast File system [v2] (little-endian)
43*a5061eceSAdrien Destugues
44*a5061eceSAdrien DestuguesDuring the implementation of the project the following links were found useful.
45*a5061eceSAdrien Destugueshttps://github.com/freebsd/freebsd/blob/master/sys/ufs/ffs/fs.h
46*a5061eceSAdrien Destugueshttps://flylib.com/books/en/2.48.1/ufs2_inodes.html
47