Kernel panic after ubi rootfs size increased - linux-kernel

I'm currently working with LTIB tool to generate linux kernel 3.0.25, with u-boot-2009-08, for iMX6 solo core board.
I use mfg tool to flash. When I installed new packages, the rootfs size changed from 147 to 162MiB. Since then, I can't boot anymore, the ubi doesn't get attached.
I have a kernel panic with the following logs :
**UBI error: process_eb: bad image sequence number 1588612812 in PEB 720, expected 1344834100**
UBI error: ubi_attach_mtd_dev: failed to attach by scanning, error -22
UBI error: ubi_init: cannot attach mtd9
UBIFS error (pid 1): ubifs_mount: cannot open "ubi0:root", error -19
VFS: Cannot open root device "ubi0:root" or unknown-block(0,0)
Please append a correct "root=" boot option; here are the available partitions:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
UBI error screenshot
Kernel Panic Screenshot
To get rid of this, I changed the u-boot mfg CONFIG_BOOTARGS as follows :
#define CONFIG_BOOTARGS "console=ttymxc1,115200 rdinit=/linuxrc mtdparts=gpmi-
nand:4m(boot),256k(bootenv),2m(splashscreen),10m(ramdisk),5m(kernel),5m(flasherkernel),256k(updater
),256k(flag1),256k(flag2),170m(rootfs),32m(userpart1),32m(userpart2),-(userpart)"\
Here's the ubinize.cfg :
[ubifs]
mode=ubi
image=ubifs.img
vol_id=0
vol_size=170MiB
vol_type=dynamic
vol_name=root
vol_flags=autoresize
And the ubi generation commands :
sudo mkfs.ubifs -r $ROOTFS -m 4096 -e 253952 -c 1184 -o ubifs.img
sudo ubinize -o $BUILT_IMG/ubi.img -m 4096 -p 256KiB ubinize.cfg
And the flash commands :
$ flash_eraseall /dev/mtd9 # Erasing Rootfs partition
$ send" file="files/ubi.img # Sending Root filesystem
$ ubiformat /dev/mtd9 -f $FILE -s 4096 -O 4096 # Flashing Root Filesystem
Any idea ?
Thanks

Related

Out of memory error installing laravel app on server

Installing my laravel 5.8 app on ubuntu 18( under Digital Ocean ) I got error :
Updating dependencies
: mmap() failed: [12] Cannot allocate memory
: mmap() failed: [12] Cannot allocate memory
: PHP Fatal error: Out of memory (allocated 533733376) (tried to allocate 4096 bytes) in /usr/share/php/Composer/DependencyResolver/RuleSetGenerator.php on line 126
: Out of memory (allocated 533733376) (tried to allocate 4096 bytes) in /usr/share/php/Composer/DependencyResolver/RuleSetGenerator.php on line 126
I check memory and see:
# free
total used free shared buff/cache available
Mem: 1009156 387908 147884 15716 473364 462800
I try to attach swap file and googling I found decision :
# sudo swapon -a
# sudo fallocate -l 1G /`file
>
and last command hang forever.
Next I tried :
# sudo mkswap /swapfile
mkswap: cannot open /swapfile: No such file or directory
# sudo swapon /swapfile
swapon: cannot open /swapfile: No such file or directory
# cat /proc/partitions
major minor #blocks name
252 0 26214400 vda
252 1 26100719 vda1
252 14 4096 vda14
252 15 108544 vda15
# fdisk -l || mount | grep sd
Disk /dev/vda: 25 GiB, 26843545600 bytes, 52428800 sectors
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: gpt
Disk identifier: C1F9A1FE-534C-4DAC-9299-5CC180C29DCE
Device Start End Sectors Size Type
/dev/vda1 227328 52428766 52201439 24.9G Linux filesystem
/dev/vda14 2048 10239 8192 4M BIOS boot
/dev/vda15 10240 227327 217088 106M Microsoft basic data
Partition table entries are not in disk order.
Why error and how to fix it ?
Modified block:
as composer run in envoy script I tried with switching to used user and setting memory as next:
# which composer
/usr/bin/composer
su -l lardeployer
php -d memory_limit=1024M /usr/bin/composer update
Composer could not find a composer.json file in /home/lardeployer
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
But last message with ref to "Getting Started" section confused me...
How to fix it?

