Amiga Fast File System (AFFS or FFS)

AmigaOne X1000 platform specific issues related to Linux only.
User avatar
xeno74
Posts: 6081
Joined: Fri Mar 23, 2012 7:58 am

Amiga Fast File System (AFFS or FFS)

Post by xeno74 »

Hi All,

This thread is for testing of the Amiga Fast File System (AFFS or FFS) support on Linux.
In 1988, Amiga produced the Fast File System (FFS) for use on the AmigaOS version 1.3 in 1988. The FFS file system was an update to what was later termed "Old File System" (OFS), released in 1985. FFS was backward compatible with OFS. The file systems were both released for the Amiga systems which had hard disks or floppy disks. Originally, the AmigaOS was termed AmigaDOS or Workbench and FFS had a version number of v34.

The Fast File System was first supported by Linux kernel 2.1.x.

FFS 1.3 was the first Amiga file system to support hard disk booting. Before version 1.3, Amiga systems had to be booted from floppy disks. FFS 1.3 was first shipped with the Amiga 500 and 2000 (or could be applied as an update). The Amiga 1000 used FFS on systems with an updated ROM chip or a new boot floppy (Kickstart).

The main patch of FFS is that it allowed a 512-byte block to be filled. Previous file system versions only allowed 488 bytes of the block to be used for data (24 bytes were used in the checksum). Of course, this wasted a lot of storage space. For example, if a file is 1 kb (1024 bytes) were to be written to disk, it would take three blocks. The first two blocks would be filled with 488 bytes while the third would hold 48 bytes. This file wastes a total of 512 bytes, or one block. So every 1 kb written to disk wasted 512 bytes or half the total space written to disk. A 5 kb file wastes 2.5 kb.

Another issue with OFS fixed with FFS is that OFS placed 24 bytes of redundant information (checksum) in each block. The redundant data was needed to 'fix' corrupted data on poor media surfaces.

NOTE: Floppy disks and even some hard disks in the early 1980's were not always of the highest quality. It was not uncommon to have numerous bad sectors on storage media. Of course, the large 8" floppy disks held very little data, similar to the 5 1/4" floppies. Bad sectors only reduced the amount of usable space. It was also not uncommon to have sectors go bad the more a disk was used.

The redundant data posed a bottleneck in performance when used on a hard disk, which were more reliable. At this point, OFS continued to be used on floppy disks to handle the poor reliability of the media. FFS was used on the hard disks to allow for booting from the hard drive.

FFS provided management of the file system by using a bitmap.

NOTE: Bitmaps are used to track used and unused space. These bitmaps are not images, but a file where each bit represents an addressable block. Each bit is either on (1) or off (0) to represent if it is used or free. In the case of FFS, a 0 means the block is used and 1 means the bock is free.

If the sector holding the bitmap is lost or corrupted, then the whole file system can become invalid and the bitmap must be rebuilt. The Amiga Validator could be used to rebuild the bitmap. Problems occurred that directories could become corrupted during the rebuild. The larger the hard disk, the longer the rebuild.

FFS had a storage limitation of 4 GB due to the file system being 32-bits. That is, the file system could only use 32-bits to generate addressable spaces. When converting 32-bits to addresses, the largest number that can be produces is 4,294,967,295 which is 4.194 GB, this makes the largest file size possible as 4 GB. Later patches for FFS provided support for 64-bit addressing for the largest addressable block being 18,446,744,073,709,551,615.

The Amiga file systems have eight modes. The modes are referred to as dostypes. Each dostype has a descriptor which is listed in the Rigid Disk Block (RDB) which is similar in nature to a Master Boot Record (MBR).

DOS\0 – The original OFS type. It was used by most companies to format floppies since the Amiga systems were backwards compatible from FFS to OFS.

DOS\1 – The original FFS with no patches.

DOS\2 – (OFS-INTL) International mode for OFS, which allows for the reading of files with foreign language characters.

DOS\3 – (FFS-INTL) International mode for FFS, which allows for the reading of files with foreign language characters.

DOS\4 – (OFS-DC) Directory Cache mode for OFS that cached a listing of the directory structure in a separate list. This increased directory reading speeds, but slowed other disk reads.

DOS\5 - (FFS-DC) Directory Cache mode for FFS that cached a listing of the directory structure in a separate list. This increased directory reading speeds, but slowed other disk reads.

DOS\6 – (OFS-LNFN) Allowed for long file name (107 characters) on an OFS disk as compared to 31 characters.

DOS\7 - (FFS-LNFN) Allowed for long file name (107 characters) on an FFS disk as compared to 31 characters.

NOTE: Linux AFFS supports all dostypes except DOS\6 and DOS\7.
I tested the mount of some AFFS filesystems with Fienix on my AmigaOne X1000 today. I was able to mount an affs1 filesystem (DOS\1) and an affs3 filesystem (DOS\3) with Fienix. I also tried to mount an affs7 filesystem (DOS\7) but without any success.

