Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
| toh:linksys:whw03_v1 [2024/05/15 06:55] – [OpenWrt bootlog] lanchon | toh:linksys:whw03_v1 [2024/07/17 06:09] – [Repartitioning] lanchon | ||
|---|---|---|---|
| Line 163: | Line 163: | ||
| </ | </ | ||
| + | ==== Repartitioning ==== | ||
| + | |||
| + | For compatibility with stock firmware, and to allow returning to stock firmware, OpenWrt fits the complete install in the kernel/ | ||
| + | |||
| + | OpenWrt uses whatever remains unused of the rootfs partition as rootfs_data, | ||
| + | |||
| + | The following steps will configure 512 MiB rootfs+rootfs_data for each firmware copy (this is a dual firmware device), and the remaining 2.4 GiB space will be set up to be used as persistent storage that is not wiped/ | ||
| + | |||
| + | - Setup SSH access and verify that your stock GPT is exactly the same as mine: | ||
| + | |||
| + | < | ||
| + | root@OpenWrt:/# | ||
| + | 34+0 records in | ||
| + | 34+0 records out | ||
| + | 7a8c9529ee9e45be87407127e6905893 | ||
| + | </ | ||
| + | |||
| + | WARNING: VERIFY THAT YOUR GPT HASH IS THE SAME AS MINE! DO NOT PROCEED OTHERWISE! | ||
| + | |||
| + | - Backup your current configuration. | ||
| + | |||
| + | - Install these packages: gdisk sgdisk blkdiscard | ||
| + | |||
| + | - Install luci-app-attendedsysupgrade if you use LuCI, or install auc if you do not. | ||
| + | |||
| + | - Use " | ||
| + | |||
| + | IMPORTANT: DO NOT PROCEED WITHOUT DOING THE 2 SYSUPGRADES! For the procedure to succeed, the installed commands need to be in rootfs, not rootfs_data, | ||
| + | |||
| + | - Make backups of the GPT (partition table): | ||
| + | |||
| + | < | ||
| + | root@OpenWrt:/# | ||
| + | |||
| + | # backup primary copy of GPT: | ||
| + | |||
| + | root@OpenWrt:/# | ||
| + | 34+0 records in | ||
| + | 34+0 records out | ||
| + | |||
| + | # backup secondary copy of GPT: | ||
| + | |||
| + | root@OpenWrt:/# | ||
| + | 33+0 records in | ||
| + | 33+0 records out | ||
| + | </ | ||
| + | |||
| + | - Make backups of the stock partitions: | ||
| + | |||
| + | NOTE: The last partition (mmcblk0p19 " | ||
| + | It is 3.4 GiB in size, with an ext4 filesystem that only contains about 250 KiB of files (when i looked). | ||
| + | However this filesystem is not trimmed, and as time goes on it accumulates stale data in unused areas. | ||
| + | If the backup commands below fail with /tmp running out of space, this stale data is the culprit. | ||
| + | |||
| + | You then have 3 options: | ||
| + | |||
| + | 1) If one backup fits in /tmp, scp the first backup (see next step), remove it from /tmp, then do the second backup. | ||
| + | |||
| + | 2) Else pipe the backups over SSH (see below). Note that this might not work from a Windows PC due to character translations (but you could work some magic with base64 or similar). | ||
| + | |||
| + | 3) Or mount and fstrim the partition to remove the stale data (requires the " | ||
| + | |||
| + | < | ||
| + | # now you can backup the complete eMMC (GPTs and all partitions): | ||
| + | |||
| + | root@OpenWrt:/# | ||
| + | |||
| + | # or you can just backup the partition that will be wiped (but better if you do both backups): | ||
| + | |||
| + | root@OpenWrt:/# | ||
| + | |||
| + | # or if you ran out of space in /tmp, you can pipe the backups over SSH from your Linux PC: | ||
| + | |||
| + | you@your-pc: | ||
| + | you@your-pc: | ||
| + | |||
| + | # and test your backups after piping them, especially if done from a Windows PC: | ||
| + | |||
| + | you@your-pc: | ||
| + | </ | ||
| + | |||
| + | - Using SCP from your PC, bring all backup files to your PC and store them safely: | ||
| + | |||
| + | < | ||
| + | you@your-pc: | ||
| + | </ | ||
| + | |||
| + | WARNING: DO NOT PROCEED WITHOUT HAVING THE BACKUPS IN YOUR PC! STORE THEM SAFELY. | ||
| + | |||
| + | - Now comes the repartitioning, | ||
| + | |||
| + | < | ||
| + | root@OpenWrt: | ||
| + | |||
| + | # before starting, verify that the GPT hash matches expectation: | ||
| + | |||
| + | root@OpenWrt: | ||
| + | 34+0 records in | ||
| + | 34+0 records out | ||
| + | 7a8c9529ee9e45be87407127e6905893 | ||
| + | |||
| + | # DO NOT PROCEED IF THE ABOVE HEX STRING DOES NOT MATCH YOUR OUTPUT. | ||
| + | |||
| + | # unmount overlay: | ||
| + | |||
| + | root@OpenWrt: | ||
| + | |||
| + | # wipe/ | ||
| + | |||
| + | root@OpenWrt: | ||
| + | blkdiscard: Operation forced, data will be lost! | ||
| + | |||
| + | # copy rootfs contents to the disk location where the rootfs partition will be in the future: | ||
| + | |||
| + | root@OpenWrt: | ||
| + | 128+0 records in | ||
| + | 128+0 records out | ||
| + | |||
| + | # copy alt_rootfs contents to the disk location where the alt_rootfs partition will be in the future: | ||
| + | |||
| + | root@OpenWrt: | ||
| + | 128+0 records in | ||
| + | 128+0 records out | ||
| + | |||
| + | root@OpenWrt: | ||
| + | GPT fdisk (gdisk) version 1.0.10 | ||
| + | |||
| + | Partition table scan: | ||
| + | MBR: protective | ||
| + | BSD: not present | ||
| + | APM: not present | ||
| + | GPT: present | ||
| + | |||
| + | Found valid GPT with protective MBR; using GPT. | ||
| + | |||
| + | Command (? for help): p | ||
| + | Disk / | ||
| + | Sector size (logical/ | ||
| + | Disk identifier (GUID): 98101B32-BBE2-4BF2-A06E-2BB33D000C20 | ||
| + | Partition table holds up to 20 entries | ||
| + | Main partition table begins at sector 2 and ends at sector 6 | ||
| + | First usable sector is 34, last usable sector is 7634910 | ||
| + | Partitions will be aligned on 2-sector boundaries | ||
| + | Total free space is 0 sectors (0 bytes) | ||
| + | |||
| + | Number | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | 10 9762 | ||
| + | 11 | ||
| + | 12 | ||
| + | 13 | ||
| + | 14 | ||
| + | 15 | ||
| + | 16 294946 | ||
| + | 17 311330 | ||
| + | 18 573474 | ||
| + | 19 574498 | ||
| + | |||
| + | # resize GPT from non-standard 20 entries to standard 128 entries: | ||
| + | |||
| + | Command (? for help): x | ||
| + | |||
| + | Expert command (? for help): s | ||
| + | Current partition table size is 20. | ||
| + | Enter new size (19 up, default 128): | ||
| + | |||
| + | Expert command (? for help): m | ||
| + | |||
| + | Command (? for help): p | ||
| + | Disk / | ||
| + | Sector size (logical/ | ||
| + | Disk identifier (GUID): 98101B32-BBE2-4BF2-A06E-2BB33D000C20 | ||
| + | Partition table holds up to 128 entries | ||
| + | Main partition table begins at sector 2 and ends at sector 33 | ||
| + | First usable sector is 34, last usable sector is 7634910 | ||
| + | Partitions will be aligned on 2-sector boundaries | ||
| + | Total free space is 0 sectors (0 bytes) | ||
| + | |||
| + | Number | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | 10 9762 | ||
| + | 11 | ||
| + | 12 | ||
| + | 13 | ||
| + | 14 | ||
| + | 15 | ||
| + | 16 294946 | ||
| + | 17 311330 | ||
| + | 18 573474 | ||
| + | 19 574498 | ||
| + | |||
| + | # delete p19: | ||
| + | |||
| + | Command (? for help): d | ||
| + | Partition number (1-19): 19 | ||
| + | |||
| + | Command (? for help): p | ||
| + | Disk / | ||
| + | Sector size (logical/ | ||
| + | Disk identifier (GUID): 98101B32-BBE2-4BF2-A06E-2BB33D000C20 | ||
| + | Partition table holds up to 128 entries | ||
| + | Main partition table begins at sector 2 and ends at sector 33 | ||
| + | First usable sector is 34, last usable sector is 7634910 | ||
| + | Partitions will be aligned on 2-sector boundaries | ||
| + | Total free space is 7060413 sectors (3.4 GiB) | ||
| + | |||
| + | Number | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | 10 9762 | ||
| + | 11 | ||
| + | 12 | ||
| + | 13 | ||
| + | 14 | ||
| + | 15 | ||
| + | 16 294946 | ||
| + | 17 311330 | ||
| + | 18 573474 | ||
| + | |||
| + | Command (? for help): v | ||
| + | |||
| + | Problem: partitions 15 and 14 overlap: | ||
| + | Partition 15: 32802 to 294945 | ||
| + | Partition 14: 16418 to 294945 | ||
| + | |||
| + | Problem: partitions 17 and 16 overlap: | ||
| + | Partition 17: 311330 to 573473 | ||
| + | Partition 16: 294946 to 573473 | ||
| + | |||
| + | Identified 2 problems! | ||
| + | |||
| + | # delete rootfs and recreate it where p19 was with size 512 MiB: | ||
| + | |||
| + | Command (? for help): d | ||
| + | Partition number (1-18): 15 | ||
| + | |||
| + | Command (? for help): n | ||
| + | Partition number (15-128, default 15): | ||
| + | First sector (574498-7634910, | ||
| + | Last sector (574498-7634910, | ||
| + | Current type is 8300 (Linux filesystem) | ||
| + | Hex code or GUID (L to show codes, Enter = 8300): | ||
| + | Changed type of partition to 'Linux filesystem' | ||
| + | |||
| + | Command (? for help): c | ||
| + | Partition number (1-18): 15 | ||
| + | Enter name: rootfs | ||
| + | |||
| + | Command (? for help): p | ||
| + | Disk / | ||
| + | Sector size (logical/ | ||
| + | Disk identifier (GUID): 98101B32-BBE2-4BF2-A06E-2BB33D000C20 | ||
| + | Partition table holds up to 128 entries | ||
| + | Main partition table begins at sector 2 and ends at sector 33 | ||
| + | First usable sector is 34, last usable sector is 7634910 | ||
| + | Partitions will be aligned on 2-sector boundaries | ||
| + | Total free space is 6011837 sectors (2.9 GiB) | ||
| + | |||
| + | Number | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | 10 9762 | ||
| + | 11 | ||
| + | 12 | ||
| + | 13 | ||
| + | 14 | ||
| + | 15 574498 | ||
| + | 16 294946 | ||
| + | 17 311330 | ||
| + | 18 573474 | ||
| + | |||
| + | # delete alt_rootfs and recreate it after the new rootfs with size 512 MiB: | ||
| + | |||
| + | Command (? for help): d | ||
| + | Partition number (1-18): 17 | ||
| + | |||
| + | Command (? for help): n | ||
| + | Partition number (17-128, default 17): | ||
| + | First sector (1623074-7634910, | ||
| + | Last sector (1623074-7634910, | ||
| + | Current type is 8300 (Linux filesystem) | ||
| + | Hex code or GUID (L to show codes, Enter = 8300): | ||
| + | Changed type of partition to 'Linux filesystem' | ||
| + | |||
| + | Command (? for help): c | ||
| + | Partition number (1-18): 17 | ||
| + | Enter name: alt_rootfs | ||
| + | |||
| + | Command (? for help): p | ||
| + | Disk / | ||
| + | Sector size (logical/ | ||
| + | Disk identifier (GUID): 98101B32-BBE2-4BF2-A06E-2BB33D000C20 | ||
| + | Partition table holds up to 128 entries | ||
| + | Main partition table begins at sector 2 and ends at sector 33 | ||
| + | First usable sector is 34, last usable sector is 7634910 | ||
| + | Partitions will be aligned on 2-sector boundaries | ||
| + | Total free space is 4963261 sectors (2.4 GiB) | ||
| + | |||
| + | Number | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | 10 9762 | ||
| + | 11 | ||
| + | 12 | ||
| + | 13 | ||
| + | 14 | ||
| + | 15 574498 | ||
| + | 16 294946 | ||
| + | 17 | ||
| + | 18 573474 | ||
| + | |||
| + | # create new ' | ||
| + | |||
| + | Command (? for help): n | ||
| + | Partition number (19-128, default 19): | ||
| + | First sector (2671650-7634910, | ||
| + | Last sector (2671650-7634910, | ||
| + | Current type is 8300 (Linux filesystem) | ||
| + | Hex code or GUID (L to show codes, Enter = 8300): | ||
| + | Changed type of partition to 'Linux filesystem' | ||
| + | |||
| + | Command (? for help): c | ||
| + | Partition number (1-19): 19 | ||
| + | Enter name: extra | ||
| + | |||
| + | Command (? for help): p | ||
| + | Disk / | ||
| + | Sector size (logical/ | ||
| + | Disk identifier (GUID): 98101B32-BBE2-4BF2-A06E-2BB33D000C20 | ||
| + | Partition table holds up to 128 entries | ||
| + | Main partition table begins at sector 2 and ends at sector 33 | ||
| + | First usable sector is 34, last usable sector is 7634910 | ||
| + | Partitions will be aligned on 2-sector boundaries | ||
| + | Total free space is 1 sectors (512 bytes) | ||
| + | |||
| + | Number | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | 10 9762 | ||
| + | 11 | ||
| + | 12 | ||
| + | 13 | ||
| + | 14 | ||
| + | 15 574498 | ||
| + | 16 294946 | ||
| + | 17 | ||
| + | 18 573474 | ||
| + | 19 | ||
| + | |||
| + | # write the altered GPT and reboot the router: | ||
| + | |||
| + | Command (? for help): w | ||
| + | |||
| + | Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING | ||
| + | PARTITIONS!! | ||
| + | |||
| + | Do you want to proceed? (Y/N): y | ||
| + | OK; writing new GUID partition table (GPT) to / | ||
| + | Warning: The kernel is still using the old partition table. | ||
| + | The new table will be used at the next reboot or after you | ||
| + | run partprobe(8) or kpartx(8) | ||
| + | The operation has completed successfully. | ||
| + | |||
| + | root@OpenWrt: | ||
| + | root@OpenWrt: | ||
| + | Connection to 192.168.1.1 closed. | ||
| + | |||
| + | </ | ||
| + | |||
| + | - Finally, you need to do a sysupgrade for the rootfs_data filesystem to grow and fill its new larger partition. So do one last Attended Sysupgrade and profit! | ||
| + | |||
| + | - You can also format the 2.4 GiB " | ||
| ==== OEM easy installation ==== | ==== OEM easy installation ==== | ||