Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debian Buster installer on modified mtd partitions #20

Closed
lpaolini opened this issue Mar 7, 2022 · 4 comments
Closed

Debian Buster installer on modified mtd partitions #20

lpaolini opened this issue Mar 7, 2022 · 4 comments

Comments

@lpaolini
Copy link

lpaolini commented Mar 7, 2022

Hi Arnaud,

I've successfully updated a TS-219p and a TS-221 using your script, so thanks again!
Now, how can I build a Debian buster installer image for the new partition table?

I tried different methods, but with no success.

Method 1:

  1. downloaded kernel-6281 (on TS-219p) and padded it to 3MB with truncate -s 3145728 kernel-6281
  2. downloaded initrd and padded it to 12MB with truncate -s 12582912 initrd
  3. created an image with cat /dev/mtd0 /dev/mtd4 /dev/mtd5 kernel-6281 initrd > debian_buster_installer

Method 2:

  1. downloaded kernel-6281 (on TS-219p) and padded it to 2MB with truncate -s 2097152 kernel-6281
  2. downloaded initrd and padded it to 12MB with truncate -s 12582912 initrd
  3. copied the padded kernel to "Kernel_legacy" partition with cp kernel-6281 /dev/mtd3
  4. copied the padded initrd to "RootFS1" partition with cp initrd /dev/mtd2
  5. created an image with cat /dev/mtd0 /dev/mtd4 /dev/mtd5 /dev/mtd1 /dev/mtd2 > debian_buster_installer

Obviously I'm doing something wrong, as they both fail the CRC check (Bad magic number) while trying to boot.

Any ideas?
Thanks, Luca

@amouiche
Copy link
Owner

amouiche commented Mar 7, 2022

Hello Luca,
what would be the purpose of debian_buster_installer (how do expect to use this file in practice) ?
Arnaud

@lpaolini
Copy link
Author

lpaolini commented Mar 7, 2022

To reinstall Debian from scratch, in case I need it. Doesn't it make sense?

@amouiche
Copy link
Owner

amouiche commented Mar 8, 2022

but how do you use the debian_buster_installer file ?
On which state are you starting your install (from a QNAP firmware or on a QNAP with debian already installed) ?

For example, cp kernel-6281 /dev/mtd3 will not work on a debian (not even sure it will work on QNAP firmware). /dev/mtd3 is a MTD device. you don't write on it like a HDD. you have to use special tools that erase the device before writing on it (ie. flashcp, flash_erase)

what you need to install the debian installer from a already installed debian firmware is:

flashcp -v kernel-6281 /dev/mtd1
flashcp -v initrd /dev/mtd2
reboot

You don't need to care about padding.

Be very careful to not write or erase /dev/mtd0. Your QNAP will not boot

@lpaolini
Copy link
Author

Ok, I got it, at last. Many thanks @amouiche for explaining.

If you expect to use the QNAP recovery features (ie. press reset button during poweron), and present this 'image' file with a TFTP server, you must know that the bootloader doesn't flash the whole file, but only fixed parts:

  • 2MB of the expected kernel partition
  • 9MB of rootfs

This obviously makes it impossible to create an image based on modified mtd partitions which can be restored using QNAP recovery mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants