Tell me, please, if the way to use the cfdis utility to solve this problem?
Do not use the parted !
The OpenWRT script uses partedhttps://openwrt.org/docs/guide-user/advanced/expand_root, I would like to get
the same result using cfdisk or fdisk.
root@OpenWrt:~# df -Th
Filesystem Type Size Used Available Use% Mounted on
/dev/root ext4 58.9G 19.7M 58.8G 0% /
tmpfs tmpfs 494.1M 1020.0K 493.1M 0% /tmp
tmpfs tmpfs 512.0K 0 512.0K 0% /dev
Okay, but how to do the same, but using the programs: FDISK, GPARTED, GNOME DISKS.
That is, I want to do the same thing without using the script but manually. Where in the OpenWrt documentation can I see this or maybe an example of a user?
root@OpenWrt:~# [[fdisk /dev/sda]]
Welcome to fdisk (util-linux 2.37.3).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.
Command (m for help): [[p]]
Disk /dev/sda: 59.63 GiB, 64023257088 bytes, 125045424 sectors
Disk model: ADATA_IM2S3134N-
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xc120d9f5
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 512 33279 32768 16M 83 Linux
/dev/sda2 33792 246783 212992 104M 83 Linux
Command (m for help): [[d]]
Partition number (1,2, default 2): [[2]]
Partition 2 has been deleted.
Command (m for help): [[n]]
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): [[p]]
Partition number (2-4, default 2): [[2]]
First sector (33280-31277231, default 34816): [[33792]]
Last sector, +/-sectors or +/-size{K,M,G,T,P}
(33792-125045423, default 125045423): [[]]
Created a new partition 2 of type 'Linux' and of size 59.6 GiB.
Partition #2 contains a squashfs signature.
Do you want to remove the signature? [Y]es/[N]o: [[n]]
Command (m for help): [[w]]
The partition table has been altered.
Syncing disks.
root@OpenWrt:~#
I'm not feeling well today so I am not sure I remember correctly but I think your example is correct for growing the disk allocation for partition 2.
But...
That does not grow the filesystem. You need to run a different tool for that specific filesystem. For ext4, you could use resize2fs. You may need to run fsck before and after resizing. I think this is basic linux stuff not specific to OpenWrt. I think Gnome Disks can do it.
I don't have recent experience resizing a filesystem but It has worked fine for me in the past. Be sure to have your config settings, list of installed apps, scripts, user data and any other files you want to keep, backed up before making changes.
Note that the normal upgrade and installation of OpenWrt wipes out the resizing and will likely cause loss of data so plan accordingly on your next upgrade.
When I came back here to post this I see that you presented a way to do it with gparted.
In the meantime, I logged a terminal session showing the resizing with cli tools. Actually, I flashed an sd card with an R4s ext4 firmware image and resized it on my linux pc and then put it in my R4S router and booted it for the first time. Maybe someone will find the steps useful.
## On linux PC ##
$ cd /tmp/r4s
$ ls
openwrt-24.10.0-952ead2bff08-rockchip-armv8-friendlyarm_nanopi-r4s-ext4-sysupgrade.img.gz
$ gunzip openwrt-24.10.0-952ead2bff08-rockchip-armv8-friendlyarm_nanopi-r4s-ext4-sysupgrade.img.gz
gzip: openwrt-24.10.0-952ead2bff08-rockchip-armv8-friendlyarm_nanopi-r4s-ext4-sysupgrade.img.gz: decompression OK, trailing garbage ignored
$
$ lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sda
< redacted >...
$
$ sudo dd if="openwrt-24.10.0-952ead2bff08-rockchip-armv8-friendlyarm_nanopi-r4s-ext4-sysupgrade.img" of=/dev/sda bs=8096
21758+1 records in
21758+1 records out
176160768 bytes (176 MB, 168 MiB) copied, 7.75087 s, 22.7 MB/s
$
$ lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sda
├─sda1 ext4 1.0 kernel 84173db5-fa99-e35a-95c6-28613cc79ea9
└─sda2 ext4 1.0 rootfs ff313567-e9f1-5a5d-9895-3ba130b4a864
< redacted >...
$
$ sudo fdisk -l /dev/sda
Disk /dev/sda: 58.94 GiB, 63281561600 bytes, 123596800 sectors
Disk model: USB DISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5452574f
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 65536 98303 32768 16M 83 Linux
/dev/sda2 131072 344063 212992 104M 83 Linux
$
$# start = 131072 | end = 15756064 (512 byte blocks) for about 8GB
$
$ sudo fdisk /dev/sda
Welcome to fdisk (util-linux 2.37.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help):d
Partition number (1,2, default 2): 2
Partition 2 has been deleted.
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2048-123596799, default 2048): 131072
Last sector, +/-sectors or +/-size{K,M,G,T,P} (131072-123596799, default 123596799): 15756064
Created a new partition 2 of type 'Linux' and of size 7.5 GiB.
Partition #2 contains a ext4 signature.
Do you want to remove the signature? [Y]es/[N]o: N
Command (m for help): p
Disk /dev/sda: 58.94 GiB, 63281561600 bytes, 123596800 sectors
Disk model: USB DISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5452574f
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 65536 98303 32768 16M 83 Linux
/dev/sda2 131072 15756064 15624993 7.5G 83 Linux
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
$
#
# Note new end and larger size for sda2
#
$ eject /dev/sda
< remove and re-insert sd-card>
$
$ lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sda
├─sda1 ext4 1.0 kernel 84173db5-fa99-e35a-95c6-28613cc79ea9
└─sda2 ext4 1.0 rootfs ff313567-e9f1-5a5d-9895-3ba130b4a864
< redacted >
$
$ sudo fsck /dev/sda2
fsck from util-linux 2.37.2
e2fsck 1.46.5 (30-Dec-2021)
rootfs: clean, 2221/6656 files, 14854/26624 blocks
$
$
# estimate of new size is 15624976 blocks or 7999987712 bytes. 1953112 in 8k blocks with a very small extra.
$
$ sudo resize2fs /dev/sda2 1953112
resize2fs 1.46.5 (30-Dec-2021)
Resizing the filesystem on /dev/sda2 to 1953112 (4k) blocks.
The filesystem on /dev/sda2 is now 1953112 (4k) blocks long.
$ sudo fsck /dev/sda2
fsck from util-linux 2.37.2
e2fsck 1.46.5 (30-Dec-2021)
rootfs: clean, 2221/399360 files, 39588/1953112 blocks
$
$ sudo eject /dev/sda
#
# Powered off R4S and swapped new sd-card in and cables as needed...
#
## On R4S router ##
#
$ ssh root@192.168.1.1
The authenticity of host '192.168.1.1 (192.168.1.1)' can't be established.
ED25519 key fingerprint is SHA256:Sq365p6uBxq+SvDpIBzxrHCaS8aJ5UIwTsp/r1LCr1V.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.1.1' (ED25519) to the list of known hosts.
BusyBox v1.36.1 (2025-02-08 21:33:11 UTC) built-in shell (ash)
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
OpenWrt 24.10.0, r28427-6df0e3d02a
-----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:~# df -Th
Filesystem Type Size Used Available Use% Mounted on
/dev/root ext4 7.4G 52.3M 7.3G 1% /
tmpfs tmpfs 1.9G 1.2M 1.9G 0% /tmp
tmpfs tmpfs 512.0K 0 512.0K 0% /dev
root@OpenWrt:~# poweroff
root@OpenWrt:~# Connection to 192.168.1.1 closed by remote host.
Connection to 192.168.1.1 closed.
$
What do you see as the use case for growing the root filesystem, especially to fill the available flash capacity, considering it gets wiped out on a regular upgrade.
I'm not sure I've heard of any way to retain data with recently added capabilities of owut or sysupgrade (asu) either. There may be better ways to use more storage for things like sharing files from the router or storing docker files or other data that will survive an upgrade.
Data files could be restored from backup after growing the filesystem, post upgrade, and backups are important to have anyway even if data files are stored someplace other than the root filesystem.