Commit Graph

54 Commits (a6b7c3e672764858fd294998406ae791f5964b4a)

Author SHA1 Message Date
李国 a6b7c3e672 x86: generate EFI platform bootable images
Add EFI platform bootable images for x86 platforms. These images can
also boot from legacy BIOS platform.

EFI System Partition need to be fat12/fat16/fat32 (not need to load
filesystem drivers), so the first partition of EFI images are not ext4
filesystem any more.

GPT partition table has an alternate partition table, we did not
generate it. This may cause problems when use these images as qemu disk
(kernel can not find rootfs), we pad enough sectors will be ok.

Signed-off-by: 李国 <uxgood.org@gmail.com>
[part_magic_* refactoring, removed genisoimage checks]
Signed-off-by: Petr Štetiar <ynezz@true.cz>
4 years ago
Tomasz Maciej Nowak b9c1cf1657 x86: add preinit hook for bootloader upgrade
This commit fills the void for current OpenWrt installations which will
be still on old bootloader version even after "x86: add bootloader
upgrade on sysupgrade", since it performs bootloader upgrade only on
sysupgrade. To keep all OpenWrt deploynents on the same GRUB version,
add preinit hook, which will perform upgrade of the bootloader on first
boot after sysupgrade.

It's temporary solution and should be deleted, when the first release
including this hook will no longer be supported by OpenWrt team.
We can assume that all installations should be on current bootolader
version and from there sysupgrade routine will be sufficient.

Signed-off-by: Tomasz Maciej Nowak <tomek_n@o2.pl>
4 years ago
Tomasz Maciej Nowak b322243d2f x86: add bootloader upgrade on sysupgrade
Currently bootloader always stays on the same version as when first
written to boot medium (not true if partition layout changed, which will
trigger sysupgrade process to write full disk image). That creates
inconveniences as it always stays with same features or/and bugs. Users
wishing to add support to additional modules or new version, would need
to write the whole image, potentially destroying previous system
configuration. To fix these, this commit adds additional routine to
sysupgrade which upgrades unconditionally the bootloader to the latest
state provided by OpenWrt.

Signed-off-by: Tomasz Maciej Nowak <tomek_n@o2.pl>
4 years ago
Rafał Miłecki 641f6b6c26 treewide: use new procd sysupgrade $UPGRADE_BACKUP variable
It's a variable set by procd that should replace hardcoded
/tmp/sysupgrade.tgz.

This change requires the most recent procd with the commit 0f3c136
("sysupgrade: set UPGRADE_BACKUP env variable").

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
5 years ago
Rafał Miłecki 62dbe361a1 treewide: when copying a backup file always specify dest name
$CONF_TAR shouldn't be assumed to always point to the sysupgrade.tgz.
This change makes code more generic and allows refactoring $CONF_TAR.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
5 years ago
Rafał Miłecki bf39047872 treewide: don't hardcode "sysupgrade.tgz" file name
1) Add BACKUP_FILE and use it when copying an archive to be restored
   after sysupgrade (on the next preinit).
2) Use CONF_TAR for copying backup prepared by the /sbin/sysupgrade

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
5 years ago
Rafał Miłecki b6f4cd57e1 treewide: sysupgrade: pass "save_partitions" option to the "sysupgrade" method
This explicitly lets stage2 know if partitions should be preserved. No
more "touch /tmp/sysupgrade.always.overwrite.bootdisk.partmap" hack.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
5 years ago
Tomasz Maciej Nowak c288ad9c2b x86: make sysupgrade.tgz reachable again
Moving binding mount before check for saved sysupgrade configuration
made it unreachable. Fix it by moving binding mount after the check.

Fixes: f78b2616 (x86: mount writable bootfs)
Reported-by: Lucian Cristian <luci@powerneth.ro>
Signed-off-by: Tomasz Maciej Nowak <tomek_n@o2.pl>
6 years ago
John Crispin c6aa4f53e8 Revert "x86: add intel microcode entries to grub config"
This reverts commit 546fced2a2.