MIPS Linux kernel in qemu trips on initrd

I grabbed initrd and vmlinux (kernel 4.9.0) images from http://ftp.debian.org/debian/dists/Debian9.5/main/installer-mips/20170615+deb9u4/images/malta/netboot, installed and booted Qemu just fine:
$ qemu-system-mips -M malta -m 1G -hda ./debian-mips.qcow2 \
-initrd $initrd \
-kernel $vmlinux \
-append "nokaslr root=/dev/sda1" -nographic
Then I cross-compiled fresh kernel 4.18.0 using the same config as for 4.9.0, but this time Qemu fails to boot:
...
[ 4.036903] NET: Registered protocol family 17
[ 4.045894] rtc_cmos 70.rtc: setting system clock to 2018-07-23 02:26:58 UTC (1532312818)
[ 4.076247] Freeing unused kernel memory: 1528K
[ 4.076491] This architecture does not have kernel memory protection.
Loading, please wait...
starting version 232
[ 4.685538] random: systemd-udevd: uninitialized urandom read (16 bytes read)
[ 4.703542] random: systemd-udevd: uninitialized urandom read (16 bytes read)
[ 4.754874] random: udevadm: uninitialized urandom read (16 bytes read)
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... Begin: Waiting for suspend/resume device ... Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
...
done.
Gave up waiting for suspend/resume device
done.
Begin: Waiting for root file system ... Begin: Running /scripts/local-block ...
done.
done.
Gave up waiting for root file system device. Common problems:
- Boot args (cat /proc/cmdline)
- Check rootdelay= (did the system wait long enough?)
- Missing modules (cat /proc/modules; ls /dev)
ALERT! /dev/sda1 does not exist. Dropping to a shell!
BusyBox v1.22.1 (Debian 1:1.22.0-19+b3) built-in shell (ash)
Enter 'help' for a list of built-in commands.
(initramfs)
I believe I have all the required drivers/hardware support compiled in, since I'm using the same .config file. Also, I mounted my qemu image, and did make modules_install in there, so the image does have the correct modules matching the kernel version.
UPDATE
So I enabled all the drivers under DeviceDrivers/ATA/ATAPI/MFM/RLL support (DEPRECATED) and DeviceDrivers/Serial ATA and Parallel ATA drivers (libata), rebuild the kernel, installed it in qemu image, booted up:
[ 4.437168] ata2.00: ATAPI: QEMU DVD-ROM, 2.5+, max UDMA/100
[ 4.442551] ata1.00: ATA-7: QEMU HARDDISK, 2.5+, max UDMA/100
[ 4.443553] ata1.00: 20971520 sectors, multi 16: LBA48
[ 4.478753] scsi 0:0:0:0: Direct-Access ATA QEMU HARDDISK 2.5+ PQ: 0 ANSI: 5
[ 4.490907] sd 0:0:0:0: Attached scsi generic sg0 type 0
[ 4.498621] sd 0:0:0:0: [sda] 20971520 512-byte logical blocks: (10.7 GB/10.0 GiB)
[ 4.501629] sd 0:0:0:0: [sda] Write Protect is off
[ 4.508063] scsi 1:0:0:0: CD-ROM QEMU QEMU DVD-ROM 2.5+ PQ: 0 ANSI: 5
[ 4.518142] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[ 4.539178] sr 1:0:0:0: [sr0] scsi3-mmc drive: 4x/4x cd/rw xa/form2 tray
[ 4.540712] cdrom: Uniform CD-ROM driver Revision: 3.20
[ 4.564806] sr 1:0:0:0: Attached scsi generic sg1 type 5
[ 4.569555] sda: sda1 sda2 < sda5 >
[ 4.588040] sd 0:0:0:0: [sda] Attached SCSI disk
[ 5.102260] Freeing unused kernel memory: 1556K
[ 5.102988] This architecture does not have kernel memory protection.
Loading, please wait...
starting version 232
[ 7.297015] random: systemd-udevd: uninitialized urandom read (16 bytes read)
[ 7.341169] random: systemd-udevd: uninitialized urandom read (16 bytes read)
[ 7.527445] random: udevadm: uninitialized urandom read (16 bytes read)
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... done.
Begin: Will now check root file system ... fsck from util-linux 2.29.2
[/sbin/fsck.ext4 (1) -- /dev/sda1] fsck.ext4 -a -C0 /dev/sda1
/dev/sda1: clean, 29311/628320 files, 454566/2512640 blocks
done.
mount: mounting /dev/sda1 on /root failed: No such device
done.
Begin: Running /scripts/local-bottom ... done.
Begin: Running /scripts/init-bottom ... mount: mounting /dev on /root/dev failed: No such file or directory
mount: mounting /dev on /root/dev failed: No such file or directory
done.
mount: mounting /run on /root/run failed: No such file or directory
run-init: current directory on the same filesystem as the root: error 0
Target filesystem doesn't have requested /sbin/init.
run-init: current directory on the same filesystem as the root: error 0
run-init: current directory on the same filesystem as the root: error 0
run-init: current directory on the same filesystem as the root: error 0
run-init: current directory on the same filesystem as the root: error 0
run-init: current directory on the same filesystem as the root: error 0
No init found. Try passing init= bootarg.
What else is possibly going wrong here?
Thanks.
The kernel configuration has to include the following options for correct FS mount procedure :
a) Device Drivers/Serial ATA and Parallel ATA drivers (libata) -- CONFIG_ATA_SFF, CONFIG_ATA_BMDMA, CONFIG_ATA_PIIX
b) Device Drivers/Generic Driver Options -- CONFIG_DEVTMPFS

