Can't format a usb volume using fdisk - format

I tried to format a usb flash disk to FAT32 using fdisk /dev/sdb(I created a new partition and saved changes with w) and mkfs.vfat -F 32 /dev/sdb but when i eject and mount the volume again,it looks like it's empty.
dmesg | tail
outputs:
[ 8583.830684] usb-storage 3-2:1.0: USB Mass Storage device detected
[ 8583.830801] scsi host5: usb-storage 3-2:1.0
[ 8584.864614] scsi 5:0:0:0: Direct-Access Generic Flash Disk 5.00 PQ: 0 ANSI: 2
[ 8584.865005] sd 5:0:0:0: Attached scsi generic sg1 type 0
[ 8584.865070] sd 5:0:0:0: [sdb] 31283200 512-byte logical blocks: (16.0 GB/14.9 GiB)
[ 8584.865194] sd 5:0:0:0: [sdb] Write Protect is off
[ 8584.865196] sd 5:0:0:0: [sdb] Mode Sense: 0b 00 00 08
[ 8584.865314] sd 5:0:0:0: [sdb] No Caching mode page found
[ 8584.865318] sd 5:0:0:0: [sdb] Assuming drive cache: write through
[ 8584.870170] sd 5:0:0:0: [sdb] Attached SCSI removable disk

mkfs.vfat -F 32 /dev/sdb
Running this command overwrites any partitioning of the disk. You should have used
mkfs.vfat -F 32 /dev/sdb1
instead. This will create the filesystem on the first partition of sdb.

Related

U-boot tftp ramdisk Bad Trap when loading larger rootfs

I'm booting kernel on my board with u-boot ramdisk image which is 39.8 MB. It boots successfully. When I try another u-boot image which has 74.7 MB size, load adress of ramdisk changing and its giving
'Loading Ramdisk to ff8c0000, end 03fffd63... Bad Trap at PC:7fef8cb0'
and board hangs with ' ###ERROR ### Please RESET the board ###'
Commands I use for booting with tftp:
tftp 30000000 uImage.bin
tftp 32000000 DTB.dtb
tftp 40000000 rootfs.ext2.gz.u-boot
bootm 30000000 40000000 32000000
I also tried different tftp adresses.
Scenario remains same.
How can I solve this situation?
Edit: Full Console log:
=> bootm 30000000 40000000 32000000 WARNING: adjusting available memory to 30000000
Booting kernel from Legacy Image at 30000000 ...
Image Name: Linux-4.19.26+gc0c2141
Image Type: PowerPC Linux Kernel Image (gzip compressed)
Data Size: 7140198 Bytes = 6.8 MiB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
Loading init Ramdisk from Legacy Image at 40000000 ...
Image Name: core-image-x11-t1042d4rdb-64b-20
Image Type: PowerPC Linux RAMDisk Image (uncompressed)
Data Size: 74710371 Bytes = 71.2 MiB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
Flattened Device Tree blob at 32000000
Booting using the fdt blob at 0x32000000
Uncompressing Kernel Image ... OK
Loading Ramdisk to ff8c0000, end 03fffd63 ... Bad trap at PC:
7fef8cb0, SR: 0
NIP: 7FEF8CB0 XER: 20000000 LR: 7FF16C60 REGS: 7faedae0 TRAP: 0d00
DAR: FFFFEFFC
MSR: 00021200 EE: 0 PR: 0 FP: 0 ME: 1 IR/DR: 00
GPR00: 00000003 7FAEDBD0 7FAEDE98 FF8C0000 4073F038 0473FD60 FFFFF000
5E2AE23B GPR08: DE633873 00000020 00000001 7FAEDBE0 7FFCB808 08200800
7FAF52E8 00000000 GPR16: 00000000 00000000 306CF3A6 30000000 00000001
30000040 00000000 7FF957A8 GPR24: 7FAF533C 7FFCB6FC 7FFCB718 40000040
04000000 7FFCB6F8 7FF78540 0473FD63 Call backtrace: 7FFCB6F8 7FF176CC
7FF0D9D4 7FEFA26C 7FF1B088 7FF0BC44 7FF0BE08 7FF0C3B8 7FF1A664
7FF09CDC 7FF0CCC4 7FF4FF3C 7FF0D1D0 7FEF1040 Exception in kernel pc
7fef8cb0 signal 0
ERROR ### Please RESET the board ###
You are loading the kernel image at 0x30000000. Afterwards you are loading the device tree at 0x30000000.
0x32000000 - 0x30000000 = 0x2000000 = 33554432
So when loading the device tree you are overwriting the kernel image.
If the area between 0x3f000000 and 0x40000000 is not used otherwise, choosing 0x3f000000 for the device tree should solve your problem.
What I understood so far is, the adress in
'Bad trap at PC: 7fef8cb0'
7fef8cb0 nearly equals 1,998995945 GB and start adress of Ramdisk seems ff8c0000 which nearly equals 3,992919922 GB.
Why U-boot is arranged so many memory for a ~70 MB ramdisk image ?

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