TS-421 dry run failed
Conan179 opened this issue · 8 comments
Hello@all
The dry run on my ts-421 (debian) end with fails:
root@Qnap-NAS:/home/Con# sudo ./qnap_mtd_resize.py --dry-run
[Check of the QNAP model and see if supported]
kirkwood-qnap: machine: QNAP TS419 family
DTB file: kirkwood-ts419-6282.dtb
Checking: flashcp -V
Checking: flash_erase --version
Using 'u-boot-tools' package
[find on which MTD device partitions are currently mounted]
Failed: no information found with dmesg
root@Qnap-NAS:/home/Con#
You were right, after the reboot it looks like this:
root@Qnap-NAS:/home/Con# sudo ./qnap_mtd_resize.py --dry-run
[Check of the QNAP model and see if supported]
kirkwood-qnap: machine: QNAP TS419 family
DTB file: kirkwood-ts419-6282.dtb
Checking: flashcp -V
Checking: flash_erase --version
Using 'u-boot-tools' package
[find on which MTD device partitions are currently mounted]
spi0.0
[Dump current U-boot config']
Current U-boot bootcmd:
uart1 0x68;cp.l 0xf8200000 0x800000 0x80000;cp.l 0xf8400000 0xa00000 0x240000;bootm 0x800000
Current U-boot bootargs:
console=ttyS0,115200 root=/dev/ram initrd=0xa00000,0x900000 ramdisk=34816 mem=768M
[Prepare new 'bootcmd']
Old: uart1 0x68;cp.l 0xf8200000 0x800000 0x80000;cp.l 0xf8400000 0xa00000 0x240000;bootm 0x800000
New: uart1 0x68;cp.l 0xf8100000 0x800000 0xc0000;cp.l 0xf8400000 0xb00000 0x300000;bootm 0x800000;echo Kernel_legacy layout fallback;bootm 0x900000
[Prepare new 'bootargs']
Old: console=ttyS0,115200 root=/dev/ram initrd=0xa00000,0x900000 ramdisk=34816 mem=768M
New: console=ttyS0,115200 root=/dev/ram initrd=0xb00000,0xc00000 ramdisk=34816 mem=768M cmdlinepart.mtdparts=spi0.0:512k@0(uboot)ro,3M@0x100000(Kernel),12M@0x400000(RootFS1),2M@0x200000(Kernel_legacy),256k@0x80000(U-Boot_Config),256k@0xc0000(NAS_Config) mtdparts=spi0.0:512k@0(uboot)ro,3M@0x100000(Kernel),12M@0x400000(RootFS1),2M@0x200000(Kernel_legacy),256k@0x80000(U-Boot_Config),256k@0xc0000(NAS_Config)
[Prepare fw_setenv script (/tmp/fw_setenv.script)]
[Dump current 'NAS config' and 'Kernel' images]
-
cat /dev/mtd5
[Resize 'NAS config' dump from 1280KB to 256KB.] -
modprobe loop
-
losetup --show -f /tmp/mtd_nas_config.dump
-
loopdev=/dev/loop0
-
e2fsck -f -p -v /dev/loop0
17 Inodes sind in Benutzung (13.28% von 128) 0 nicht zusammenhängende Dateien (0.0%) 0 nicht zusammenhängende Verzeichnisse (0.0%) # von Inodes mit ind/dind/tind Blöcken: 0/0/0 54 Blöcke werden benutzt (5.27% von 1024) 0 defekte Blöcke 0 große Dateien 6 reguläre Dateien 2 Verzeichnisse 0 zeichenorientierte Gerätedateien 0 Blockgerätedateien 0 Fifos 0 Verknüpfungen 0 symbolische Verknüpfungen (0 schnelle symbolische Verknüpfungen) 0 Sockets
8 Dateien
-
e2fsck -f -p -v /dev/loop0
17 Inodes sind in Benutzung (13.28% von 128) 0 nicht zusammenhängende Dateien (0.0%) 0 nicht zusammenhängende Verzeichnisse (0.0%) # von Inodes mit ind/dind/tind Blöcken: 0/0/0 54 Blöcke werden benutzt (5.27% von 1024) 0 defekte Blöcke 0 große Dateien 6 reguläre Dateien 2 Verzeichnisse 0 zeichenorientierte Gerätedateien 0 Blockgerätedateien 0 Fifos 0 Verknüpfungen 0 symbolische Verknüpfungen (0 schnelle symbolische Verknüpfungen) 0 Sockets
8 Dateien
-
resize2fs /dev/loop0 128
resize2fs 1.44.5 (15-Dec-2018)
Die Größe des Dateisystems auf /dev/loop0 wird auf 128 (1k) Blöcke geändert.
Das Dateisystem auf /dev/loop0 is nun 128 (1k) Blöcke lang. -
losetup -d /dev/loop0
[Concatenate first 256K of 'NAS config' with first 1MB of Kernel > /tmp/mtd_nas_config.new]
[Prepare second 1MB of kernel tail > /tmp/mtd_kernel.tail]
!!!! Warning !!!!
Everything is fine up to now.
Next steps will write the flash and may be subject to failures.
It is highly recommended to perform a MTD backup and save the files
somewhere (USB device, PC)
cat /dev/mtd0 > /tmp/mtd0.uboot.backup
cat /dev/mtd1 > /tmp/mtd1.kernel.backup
cat /dev/mtd2 > /tmp/mtd2.rootfs1.backup
cat /dev/mtd3 > /tmp/mtd3.rootfs2.backup
cat /dev/mtd4 > /tmp/mtd4.uboot-config.backup
cat /dev/mtd5 > /tmp/mtd5.nas-config.backup
fw_printenv -c /tmp/fw_env.config > /tmp/uboot_config.backup.txt
cd /tmp
tar cvzf mtd_backup.tgz mtd?.*.backup uboot_config.backup.txt
# now use scp / sftp to push/pull mtd_backup.tgz on another PC.
Be sure you will not cut the power until the end of operations.
In case of failure, you way need to recover with a Serial Console
to run U-boot commands
https://www.cyrius.com/debian/kirkwood/qnap/ts-219/serial/
Continue and flash the new partitions ? (y/N)
Note: You are using --dry-run option. No flash operations will be performed if you answer 'y'.
y
[Flash 'NAS config' partition content (ie 'NAS config' + head of Kernel) (still a 'safe' op)]
(Dry run)
- flashcp -v /tmp/mtd_nas_config.new /dev/mtd5
[Change U-boot config with new values)]
(Dry run)
- fw_setenv -c /tmp/fw_env.config -s /tmp/fw_setenv.script
[Flash tail of the kernel in old 'Kernel' Partition]
(Dry run)
- flashcp -v /tmp/mtd_kernel.tail /dev/mtd1
[Make a copy of /tmp/fw_env.config into /etc/fw_env.config (if not already existing)]
SUCCESS.
Now, REBOOT !
Notes:
- DO NOT PERFORM A KERNEL OR SYSTEM UPDATE before the next reboot !...
so don't wait too long.
- Consider compressing initrd with 'xz' to optimize the size with:
echo "COMPRESS=xz" > /etc/initramfs-tools/conf.d/compress
I didn't get to do it sooner.
root@Qnap-NAS:~# cat /proc/mtd
dev: size erasesize name
mtd0: 00080000 00001000 "uboot"
mtd1: 00300000 00001000 "Kernel"
mtd2: 00c00000 00001000 "RootFS1"
mtd3: 00200000 00001000 "Kernel_legacy"
mtd4: 00040000 00001000 "U-Boot_Config"
mtd5: 00040000 00001000 "NAS_Config"
I have one more question, what do I have to do with the kirkwood-ts419-6282.dtb file?
Does it have to be in a specific folder?
root@Qnap-NAS:/home/Con# sudo ./qnap_mtd_resize.py
[Check of the QNAP model and see if supported]
kirkwood-qnap: machine: QNAP TS419 family
DTB file: kirkwood-ts419-6282.dtb
Checking: flashcp -V
Checking: flash_erase --version
Using 'u-boot-tools' package
[find on which MTD device partitions are currently mounted]
spi0.0
[Dump current U-boot config']
Current U-boot bootcmd:
uart1 0x68;cp.l 0xf8200000 0x800000 0x80000;cp.l 0xf8400000 0xa00000 0x240000;bootm 0x800000
Current U-boot bootargs:
console=ttyS0,115200 root=/dev/ram initrd=0xa00000,0x900000 ramdisk=34816 mem=768M
[Prepare new 'bootcmd']
Old: uart1 0x68;cp.l 0xf8200000 0x800000 0x80000;cp.l 0xf8400000 0xa00000 0x240000;bootm 0x800000
New: uart1 0x68;cp.l 0xf8100000 0x800000 0xc0000;cp.l 0xf8400000 0xb00000 0x300000;bootm 0x800000;echo Kernel_legacy layout fallback;bootm 0x900000
[Prepare new 'bootargs']
Old: console=ttyS0,115200 root=/dev/ram initrd=0xa00000,0x900000 ramdisk=34816 mem=768M
New: console=ttyS0,115200 root=/dev/ram initrd=0xb00000,0xc00000 ramdisk=34816 mem=768M cmdlinepart.mtdparts=spi0.0:512k@0(uboot)ro,3M@0x100000(Kernel),12M@0x400000(RootFS1),2M@0x200000(Kernel_legacy),256k@0x80000(U-Boot_Config),256k@0xc0000(NAS_Config) mtdparts=spi0.0:512k@0(uboot)ro,3M@0x100000(Kernel),12M@0x400000(RootFS1),2M@0x200000(Kernel_legacy),256k@0x80000(U-Boot_Config),256k@0xc0000(NAS_Config)
[Prepare fw_setenv script (/tmp/fw_setenv.script)]
[Dump current 'NAS config' and 'Kernel' images]
-
cat /dev/mtd5
[Resize 'NAS config' dump from 1280KB to 256KB.] -
modprobe loop
-
losetup --show -f /tmp/mtd_nas_config.dump
-
loopdev=/dev/loop0
-
e2fsck -f -p -v /dev/loop0
17 Inodes sind in Benutzung (13.28% von 128) 0 nicht zusammenhängende Dateien (0.0%) 0 nicht zusammenhängende Verzeichnisse (0.0%) # von Inodes mit ind/dind/tind Blöcken: 0/0/0 54 Blöcke werden benutzt (5.27% von 1024) 0 defekte Blöcke 0 große Dateien 6 reguläre Dateien 2 Verzeichnisse 0 zeichenorientierte Gerätedateien 0 Blockgerätedateien 0 Fifos 0 Verknüpfungen 0 symbolische Verknüpfungen (0 schnelle symbolische Verknüpfungen) 0 Sockets
8 Dateien
-
e2fsck -f -p -v /dev/loop0
17 Inodes sind in Benutzung (13.28% von 128) 0 nicht zusammenhängende Dateien (0.0%) 0 nicht zusammenhängende Verzeichnisse (0.0%) # von Inodes mit ind/dind/tind Blöcken: 0/0/0 54 Blöcke werden benutzt (5.27% von 1024) 0 defekte Blöcke 0 große Dateien 6 reguläre Dateien 2 Verzeichnisse 0 zeichenorientierte Gerätedateien 0 Blockgerätedateien 0 Fifos 0 Verknüpfungen 0 symbolische Verknüpfungen (0 schnelle symbolische Verknüpfungen) 0 Sockets
8 Dateien
-
resize2fs /dev/loop0 128
resize2fs 1.44.5 (15-Dec-2018)
Die Größe des Dateisystems auf /dev/loop0 wird auf 128 (1k) Blöcke geändert.
Das Dateisystem auf /dev/loop0 is nun 128 (1k) Blöcke lang. -
losetup -d /dev/loop0
[Concatenate first 256K of 'NAS config' with first 1MB of Kernel > /tmp/mtd_nas_config.new]
[Prepare second 1MB of kernel tail > /tmp/mtd_kernel.tail]
!!!! Warning !!!!
Everything is fine up to now.
Next steps will write the flash and may be subject to failures.
It is highly recommended to perform a MTD backup and save the files
somewhere (USB device, PC)
cat /dev/mtd0 > /tmp/mtd0.uboot.backup
cat /dev/mtd1 > /tmp/mtd1.kernel.backup
cat /dev/mtd2 > /tmp/mtd2.rootfs1.backup
cat /dev/mtd3 > /tmp/mtd3.rootfs2.backup
cat /dev/mtd4 > /tmp/mtd4.uboot-config.backup
cat /dev/mtd5 > /tmp/mtd5.nas-config.backup
fw_printenv -c /tmp/fw_env.config > /tmp/uboot_config.backup.txt
cd /tmp
tar cvzf mtd_backup.tgz mtd?.*.backup uboot_config.backup.txt
# now use scp / sftp to push/pull mtd_backup.tgz on another PC.
Be sure you will not cut the power until the end of operations.
In case of failure, you way need to recover with a Serial Console
to run U-boot commands
https://www.cyrius.com/debian/kirkwood/qnap/ts-219/serial/
Continue and flash the new partitions ? (y/N)
y
[Flash 'NAS config' partition content (ie 'NAS config' + head of Kernel) (still a 'safe' op)]
- flashcp -v /tmp/mtd_nas_config.new /dev/mtd5
Erasing blocks: 320/320 (100%)
Writing data: 1280k/1280k (100%)
Verifying data: 1280k/1280k (100%)
[Change U-boot config with new values)]
- fw_setenv -c /tmp/fw_env.config -s /tmp/fw_setenv.script
[Flash tail of the kernel in old 'Kernel' Partition]
- flashcp -v /tmp/mtd_kernel.tail /dev/mtd1
Erasing blocks: 256/256 (100%)
Writing data: 1024k/1024k (100%)
Verifying data: 1024k/1024k (100%)
[Make a copy of /tmp/fw_env.config into /etc/fw_env.config (if not already existing)]
SUCCESS.
Now, REBOOT !
Notes:
- DO NOT PERFORM A KERNEL OR SYSTEM UPDATE before the next reboot !...
so don't wait too long.
- Consider compressing initrd with 'xz' to optimize the size with:
echo "COMPRESS=xz" > /etc/initramfs-tools/conf.d/compress
Ok, thanks for the answer, it had confused me. >.<
So my Nas has been running for almost 2 weeks without any problems, after resizing and flashing the new kernel, is it okay to ask how I can now install the latest debian?
To be honest, this is my only Debian device. Normally I used Ubuntu, it works differently there. 😅
Thank you for the link.