Vanilla kernel build on Rasperry Pi 1 B+

Attempting to build mainline vanilla kernel (4.9) and boot on a Raspberry Pi 1 B+. Have followed instructions here. Currently boot hangs with the following output
Net: No ethernet found. starting USB...
USB0: Core Release: 2.80a
scanning bus 0 for devices... 3 USB Device(s) found
scanning usb for storage devices... 0 Starage Device(s) found
Hit any key to stap autoboot: 0
switch to partition #0, OK
mmc0 is current device
Scanning mmc 0:1
Found U-Boot script /boot.scr.uimg
reading /boot.scr.uimg 326 bytes read in 25 ms (12.7KiB/s)
## Exectuting script at 02000000 switch to partitions #0, OK
mmc0 is current device
reading ZImage
4064616 bytes read in 389 Ms (10MiB/s)
reading bcm2835-rpi-b-plus.dtb
7101 bytes read in 31 Ms (223.6KiB/s)
Kernel image # 0x1000000 [ 0x000000 _0x3e0568 ]
## Flattened Device Tree blob at 00000100
Booting using the fdt blob at 0x000100
Using Device Tree in place at 00000100, end 00004cbc
Starting kernel ...
boot.scr.uimg was built using mkimage from Ubuntu repositories
$ mkimage -V
mkimage version 2016.01+dfsg1-2ubuntu3
$ mkimage -A arm -O linux -T script -C none -n boot.scr -d boot.scr boot.scr.uimg
boot.scr is as listed in the instructions.
mmc dev 0
setenv fdtfile bcm2835-rpi-b-plus.dtb
setenv bootargs earlyprintk console=tty0 console=ttyAMA0 root=/dev/mmcblk0p2 rootwait
fatload mmc 0:1 ${kernel_addr_r} zImage
fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}
bootz ${kernel_addr_r} - ${fdt_addr_r}

Linux Kernel - ERROR: Failed to allocate 0x6b3c bytes below 0x1000000