Signed-off-by: John Crispin <john@phrozen.org>
6 years ago
John Crispin 8ead5a735d Revert "x86: add amd microcode entries to grub config"
This reverts commit a822283c7e.

Signed-off-by: John Crispin <john@phrozen.org>
6 years ago
Tomasz Maciej Nowak a822283c7e x86: add amd microcode entries to grub config
Create initrd enries for x86 images, that'll load amd microcode as early
as possible. Also remove the preinit script responsible for late load of
microcode.

Signed-off-by: Tomasz Maciej Nowak <tomek_n@o2.pl>
6 years ago
Tomasz Maciej Nowak 546fced2a2 x86: add intel microcode entries to grub config
Create initrd enries for x86 images, that'll load intel microcode as
early as possible. To achieve that the test module for grub is enabled
which provides shell-like conditionals. Also restrict the late load of
microcode to AMD processors.

Signed-off-by: Tomasz Maciej Nowak <tomek_n@o2.pl>
6 years ago
Tomasz Maciej Nowak f78b261637 x86: mount writable bootfs
Mount boot file system with rw option to allow installation of packages
which install files to /boot directory.

Signed-off-by: Tomasz Maciej Nowak <tomek_n@o2.pl>
6 years ago
Zoltan HERPAI 1ba6d59f2b x86: add preinit hook to reload microcode
Signed-off-by: Zoltan HERPAI <wigyori@uid0.hu>
6 years ago
Philip Prindeville d280c03a1d x86: preinit: use board_name on Sm Super Servers
Supermicro puts "Super Server" into their product_name DMI value
for a whole slew of products, making this value about as useful
as not having been filled in at all.  Instead, fall back on the
board_name instead.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
6 years ago
Philip Prindeville 445f980a38 x86: preinit: make name rewrite into reusable function
There might be other places (such as vendor-supplied preinit scripts)
where we wish to take a DMI name and clean it up in a consistent way,
so make the sed command into a function.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
6 years ago
Mathias Kresin ac3e05c5d7 treewide: populate boardname and model earlier
For targets using the generic board detection and board specific
settings in diag.sh, the board name is still unset at the time the
set_state() provided by diag.sh is called by 10_indicate_preinit.

Change the execution order to ensure the boardname is populated before
required the first time. Do the target specific board detection as
early as possible, directly followed by the generic one to allow a
seamless switch to the generic function for populating /tmp/sysinfo/.

Signed-off-by: Mathias Kresin <dev@kresin.me>
7 years ago
Matthias Schiffer dac07ca05b
x86: sysupgrade: explicitly rescan disk after writing partition table
This should ensure that the kernel partition can be mounted in
platform_copy_config when its size has changed.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
7 years ago
Matthias Schiffer a77633d36d
x86: sysupgrade: refactor platform_do_upgrade
By returning early when no upgrade device can be found and handling the
SAVE_PARTITIONS=0 case differently, we can get rid of two levels of if.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
7 years ago
Matthias Schiffer 19b84cfff2
x86: sysupgrade: move partition table change check to platform_check_image
The staged sysupgrade will prevent us from using ask_bool in
platform_do_upgrade; therefore, the check is moved to platform_check_image.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
7 years ago
Daniel Golle 63571cb56c x86: keep /boot mounted for kexec
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
7 years ago
Felix Fietkau b02c381b4b x86: fix sysupgrades on disks with 4k block size
Even when the disk uses 4k blocks, the partition table still uses units
of 512 byte sectors. Always use ibs=512 for the offsets

Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 years ago
Yousong Zhou 6f61d8511e base-files: export x86 platform upgrade functions to common.sh
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
8 years ago
Yousong Zhou fa37bdc05a x86: move sysupgrade.tgz only if it exists
To squash error messages at boot time

    mv: can't rename '/mnt/sysupgrade.tgz': No such file or directory

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
8 years ago
Jo-Philipp Wich 699f7ecd15 x86: use sysfs DMI information to populate sysinfo
Use the DMI data available in sysfs to extract manufacturer and model info
and write it to /tmp/sysinfo/.

The data will be picked up by board_detect and can be used by e.g. LuCI to
display a more appropriate model description.

On an APU board the files will contain the following values:

    # cat /tmp/sysinfo/model
    PC Engines APU

    # cat /tmp/sysinfo/board_name
    pc-engines-apu

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
8 years ago
Jo-Philipp Wich 1012701014 x86: generalize partition discovery for sysupgrade
Generalize the partition discovery in sysupgrade in order to fix sysupgrade
and config backup/recovery on MMC block devices which use a different naming
scheme compared to mtdblock or sd* devices.

The change also adds the find applet to the ramdisk utilities so that upgrade
code can rely on it.

The commit is based on the initial submission by Russell Senior at
http://patchwork.ozlabs.org/patch/625440/ .

Signed-off-by: Russell Senior <russell@personaltelco.net>
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
8 years ago
Jo-Philipp Wich 924fb794bd x86: search PARTUUID in any block device
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
8 years ago
Jo-Philipp Wich 9f422eba7c x86: make sysupgrade work without partx
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
8 years ago
Hauke Mehrtens 8a7b28071f x86: fix platform_export_bootpart() for Xen virtual disks
Virtual disk devices in a Xen virtual machine (DomU) can be /dev/xvda,
/dev/xvdb and so on with partitions like /dev/xdva1. Devices named like
this where not considered before. This resulted in a non working
sysupgrade, because the boot partition could not be found.

Signed-off-by: Alexander Dahl <alex@netz39.de>
Suggested-by: Matthias Schiffer <mschiffer@universe-factory.net>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>

SVN-Revision: 49190
8 years ago
Jo-Philipp Wich 4aeeead303 x86: preserve partition table on sysupgrade
With this patch sysupgrade will write directly to the partitions
instead of to the main disk.  The UUID is copied from the image
to the MBR as well.  This prevents the mbr from being completely
overwritten and losing the partition table.  The -p option has
been added to maintain the original behavior and overwite the
entire disk with the new image.  Tests have been added to ensure
that the image partitions match up with the active partitions.

Signed-off-by: Rob Mosher <nyt-openwrt@countercultured.net>

SVN-Revision: 48682
8 years ago
Jo-Philipp Wich 02e2548b84 x86: use PARTUUID instead explicitly specifying the device by default
This changes the x86 image generation to match x86_64, using the PARTUUID for
the rootfs instead of explicitly configuring the device.

It unbreaks KVM with VirtIO, which uses /dev/vda2 instead of /dev/sda2.

Tested in QEMU/KVM with VirtIO, VirtualBox and VMware.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>