Screenshot:

Image

Could you please try to mount AFFS filesystems as well?

Thanks,
Christian
http://www.amigalinux.org
http://www.supertuxkart-amiga.de

Running Linux on AmigaONEs can require some tinkering.

User avatar
Hypex
Beta Tester
Beta Tester
Posts: 431
Joined: Mon Dec 20, 2010 2:23 pm
Location: Vic. Australia.

Re: Amiga Fast File System (AFFS or FFS)

Post by Hypex »

Hi.

I've been doing some FFS testing lately as it happens. I actually setup a DOS3 volume years ago to share data between OS4 and Linux. But I tested writing to a DOS3 volume and it was slow. Generally I find AFFS support is built in A1 kernels and don't recall having any major issues.

However I have had some issues pop up in testing. First is mounting. It would be good if a volume could be mounted from the desktop. but this is corrupted. My DOS3 volume turns up on the sidebar, but it thinks it is Ext2 for some reason, and I accidentally mounted it before finding out I had let Linux mount an Amiga partition as Ext2. It corrupted a file. I did a check in OS4 and it passed. Then restored the file from a backup. The volume is marked as bootable so that may have confused it.

Secondary to the above is tools like Disks or GParted. They don't know what FFS is. It would be good if support could be easily added. I don't know if it's easy enough to generate a config file. It would be good if the AFFS package included this support. I don't know where the proper place is that common filesystems like Ext4 have this support so it is picked up.

I've mounted on the command line but just a basic mount with no options. It works but I wonder if this causes issues as I found all the files in the FFS volume are root only. It gets annoying when I want to edit a simple file and it won't let me. I think the "open as root" option should be on every desktop as I see this problem a lot. You need to be root to unpack the kernel and install it.

I can see I need to add to fstab, but I would prefer not to modify the system fstab and add to a user fstab instead. Unfortunately, they introduced this useful feature in the form of fstab.d, but then decided it was a bad idea and removed it. I don't know. It protected the system fstab from tampering and they thought it was a bad idea! Seriously, that's messed. That would be like the OS4 team revoking DOSDrivers and forcing people to edit one Mountlist file by hand. That would be going backwards. :-?

User avatar
xeno74
Posts: 6081
Joined: Fri Mar 23, 2012 7:58 am

Re: Amiga Fast File System (AFFS or FFS)

Post by xeno74 »

Hypex,

Many thanks for your report!

Cheers,
Christian
http://www.amigalinux.org
http://www.supertuxkart-amiga.de

Running Linux on AmigaONEs can require some tinkering.

User avatar
Hypex
Beta Tester
Beta Tester
Posts: 431
Joined: Mon Dec 20, 2010 2:23 pm
Location: Vic. Australia.

Re: Amiga Fast File System (AFFS or FFS)

Post by Hypex »

No problem. :-)

User avatar
xeno74
Posts: 6081
Joined: Fri Mar 23, 2012 7:58 am

Re: Amiga Fast File System (AFFS or FFS)

Post by xeno74 »

Hypex wrote:
Wed May 13, 2020 1:06 pm
Secondary to the above is tools like Disks or GParted. They don't know what FFS is.
I can only see my Amiga partitions including the labels (DH1, BDH0 etc) with parted. Do you know another tool for displaying the Amiga partitions with partition labels?

I tried to mount an AFFS partition with the label.

Code: Select all

mount -L DH1 -t affs /media/fienix/DH1
Unfortunately without any success.

Error message: mount: /media/fienix/DH1: can't find LABEL="DH1".

Any hints?
http://www.amigalinux.org
http://www.supertuxkart-amiga.de

Running Linux on AmigaONEs can require some tinkering.

User avatar
Hypex
Beta Tester
Beta Tester
Posts: 431
Joined: Mon Dec 20, 2010 2:23 pm
Location: Vic. Australia.

Re: Amiga Fast File System (AFFS or FFS)

Post by Hypex »

xeno74 wrote:
Thu May 14, 2020 1:10 pm
I can only see my Amiga partitions including the labels (DH1, BDH0 etc) with parted. Do you know another tool for displaying the Amiga partitions with partition labels?
There is amiga-disk. It can read an RDB and detect up to DOS6. But I can't see it display labels. Parted can display the labels or perhaps, the Amiga DOS device name.
I tried to mount an AFFS partition with the label.
I've tried to mount with label and UUID, but found it was non existent.
Any hints?
The only clue I can give, to specify an Amiga volume, without using the device name, is to use the udevadm command. But it needs a device name to tell you other references. Using /dev/sda14 as an example in my case:

Code: Select all

udevadm info --name sda14 --query symlink

User avatar
xeno74
Posts: 6081
Joined: Fri Mar 23, 2012 7:58 am

Re: Amiga Fast File System (AFFS or FFS)

Post by xeno74 »

Hypex,

Thanks a lot for your answer.

Is BDH0 always the first partition on the first hard drive or can it be on the second hard drive as a second partition?

Thanks,
Christian
http://www.amigalinux.org
http://www.supertuxkart-amiga.de

Running Linux on AmigaONEs can require some tinkering.

User avatar
nbache
Beta Tester
Beta Tester
Posts: 1452
Joined: Mon Dec 20, 2010 7:25 pm
Location: Copenhagen, Denmark
Contact:

Re: Amiga Fast File System (AFFS or FFS)

Post by nbache »

Under AmigaOS, you can give any partition any device name at all.

So the first partition on the first hard drive could be given a device name of DH0:, SDH17: or XENO74: or anything else you can think of - if that's what you were asking?

Best regards,

Niels

User avatar
Hypex
Beta Tester
Beta Tester
Posts: 431
Joined: Mon Dec 20, 2010 2:23 pm
Location: Vic. Australia.

Re: Amiga Fast File System (AFFS or FFS)

Post by Hypex »

xeno74 wrote:
Fri May 15, 2020 6:33 am
Hypex,

Thanks a lot for your answer.
You're welcome. Funny enough, I only know this info because I was recently experimenting with it, and trying to work out how to detect Amiga device points from a script. I didn't think to post my findings until I saw your thread.

I think I can figure out the ID thing. It is particular to Linux filesystems. Because Amiga partitions to not have a UUID, at least not that I know of, none can be found. As an example the blkid command won't see any. Or it only prints known filesystems. The DOS device name that AmigaDOS uses is too unreliable to be used in place of the UUID. AmigsDOS has been aware of this since inception and IIRC used the datestamp as an ID in the case two volumes were inserted with the same label. So this could be used to generate a UUID but AFFS would need to generate it so other Linux tools can see it. I don't know if it's possible.
Is BDH0 always the first partition on the first hard drive or can it be on the second hard drive as a second partition?
Actually, it can be on a second HDD as well. In my case, my X1000 has both my SATA drive and my XE IDE drive attached. There is cross over in some device names. Now, when AmgaDOS boots, it will detect this and append some number to the DOS device so they differ on mount. During setup, Media Toolbox tends to look through your partition devices, so adding a new partition will always have a unique device name.

With the information shared in my previous post I've just written three commands prior to this reply. They can be used to print a virtual UUID, a mount command and a fstab entry. I'll just post the scripts with embedded filename. They don't do any error checking. Hope it helps. :-D

Code: Select all

#!/bin/sh 

# affsid.sh <device>

# AFFS ID.
# Print an ID relating to an AFFS volume. Takes device as input.

udevadm info --name ${1} --query symlink | cut -f1 -d' '

Code: Select all

#!/bin/sh 

# affsmp.sh <device> <point>

# AFFS Mount Point.
# Print a commnand to mount an AFFS volume using a unique ID. Takes a device and mount point as input.

echo "sudo mount -t affs `udevadm info --name ${1} --query symlink | cut -f1 -d' '` ${2}"

Code: Select all

#!/bin/sh 

# affstab.sh <device> <point>

# AFFS Tab.
# Print a fstab entry to mount an AFFS volume using a unique ID. Takes a device and mount point as input.

echo "`udevadm info --name ${1} --query symlink | cut -f1 -d' '`\t${2}\taffs\tnoauto,user,exec,verbose\t0\t0"

User avatar
xeno74
Posts: 6081
Joined: Fri Mar 23, 2012 7:58 am

Re: Amiga Fast File System (AFFS or FFS)

Post by xeno74 »

Hypex,

Thanks a lot! Interesting!

I would like to mount my BDH0 partition with the name. First I have to figure out which affs partition has the name BDH0.

I can do that with:

Code: Select all

parted -l | grep BDH0
Output:

Code: Select all

1 1057kB 123MB 122MB affs3 BDH0 hidden
The output of "parted -l" displays the disk device node of the affs3 partition as well but it displays also all other disk device nodes. That means I can't figure out which disk device node has the BDH0 partition with grep etc.
nbache wrote:
Fri May 15, 2020 10:07 am
Under AmigaOS, you can give any partition any device name at all.

So the first partition on the first hard drive could be given a device name of DH0:, SDH17: or XENO74: or anything else you can think of - if that's what you were asking?

Best regards,

Niels
No, I hoped, that BDH0 is always sda1 for an easy mount.

Thanks,
Christian
http://www.amigalinux.org
http://www.supertuxkart-amiga.de

Running Linux on AmigaONEs can require some tinkering.

Post Reply