Hi. As I stated in my first reply I have not done this yet myself but I have read about it in preparation to do it. If the following doesn't meet your needs then it may be better to ask in the OpenWrt nano pi forum linked in my first reply. It gets a lot of traffic and you should get good answers.
From the info in the OpenWrt documentation, this process is to be done on the running router without other customization to the filesystems yet. I'm pretty sure it takes some changes to the process to do it from another linux system. I also think I read that it has to be done after first boot as the f2fs filesystem gets setup on first boot and is not shipped in the image file in a state usable to do these alterations.
Be sure to back up the router config to another device (not on the sd card) if you have some non default config in place.
You are not to supply any values to the commands in the "grow f2fs filesystem" instruction text block. What may look like parameters for you to substitute values for ("NAME
", "BACK-FILE
", "OFFSET
" in upper case letters) are literal strings passed to the "-O
" option of the losetup
command. It is all an automated process that you can copy/paste to the router command line in your ssh session. Per the OpenWrt docs, the reboot is of the router and is needed to put the changes into effect.
That may be enough info to move forward with the process. The following is just for more knowledge.
Most of the programs and some of the built-in commands have help available. Try passing --help
or -h
parameter to a command to get help on it. The following all work:
losetup --help
sort --help
sed --help
fsck.f2fs --help
mount --help
umount --help
resize.f2fs --help
Specifics for the "grow f2fs filesystem" section:
LOOP="$(losetup -n -O NAME | sort | sed -n -e "1p")"
...gets the name of the loop device for the overlay filesystem for the writable area on the sd card as provisioned by the image installation and assigns it to a the variable "LOOP
".
Show the value of the LOOP
variable with echo $LOOP
Type losetup
to see the default output.
Type losetup -n -O NAME
to see what the script gets before adding /dev
to it.
ROOT="$(losetup -n -O BACK-FILE ${LOOP} | sed -e "s|^|/dev|")"
...gets the device name for the combined root
and overlay
filesystems on the sd card and prepends /dev
to the string and assigns it to variable ROOT
OFFS="$(losetup -n -O OFFSET ${LOOP})"
...gets the offset from the beginning of the partition to the start of the writable overlay area and assigns it to variable OFFS
LOOP="$(losetup -f)"
...gets the next free (-f
) loop device id and assigns it to variable LOOP
which is reusing variable LOOP
.
losetup -o ${OFFS} ${LOOP} ${ROOT}
...creates a second loop device for the overlay filesystem that is already used and mounted for modification in the next four commands. It is passed the values in the three variables.
fsck.f2fs -f ${LOOP}
...I'm not sure if this is just an integrity check or if it fixes (-f
) anything for use in other commands. It is passed the value of the LOOP
variable.
mount ${LOOP} /mnt
umount ${LOOP}
...I'm not sure why this is needed but it probably sets info needed elsewhere. It is passed the value of the LOOP
variable.
resize.f2fs ${LOOP}
... resizes the overlay filesystem to fill the partition per default values as the size is not specified on the command line. It is passed the value of the LOOP
variable.
reboot
...reboots the router to put the changes into effect. The active overlay filesystem needs to be mounted early in the boot process as all the config is stored on it. I'm not sure what problems may arise with continuing to run with the changes made to the overlay filesystem so shutting down soon after resizing is probably a good idea.
NOTE that reboot
will turn off the router and it may not restart due to an issue with voltage to the sd card reader. You may need to unplug the power cable and re plug it to get it to boot. This may always be the case on all reboots and system crash/restart unless you run a build with the right patch included.
Good Luck! I hope this info helps.