SVN-Revision: 44966
9 years ago
Felix Fietkau d2b08fb4ab x86: remove old soekris config hacks, install a more appropriate default /etc/config/network with lan+wan
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 42888
10 years ago
John Crispin f933a741a9 target/linux/*/base-files/lib/upgrade/platform.sh - wrong check for ARGC
ARGC is a 'C-ism', but not known/valid in shell-syntax - insert the correct
var $# (=number of args) here. under normal conditions this had no impact,
but we should at least correct it. the error was observable like this:

root@box:~ [ -e "/etc/functions.sh" ] && . /etc/functions.sh
root@box:~ [ -e "/lib/functions.sh" ] && . /lib/functions.sh
root@box:~ . /lib/upgrade/platform.sh
root@box:~ . /lib/upgrade/common.sh
root@box:~ platform_check_image /tmp/myfirmware.bin
ash: bad number
root@box:~ echo $?
0

Signed-off-by: Bastian Bittorf <bittorf@bluebottle.com>

SVN-Revision: 40915
10 years ago
Felix Fietkau a14437024c x86: fix sysupgrade
Function move_config should be called after or during preinit_mount_root
hook in do_mount_root function. At this state sysupgrade.tgz is not in its
place during that time when do_mount_root is called. Function move_config
is called later so the sysupgrade.tgz stays in root directory to the second
restart when it is unpacked properly.

This patch adds move_config function to preinit_mount_root hook instead
of preinit_main and changes the filename of script to be called before
80_mount_root is called. It will prepare the sysupgrade archive for do_mount_root
within preinit_mount_root hook.

This patch solves ticket #15042 and #14088.

Signed-off-by: Jiri Slachta <slachta@cesnet.cz>

SVN-Revision: 39996
10 years ago
Felix Fietkau b95bdc8ab5 kernel/base-files: clean up old code related to refreshing mtd partitions, it is no longer used anywhere
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 37282
11 years ago
John Crispin 831c7ea04f preinit: move cmdline failsafe= handling ot the generic code
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 36430
11 years ago
Mirko Vogt 439a869090 Do not overload mount-call - trying to reduce confusion
The behaviour of calling 'mount' differed depending on whether it called
the busybox-mount, the mount of util-linux, the mount defined in
/lib/functions.sh and /lib/functions/boot.sh

/etc/preinit even included /lib/functions.sh and /lib/functions/boot.sh,
both re-defining 'mount'.

SVN-Revision: 34792
12 years ago
Jo-Philipp Wich f600ec5b3b x86: allow both old and new grub signatures in sysupgrade
SVN-Revision: 33898
12 years ago
Felix Fietkau 95e642632a x86: correct image magic for grub2 images
Sysupgrade broke on x86 when grub2 superceded grub.  This patch
corrects tha magic_word to be expected in grub2 combined images.

Signed-off-by: Russell Senior <russell@personaltelco.net>

SVN-Revision: 33890
12 years ago
Felix Fietkau a1bcd25082 x86: add grub2 iso support
SVN-Revision: 33639
12 years ago
Vasilis Tsiligiannis 1978c07539 Fix sysupgrade for squashfs, jffs2 and ext4 images
* use 'fsync' with 'dd' for image writing
	* save config to boot partition

SVN-Revision: 32465
12 years ago
Felix Fietkau 3d9d5cee8a x86/soekris: Add script to detect soekris model
Add script to detect soekris board of net4801 and net4826.

Patch from: kentarou matsuyama <matsuyama@thinktube.com>

SVN-Revision: 25102
14 years ago
Nicolas Thill 1fc7da0306 sysupgrade: fix typo in platform_do_upgrade() on x86 (closes: #7068), thanks to acinonyx
SVN-Revision: 20703
14 years ago
Florian Fainelli e1a4f69cb5 sysupgrade: Get target device from kernel cmdline, patch from acinonyx
SVN-Revision: 20538
14 years ago
Jo-Philipp Wich 817d27bcdc sysupgrade: Dump image to sda device instead of hda (patch by Acinonyx)
SVN-Revision: 20514
14 years ago
Jo-Philipp Wich c63fd559fc base-files: remove redundant "Press " when writing enter failsafe message
SVN-Revision: 20393
14 years ago
Jo-Philipp Wich 9feb2ed7c5 preinit: use grep -q where applicable
SVN-Revision: 19479
15 years ago
Felix Fietkau b88fc11e2a preinit: Remove Ctrl-C prompt...impossible on /dev/console (patch by cshore)
SVN-Revision: 19367
15 years ago
Felix Fietkau 56bc02a305 add preinit modularization work by Daniel Dickinson (cshore)
SVN-Revision: 19331
15 years ago
Jo-Philipp Wich 5231811851 sysupgrade-ext2 sync before writing image, not after Sysupgrade for ext2 currently flushes the filesystem buffers after an image is written to the disk. This should happen before the image is written.
SVN-Revision: 16867
15 years ago