I'm including my rootfs (CONFIG_INITRAMFS_SOURCE) into my kernel, so the kernel has now a size of 17Mb:
$ ls -la uImage
-rw-r--r-- 1 kkr kkr 17669274 Dec 1 18:59 uImage
$ d2h 17669274
0x10D9C9A
Since it's compressed, it would occupied uncompressed 39Mb:
$ dd if=uImage of=uImage-x.gz bs=64 skip=1
$ file uImage-x.gz
uImage-x.gz: gzip compressed data, max compression, from Unix
$ gunzip uImage-x.gz
$ ls -la uImage-x
-rw-r--r-- 1 kkr kkr 39852288 Dec 1 19:18 uImage-x
$ d2h 39852288
0x2601900
Why cannot I start my kernel via uBoot with this commands?
=> setenv bootargs console=$consoledev,$baudrate $othbootargs
=> tftp 0x3000000 $bootfile
Speed: 100, half duplex
Using eTSEC1 device
TFTP from server 192.168.32.3; our IP address is 192.168.32.32
Filename 'uImage-powerpc'.
Load address: 0x3000000
Loading: #####################################################
done
Bytes transferred = 17669274 (10d9c9a hex)
=> tftp 0x2700000 $fdtfile;
Speed: 100, half duplex
Using eTSEC1 device
TFTP from server 192.168.32.3; our IP address is 192.168.32.32
Filename 'sat_92107.100.00C_p2020.dtb'.
Load address: 0x2700000
Loading: ##
done
Bytes transferred = 15164 (3b3c hex)
=> bootm 0x3000000 - 0x2700000
## Booting kernel from Legacy Image at 03000000 ...
Image Name: Linux-4.0.0-AOA00.01-00662-g07ae
Created: 2015-12-01 17:59:21 UTC
Image Type: PowerPC Linux Kernel Image (gzip compressed)
Data Size: 17669210 Bytes = 16.9 MiB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
## Flattened Device Tree blob at 02700000
Booting using the fdt blob at 0x02700000
Uncompressing Kernel Image ... OK
ERROR: Failed to allocate 0x6b3c bytes below 0x1000000.
device tree - allocation error
Since the kernel itself needs 0x10d9c9a bytes (compressed) or 0x2601900 bytes (uncompressed) there is no chance to place the devicetree below 0x1000000. Is this value (16Mb) configurable? Does my extracted kernel have be less than 16Mb otherwise?
Yes, this value is configurable in U-Boot by setting the environment variables bootm_low and bootm_size to hexadecimal values. In your case, it's 0x0 and 0x20000000, respectively.
See section "Environment Variables" of the big README file in the U-Boot source tree.

How to mount ext2 fs?

fdisk is used to create mmcblk0p3 on the 64G SD card.
Disk /dev/mmcblk0: 63.8 GB, 63864569856 bytes
255 heads, 63 sectors/track, 7764 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 * 2 6 40162+ c Win95 FAT32 (LBA)
/dev/mmcblk0p2 7 130 996030 83 Linux
/dev/mmcblk0p3 131 7764 61320105 83 Linux
The fs is then formatted like this:
$ mke2fs -L media /dev/mmcblk0p3
Filesystem label=media
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
3833856 inodes, 15330026 blocks
766501 blocks (5%) reserved for the super user
First data block=0
Maximum filesystem blocks=16777216
468 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, ...
Mount point /media definitely exists and $ mount /dev/mmcblk0p3 /media works fine when mmcblk0p3 is a FAT32 FS on a Win95 FAT32 partition. I need to change from FAT32 to ext2 since the FAT32 partition 3 is too easily hosed in this embedded Linux target (power cycle, USB mass storage disconnects, etc.). An Ubuntu 10.04 desktop system has been used to verify that the partition type is ext2 and is able to mount the SD card partition but this needs to work on the embedded Linux target. The kernel version is 2.6.32-17-ridgerun with BusyBox v1.18.2.
Why does $ mount /dev/mmcblk0p3 /media cause mount: mounting /dev/mmcblk0p3 on /media failed: Invalid argument?
Why does mount -t ext2 /dev/mmcblk0p3 /media cause mount: mounting /dev/mmcblk0p3 on /media failed: No such device?
Why does $ mount /dev/mmcblk0p3 /media cause mount: mounting
/dev/mmcblk0p3 on /media failed: Invalid argument?
The kernel can probably mount the filesystem, but it wrongly guess its type.
Why does mount -t ext2 /dev/mmcblk0p3 /media cause mount: mounting
/dev/mmcblk0p3 on /media failed: No such device?
If, after you specified -t, you get a problem like that, it is very likely that the kernel cannot mount the requested filesystem for you. Check if there is a module for that filesystem and it is loaded.
lsmod # show modules
modprobe ext2 # load module
Sources : http://www.silas.net.br/doc.notes/unix/linux/busybox-troubleshooting.html
As far as I know ext2 modules are already loaded by default. But it won't hurt to check.
The problem here I think is the ambiguity due to mke2fs. mke2fs can be used to create ext2/ext3/ext4 filesystems. You have to specify the file system via -t option. Try doing this :
#mkfs -t ext2 /dev/hda1
#mkfs.ext2 /dev/hda1
You missed out -t option in your command making mke2fs format it with filesystem in default conf.

Resources