output
stringlengths 9
26.3k
| input
stringlengths 26
29.8k
| instruction
stringlengths 14
159
|
---|---|---|
Bootable usb thumb drive with 2 partitions.
Windows and others may only see the first partition on a usb device even when there are multiple partitions. Therefore make your first primary partition the fat32 or NTFS partition so windows can see and use it.
partition 1 - ntfs or vfat
partition 2 - ext4
The second partition is where you will store the bootable iso.
Use grub to load and select what live OS you want to use.
steps:
1: zero out partition table
sudo dd if=/dev/zero of=/dev/sdx bs=512 count=42: Create partitions (use cli “fdisk” or gui “gparted”)
create partition table "msdos"
create 2 partitions
p1 = ntfs
p2 = ext4 -- tag as bootable.
format partitions.
3: Install grub bootloader to usb device
sudo grub-install --boot-directory /mnt/usbp2/boot /dev/sdxVerify: If these exist all is well so far.../mnt/usbp2/boot/grub/fonts -- minimum unicode.pf2
/mnt/usbp2/boot/grub/i386-pc -- *.mod modules to load in you grub.cfg
/mnt/usbp2/boot/grub/local -- languages
/mnt/usbp2/boot/grub/grubenv -- environment variable storage4: Create a grub.cfg file for the OS's on this pc
sudo grub-mkconfig --output=/mnt/usbp2/boot/grub/grub.cfgTest by booting to usb
5: Copy support files to the usbiso files
memdisk binary -- get from syslinux
grub.cfg -- custom for your usb stick. Overwrite grub.cfg created by grub-mkconfigNote: each live iso may require different grub information.
Note: If you only get a grub command line, your grub.cfg probably contains errors. Go minimal to start.
6: Create your custom usb boot installer.
Copy the MBR and Partition Table
dd if=/dev/sdx of=/custom_boot/cb_mbr.img bs=512 count=1Copy the bootable partition
dd if=/dev/sdx2 of=/custom_boot/cb_ext4.img bs=5127: Create new bootable usb deviceDelete all existing partitions and clean MBR
fdisk or gparted (delete partitions)
dd if=dev/zero of=/dev/sdx bs=512 count=1
restore MBR and Partition Table
dd if=/custom_boot/cb_mbr.img of=/dev/sdx bs=512
Restore bootable partition
dd if=/custom_boot/cb_ext4.img of=/dev/sdx2 bs=512
Fix the first partition and reformat (fat32 or ntfs)
fdisk or gpartedMy grub.cfg
My Notes
|
I have a bootable USB stick as shown in the screenshot:
# dd if=/path/to/os_image.iso of=/dev/sdb
(...everything OK...)# sudo dumpe2fs /dev/sdb
dumpe2fs 1.42.9 (4-Feb-2014)
dumpe2fs: Bad magic number in super-block while trying to open /dev/sdb
Couldn't find valid filesystem superblock.GParted doesn't recognize any partitions.The GUI file manager reports the filesystem as isofs. The system boots and everything works fine.
The problem is, I want to use the USB stick for a live OS and as a storage with PCs and TVs which only recognize FAT32 and NTFS.
I have tried creating two partitions, doing dd on sdb1 and making sdb1 the only bootable partition, but the system didn't boot.
How to put both FAT32/NTFS and (any) bootable ISO image on an MBR-partitioned disk without using an external bootable USB creator program? I would like to simply use dd, as I do now.
Presumably this could be solved using the right bootloader with the right configuration. I just don't know which bootloader and what configuration.
|
FAT32 / NTFS + isofs on USB flash drive
|
Since permissions do not matter, copying with cp -R is fine.
The command you're using to compare the two trees compares the file names, ownership and permission. If you don't care about preserving permissions, don't print out the permissions!
vimdiff <(cd /Volumes/fat32/ && find . | sort) <(cd /Users/masi/BitTorrentSync/ && find . | sort)But you should use a file synchronizer: rsync if you always copy in the same direction,
Unison if to synchronize in both directions.
There is no way to preserve permissions on FAT32. If you wanted to copy files and preserve permissions, you'd need to use a different filesystem or put them in an archive (zip, 7z, tar.gz, …).
|
I sudo-copied documents from OSX extended filesystem to FAT32. Now, I see that two trees are different by size and by Stephen's command here
vimdiff <(find /Volumes/fat32/ -printf "%P %u:%g %m\n" | sort) <(find /Users/masi/BitTorrentSync/ -printf "%P %u:%g %m\n" | sort) How can you copy lossless from OSX ext to FAT32 without Ownerships/Permissions?
|
How To Copy Lossless from OSX ext to FAT32 without Ownership/Permissions? [closed]
|
I could be wrong, but it does rather look like you've got a filesystem directly on the disk, without any partition table.
If that is the case you cannot have additional partitions without wiping the disk and starting over, this time with a partition table.
|
I'm trying to create an external hard drive with NTFS part for info and hidden bootable fat32 part.Here is an error
.
|
Gparted: too many primary partitions
|
Frederik's answer involving magic SysRq and kernel dumps will work if the kernel is still running, and not truly hung. The kernel might just be busy-looping for some reason.
The fact that it doesn't respond to Ctrl-Alt-Del tells me that probably isn't the case, and that the machine is locking up hard. That means hardware failure, or something closely related, like a bad driver.
Your memory check test is good, if you let it run long enough. You should also try other things to try and stress the system, like StressLinux. Long-running benchmarks are good, too.
Another thing to try is booting the system with an Ubuntu live CD and trying to use the system as normal. If returning to Ubuntu temporarily like that doesn't cause the problem to recur, there's a good chance it's not actually broken hardware, but one of the related things like a bad driver or incorrectly configured kernel. It is quite possible that a more popular distribution like Ubuntu could have a more stable kernel configuration than one like Arch, simply due to the greater number of machines it's been tried on during the distro's test phase.
|
My Arch machine sometimes hangs, suddenly not responding in any way to the mouse or the keyboard. The cursor is frozen. Ctrl-Alt-Backsp won't stop X11, and ctrl-alt-del does exactly nothing. The cpu, network, and disk activity plots in conky and icewm stop updating. In a few minutes the fan turns on. The only way to make the computer do anything at all is to turn off power.
When it boots up, the CPU temperature monitors show 70 to 80C. Before the hang, I was usually doing low-intensity activity like web surfing getting around 50C.
The logs show nothing special compared to a normal shutdown. Memory checker runs fine with zero defects.
How can I investigate why it hung up? Is there extra information I can find for a clue? Is there anything less drastic than power-off to get some kind of action, if only some limited shell or just beeps, but might give a clue?
The machine is a Gateway P6860 17" laptop (bulky but powerful) and it's running Arch 64bit, up to date (as of March 2011). I had Arch for a long time w/o this problem, switched to Ubuntu for about a week then retreated back to a fresh install of Arch. That's when the hangings started.
UPDATE: Yeah, for sure it's overheating. At one temperature, the mouse and keyboard stop working, sometimes becoming functional after several minutes of cooling off. At a higher temperature, worse things happen, like total nonresponsiveness including ignoring SysRq. This condition is shortly followed by a sudden power-off. I have solved the problem by buying a new computer 8D
|
How to investigate cause of total hang?
|
You could use in-kernel mechanism inotify for monitoring accessed files.
First you should check if inotify is turned on in kernel:
pbm@tauri ~ $ zcat /proc/config.gz | grep CONFIG_INOTIFY
CONFIG_INOTIFY=y
CONFIG_INOTIFY_USER=yNext thing to do is install inotify-tools. Instructions for various distributions you could find at project page - it should be in repositories of all major distributions.
After that inotify is ready to work:
inotifywait /dirs/to/watch -mrq(m = do not exit after one event, r = recursive, q = quiet)
For example - output after ls /home/pbm
pbm@tauri ~ $ inotifywait /bin /home/pbm -mq
/bin/ OPEN ls
/bin/ ACCESS ls
/bin/ ACCESS ls
/home/pbm/ OPEN,ISDIR
/home/pbm/ CLOSE_NOWRITE,CLOSE,ISDIR
/bin/ CLOSE_NOWRITE,CLOSE lsImportant thing is to properly set directories for watch:don't watch / recursively - there is a lot of read/write to /dev and /proc
don't watch your home dir recursively - when you use apps there is a lot of read/write to application configuration dirs and browsers profile dirsIn /proc/sys/fs/inotify/max_user_watches there is configuration option that shows how many files can be watched simultaneously. Default value (for Gentoo) is about not so high, so if you set watcher to /home/ you could exceed limit. You could increase limit by using echo (root access needed).
echo 524288 > /proc/sys/fs/inotify/max_user_watchesBut before that you should read about consequences of that change.
Options that could be interesting for you:-d = daemon mode
-o file = output to file
--format = user-specified format, more info in man inotifywait
-e EVENT = what event should be monitored (for example access, modify, etc, more info in man)
|
So recently I found that someone has been using my computer without consent, browsing folders, etc....
I could change all my passwords straight away, but I'm curious as the what the intruding party was looking for. So I would like to set up a trap ( evil grin ).
What software will monitor any activity on my computer? While I know that capturing my screen will work here. I'd rather use a logfile.
For example:
/var/log/activity.log[1 Aug 2010 20:23] /usr/bin/thunar accessed /multimedia/cctv-records/
[1 Aug 2010 20:25] /usr/bin/mplayer accessed /multimedia/cctv-records/00232.avi
[3 Aug 2010 02:34] /usr/bin/thunderbird was run
[3 Aug 2010 03:33] incomming ssh session from 12.32.132.123Activities I would like to log is:Access to files and folders on the filesystem
Commands run ( from console or otherwise )
User Sessions ( login's, ssh sessions and failed attempts )
|
Monitoring activity on my computer.
|
That is not information that is normally recorded, unless you took special disposition to that effect (like via some audit system).
The service through which the user has renamed the directory (like over FTP, SFTP, WebDAV, samba...) may have logs that can help. You can try and check those logs, the last, lastcomm, audit, authentication logs around the time the folder was renamed.
If you're administrator, you can look at the history file of the shells of the users that had the permissions to rename it (if the directory was renamed from /A/dir to /B/newdir, it's whoever had write access to both /A and /B (assuming /A didn't have the t bit in its permissions and /A/dir and /B are on the same filesystem)).
|
I couldn't find the answer to this anywhere. How can I know who renamed a directory?
ls -al shows only the name of user who created that dirctory.
|
Who renamed a directory?
|
TL;DR: In many cases, you can see whether the file was accessed; however, it is impossible to tell whether a copy was made or not.
It seems that atime would be updated when using cp (unless noatime is in effect); however, doing any other read operation (like grep somestring $filename) would also touch the file.
In most installs (without a ton of auditing), it is not possible to find out why exactly the file was read, and whether the process reading the file also wrote a copy of the data elsewhere (to USB? to socket? to RAM?).
Moreover, this only concerns online, unprivileged attacks. If I have physical access, I could reboot into a live-CD distro, mount the partition read only, copy anything off it (or even make a full-disk image) and there would be no marks on the partition (except the incremented mount counter).
|
Is there a way to make sure that a file has been copied to a USB drive?
(Ex: I have a file secret.db and I suppose that my friend has copied it into his USB drive. With stat $filename I cannot see the updated a/c/m/time because cp doesn't update the timestamps).
Is there a way to know that or is it impossible?
I'm using Ubuntu 12.04 with Bash v4.
|
How might one verify that a file has been copied?
|
By looking at /etc/passwd in the backups taken of your system from the day/week/period before the user deletion.
If userdel was used with -r, then both the home directory and user's mail spool have gone. If it wasn't used with -r, check for the user's mail spool, or perhaps a crontab if you're very lucky.
If there are no backups, and no obvious files owned by that user you can check, then you'll need to scout around places like /tmp and look for files with UID's as owners and try and work it out - but really, your backup is your best bet.
Edit: as jw013 points out you could also use find / -nouser to find files which have no matching user for the file's UID.
|
How can an administrator find the UID of a user that's been deleted with the userdel command?
|
UID of a deleted account
|
Run ulimit -c 1073741824 prior to starting the program. Next time the program crashes, a core dump will be created in the working directory (named core.<PID>). You can then use GDB to open this core at any time you like.
ulimit -c XXXXX sets the maximum size of the core dump file created when a program seg faults. By default this is 0 which means not to dump the core.
|
First, a brief description of the situation: a computer sits hidden near a display in a gallery of some sort, acting as the silent workhorse for a piece. Despite its programmer's best intentions the piece may, well, crash, from time to time depending on the passerby's interactions with the display. The programmer has rigged up the computer to automatically restart the relevant program hackishly using a bash loop, since uptime (or something resembling it) is at a premium.
The developer would love to determine what the cause of any crashes is, but running the program via GDB -- to the best of this developer's knowledge -- would result in the process stopping upon a crash. This would indeed enable the developer to tap in 'backtrace' and find the cause, but the piece would be inoperable until the developer made his or her way to the gallery in question to check on it. This is no good.
How might this intrepid developer secure backtraces of each crash (and presumably store them somewhere) via GDB, but still allow for the original behaviour of automatically restarting the process upon a crash?
|
Capture and log GDB backtraces without stopping the process
|
The image you have is the image of an entire disk including things like partition tables and other things outside of the file system that you would like to mount inside it. You likely have at least one partition inside that raw blob. Mount is telling you it can't figure out what file system it is because it is starting to read the raw blob at the beginning and finding things that are not part of a file system at all.
In order to mount the file system, you need to figure out where the file system is. This answer on Ask Ubuntu has some details about how you can calculate where the partition starts in the image and then use that value to create a loop device that starts at that offset. If you want to simplify even further, once you have found the right offset value you can skip the loop device setup and pass the offset value directly to mount using mount -o offset=<offset in bytes>.
|
While Trying to mount a disk image in Raw(dd) format using the following command
mount nps-2010-emails.dd /media/manu/I get the following error message
mount: you must specify the filesystem typeI know that using -t we can specify the file system but what is the terminology for
a RAW (dd) file, which can pe passed as an argument to the mount command. If my method to mount this file system is wrong please help me out in doing the same.
On typing the command file -s nps-2010-emails.dd
The output is as follows:
nps-2010-emails.dd: x86 boot sector; partition 1: ID=0xb, starthead 254, startsector 1, 20479 sectors, extended partition table (last)\011, code offset 0x0
|
Mounting Disk Image in Raw format [duplicate]
|
GNU ddrescue first quickly copies good blocks using a large block size and then optionally tries to recover more data reading smaller blocks within the blocks that failed in the first pass. This requires a log file that records what areas are still missing and the output must go to a file or disk that allows random access. If run again with the log file present, ddrescue will try again reading the missing parts only.
Kurt Garloff's dd_rescue copies the data in sequential order, allowing it to be captured on stdout, e.g. to compress it before writing it to a file. When a read error is encountered dd_rescue switches temporarily to a smaller block size to try to recover data from the problematic area before continuing with the remainder of the disk.
|
There are two similar tools for a dd on bad hardware:Kurt Garloff's dd_rescue
GNU ddrescueWhat is the difference between dd_rescue and ddrescue, when to prefer which one?
|
What is the difference between dd_rescue and ddrescue, when to prefer which one?
|
That's a long list, surely you don't expect us to review it line by line? It's normal to have many processes running as root: unix systems often have one process to do each job, so many system services get their own process. In fact, some of these (e.g. all the /0 or / (the number identifies a CPU), and most of the ones beginning with k) are kernel threads.
If you're worried about someone gaining control of your machine, ps is not a useful tool. Any halfway decent¹ rootkit contains code to hide any malicious process from process listings. Even if the malicious code was not running as root and so couldn't change the kernel reports, it would disguise itself as something innocuous like sh.
¹ Yes, “decent” may not be the right word here.
|
My significant other and I are sometimes paranoid that a foreign government usually associated with last year's Gmail security breach may be attempting to gain access to our computers.
There were a lot of strange processes running as root tonight, though I have not opened any root terminals. Can someone please look at these and tell me, yes or no, are they suspicious, and why or why not?
PID TTY TIME CMD
1 ? 00:00:01 init
2 ? 00:00:00 kthreadd
3 ? 00:00:01 ksoftirqd/0
6 ? 00:00:00 migration/0
7 ? 00:00:00 watchdog/0
13 ? 00:00:00 cpuset
14 ? 00:00:00 khelper
15 ? 00:00:00 netns
16 ? 00:00:00 sync_supers
17 ? 00:00:00 bdi-default
18 ? 00:00:00 kintegrityd
19 ? 00:00:00 kblockd
20 ? 00:00:00 kacpid
21 ? 00:00:00 kacpi_notify
22 ? 00:00:00 kacpi_hotplug
23 ? 00:00:00 kseriod
25 ? 00:00:00 kondemand
26 ? 00:00:00 khungtaskd
27 ? 00:00:03 kswapd0
28 ? 00:00:00 ksmd
29 ? 00:00:00 fsnotify_mark
30 ? 00:00:00 aio
31 ? 00:00:00 crypto
163 ? 00:00:00 khubd
164 ? 00:00:00 ata_sff
165 ? 00:00:00 scsi_eh_0
166 ? 00:00:00 scsi_eh_1
199 ? 00:00:00 usbhid_resumer
222 ? 00:00:00 kjournald
271 ? 00:00:00 udevd
442 ? 00:00:00 kpsmoused
446 ? 00:00:36 net.agent
450 ? 00:00:00 cfg80211
471 ? 00:00:00 hd-audio0
532 ? 00:00:36 net.agent
751 ? 00:00:02 kjournald
755 ? 00:00:00 kjournald
756 ? 00:00:00 kjournald
757 ? 00:00:01 kjournald
801 ? 00:00:00 flush-8:0
1035 ? 00:00:00 rsyslogd
1089 ? 00:00:00 modem-manager
1094 ? 00:00:01 polkitd
1114 ? 00:00:02 wpa_supplicant
1126 ? 00:00:00 gdm3
1137 ? 00:00:00 gdm-simple-slav
1141 tty7 00:20:11 Xorg
1146 ? 00:00:07 acpid
1169 ? 00:00:00 atd
1195 ? 00:00:00 bluetoothd
1209 ? 00:00:00 l2cap
1212 ? 00:00:00 krfcommd
1273 ? 00:00:00 cron
1303 ? 00:00:00 cupsd
1597 ? 00:00:07 kerneloops
1627 ? 00:00:00 kconservative
1631 ? 00:00:00 console-kit-dae
1771 ? 00:00:00 sshd
1800 tty1 00:00:00 getty
1801 tty2 00:00:00 getty
1802 tty3 00:00:00 getty
1803 tty4 00:00:00 getty
1804 tty5 00:00:00 getty
1805 tty6 00:00:00 getty
1852 ? 00:00:00 gdm-session-wor
1857 ? 00:00:15 upowerd
2017 ? 00:00:00 kauditd
2172 ? 00:00:02 udisks-daemon
2176 ? 00:00:00 udisks-daemon
3038 ? 00:00:00 udevd
3039 ? 00:00:00 udevd
3251 ? 00:00:00 NetworkManager
3440 ? 00:00:00 dhclient
5322 ? 00:00:00 kworker/u:2
6717 ? 00:00:00 sleep
6720 ? 00:00:00 sleep
13386 ? 00:00:00 kworker/1:2
21237 ? 00:00:02 kworker/0:2
24297 ? 00:00:11 kworker/1:1
27326 ? 00:00:02 kworker/0:1
29045 ? 00:00:01 kworker/u:0
30132 ? 00:00:00 migration/1
30134 ? 00:00:00 ksoftirqd/1
30135 ? 00:00:00 watchdog/1
30238 ? 00:00:48 irq/19-0000:01:
31245 ? 00:00:00 kworker/u:1
|
Is there any chance that some of these processes are malicious?
|
Initial Disk Quality
Since we're not talking about a hard drive here, which can be recovered, you're sadly experiencing the reality that most consumer grade DVDs are NOT reliable.
A physical hard disk has magnetic charged particles in a solid surface, and recovery in worst case scenarios happens by taking the disk apart physically, and then using a special read head to go sector by sector and reading the magnetic data. A dye based writable dvd has no such option, the dye is the data, and if it's degraded, there is nothing to recover.
The only likely prospect given your scenario is that the dye used to create DVD-R disk data simply is failing. Unlike commercial music CDs, which usually use a sort of laser enscribed aluminum sheet for the actual data, burnable dvds use a layer of dye, which, and this is particularly relevant with lower end stuff, tends to fade away and fail over years.
Note that 'cheaper' does not necessarily refer to price or brand, it refers to the factory that actually made the disks. Some major brands that people would have believed were high quality were not in fact high quality.
This is also, by the way, why you always have to buy name DVDs, like Taiyo Yuden (back when I did a lot of burning, that's the only brand I would use), or quality 'archival' dvds [which cost a LOT more than regular ones]. Cheaper dvds/cds use cheaper dyes, which can and do simply fail over time. The only brand I ever trusted was taiyo yuden, because it never outsourced its disk production and was known to be be high quality, and was made in Japan [this could have changed since I did a lot of work with CDs/DVDs]. If the disk was made by a no name or whitebox brand, then it's junk, for sure. I've seen dyes on CDs fade after just a few years when they were cheap no name brands.
You may have heard the term 'archival DVDs', this is what it refers to, the expected life of a properly stored optical storage medium.
Since you did not mention the brand of the disk, that suggests to me that you were not aware of these realities, since the key to all optical disk storage is the quality of the disk and its dyes, and that's a function of what brand and model version it is.
It's also worth mentioning that rewritable CD/DVDs are far far worse, and should in no case be relied on for really anything at all, at least that's been my experience, over years, I think the data loss become so high that I no longer even consider optical rewritable anything to be a storage medium at all.
How to Kill your DVD/CD
Things that can damage these dyes: heat, probably number one, like, putting disk on or near radiators, electronic components that generate heat, direct sunlight, etc.
Once you have damaged the dye there is no longer any data there to restore, and if you damaged the actual data table on the dvd itself that says where the data is, then there is nothing to restore either.
Other good ways to lose your data is to buy cheap or no name disks, that means you will wake up one day and find your data gone, without having to do a thing!! Just from the dye failing on its own, though I'm sure environmental causes can contribute, like the place it's stored getting a bit warmer for a few days in a row, or whatever.
Last Chances
Before you give up, you might want to try the following:Take a clean soft cloth, dampen it slightly, and carefully wash the surface of the disk. In particular pay close attention to the inner, not outer part. The disks burn from the inside out, so if there is dirt or scratches there, it can make the reads fail.
Try it in a very high quality DVD reader, like a plextor, something with a very good laser. Lasers can and do wear out, and, coupled with dye fade and failure, that can make disks fail to read. Do not assume a DVD reader laser is in good condition, they die over the life the reader, so the newer it is, the better. As with dyes, there is a significant difference between the quality of the lasers used by CD/DVD readers/writers. The laser is what heated the dye when it was burned, and it's what tries to read it when it reads. The better the laser, the more likely it can pick up faint traces of fading dyes.
take a magnifier and closely examine the disk under strong light close to the inside rings, to see if you can see anything unusual there, like cloudy surface, or something like that. This is what it has to read to discover that there is a disk with data present.
laptop dvd drives are junk, cheap, low end, flimsy, lightweight, I wouldn't even consider them to be a valid test, make sure to use a real PC dvd reader, that is not too used or old, or cheap.
The device you listed: http://www.driverscape.com/download/tsstcorp-cddvdw-sh-s223c-ata-device appears to be over 10 years old, is that correct? If so, that's clearly not going to be a good tool to test this with.Back in the old days, you could actually rely on the fact that certain brands and models had superior lasers, but in my opinion, those days are sadly gone. But if you research it, you may find that there are still certain specific models that are known to have a superior laser, obviously, I would expect those to be higher end and expensive.
Note that the age of the reader is also important, because these lasers basically begin to die as soon as they are used, so the newer the high end reader is, the higher your chances at recovery.
However, with that said, the marked decline in reading over a short time suggests to me that something started breaking down the DVD dyes, until it failed, possibly an inadvertent leaving it in direct sun or on a hot surface, without you having realized it, or simply the dye itself breaking down because it was either cheap or defective in the first place.
Likewise the drives not finding any data suggests the file system data table in the start of the dvd is either gone or corrupted beyond repair or read.
[Update: user data added to post]
As I suspected, you used no name dvd blanks, which are basically guaranteed to be non trustworthy, and your dvd readers are old. Old burners by the way can also have weaker lasers, which makes the dye imprint weaker, so it looks like you're suffering from all the worst case scenarios.
Where to get good disks?
I haven't bought these in a while, but to make this complete, I searched, and was very happy to find that supermediastore.com still exists, and still sells Taiyo Yuden. https://www.supermediastore.com/products/jvc-taiyo-yuden-dvd-r-8x-silver-thermal-dvd-recordable-single-layer-media-jdmr-zz-sb8-100pk
This was the best place to buy 10-15 years ago, and it appears to still be around, which is great, I always trusted that store and their products, which is an unusual thing to be able to say nowadays.
Note that other good archival options are things like Verbatim DataLifePlus, but in general, I only stick with brands where I know that the brand is actually made by the company whose brand the disks carry.
But the key thing to remember is: if the data on the disk is important, PAY FOR QUALITY DISKS!!
|
I have a very strange case of DVD reading failure.
It's a video DVD recorded a couple of years ago on a DVD-R disc.
Two weeks ago our video DVD player would start having trouble reading parts of it. The problem was reproducible on two PCs, where only part of the videos could be played. Plus, current playing time and total duration of VOB files would me messed up, indicating that the files were corrupted somehow, likely due to disc aging.
Three days later, I wanted to play the same videos again (same setup, same laptop DVD reader) but I couldn't even view the DVD's file structure. To avoid further losses, I launched
$ ddrescue -n -b 2048 /dev/sr0 ~/dvd_dump
After six hours and since I needed to shutdown my laptop, I interrupted the process and decided I would restart it later.
However, two days later, the DVD reader would not even recognize the presence of a disc, throwing a no medium found error whenever I tried. Also the disc would not start spinning upon closing the tray.
This situation was reproducible on three different DVD readers.
Some details:
$ dmesg | grep sr
[ 3.078673] sr 3:0:0:0: [sr0] scsi3-mmc drive: 52x/52x writer dvd-ram cd/rw xa/form2 cdda tray
[ 3.078891] sr 3:0:0:0: Attached scsi CD-ROM sr0
[ 3.078960] sr 3:0:0:0: Attached scsi generic sg4 type 5$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931,5G 0 disk
├─sda1 8:1 0 100M 0 part
├─sda2 8:2 0 597,5G 0 part /mnt/win
├─sda3 8:3 0 1K 0 part
├─sda4 8:4 0 1G 0 part
├─sda5 8:5 0 323,2G 0 part /
└─sda6 8:6 0 9,8G 0 part [SWAP]
sde 8:64 0 1,8T 0 disk
├─sde1 8:65 0 1K 0 part
├─sde5 8:69 0 398,7G 0 part
├─sde6 8:70 0 951,8G 0 part
└─sde7 8:71 0 512,5G 0 part
sr0 11:0 1 1024M 0 rom $ cd-info --dvd
cd-info version 0.83 x86_64-pc-linux-gnu
Copyright (c) 2003, 2004, 2005, 2007, 2008, 2011 R. Bernstein
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
CD location : /dev/cdrom
CD driver name: GNU/Linux
access mode: IOCTLVendor : TSSTcorp
Model : CDDVDW SH-S223C
Revision : ME00
Hardware : CD-ROM or DVD
Can eject : Yes
Can close tray : Yes
Can disable manual eject : Yes
Can select juke-box disc : NoCan set drive speed : No
Can read multiple sessions (e.g. PhotoCD) : Yes
Can hard reset device : YesReading....
Can read Mode 2 Form 1 : Yes
Can read Mode 2 Form 2 : Yes
Can read (S)VCD (i.e. Mode 2 Form 1/2) : Yes
Can read C2 Errors : Yes
Can read IRSC : Yes
Can read Media Channel Number (or UPC) : Yes
Can play audio : Yes
Can read CD-DA : Yes
Can read CD-R : Yes
Can read CD-RW : Yes
Can read DVD-ROM : YesWriting....
Can write CD-RW : Yes
Can write DVD-R : Yes
Can write DVD-RAM : Yes
Can write DVD-RW : No
Can write DVD+RW : No
__________________________________Disc mode is listed as: Error in getting information
++ WARN: error in ioctl CDROMREADTOCHDR: No medium foundcd-info: Can't get first track number. I give up.$ sudo mount -t iso9660 /dev/sr0 /mnt/dvd
mount: block device /dev/sr0 is write-protected, mounting read-only
mount: no medium found on /dev/sr0I am very surprised to see a DVD going from large parts still readable to totally undetectable within a week. I treated the DVD with maximal care, did not carry it around anywhere, and no physical damage (scratches or the like) were visible before, nor are there any now.
My questions:Is there a way to force-read the disc with a low-level command that would ignore the no medium found error, or cd-info's Can't get first track number error (see above)?
Is it plausible that a faulty DVD reader would overwrite the DVD-R with zeros when it was only supposed to read-access it via the ddrescue command quoted above?
What options do I have left? Is there any chance that professional data rescuing services will be capable of salvaging my disc?
Are there high-end DVD readers on the market with superior error-correcting capabilities that might extract something from that disc?(Before someone asks: Yes, I am sure it was one and the same disc!)
Edit:
The disc is a TDK DVD-R Data/Video 4.7 GB 1-8x.
DVD readers (from cd-info output):TSSTcorp CDDVDW SH-S223C Revision ME00 (3.5-inch drive on desktop PC at workplace, age unknown)
MATSHITA DVD-RAM UJ-844 Revision RC06 (on Lenovo Thinkpad X301, ~8 years old)
unknown (I will edit this once I get the info)
|
Recovery of damaged DVD yielding "no medium found" error
|
I recommend the dstat tool. It has a lot of plugins (listed via "dstat --list") that could help you narrow down where the issue is occurring.
One place to start could be with most expensive IO:
# dstat -s --top-io-adv --top-bio-adv
----swap--- -------most-expensive-i/o-process------- ----most-expensive-block-i/o-process----
used free|process pid read write cpu|process pid read write cpu
0 4000M|chrome 3388 152k 97k0.6%|chrome 3388 155k 95k0.6%
0 4000M|gnome-terminal-server 4635 586B 24k0.1%|chrome 3388 0 12k0.1%From: http://articles.slicehost.com/2010/11/12/using-dstat-to-check-i-o-and-swap
|
Answer
I fixed my "freezes" by turning autoneg of (ethtool -s eth0 duplex full autoneg off).
How I found this
Every time after a freeze, monitoring disk I/O with the help of the post below, I saw that rsynclogd was writing to disk after freezes. I then checked /var/log for the last changes and saw that kern.log had link up / link down messages after freezes. So I figured it might be the network card which is turning off & on, which looks like freezes if you're SSH'd in or trying to access your web server.
Original problem
I've got a bananapi with Xubuntu on it:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.3 LTS"
NAME="Ubuntu"
VERSION="14.04.3 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.3 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
No LSB modules are available.
Linux version 3.4.103 (bananapi@lemaker) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #4 SMP PREEMPT Thu Dec 18 12:55:58 CST 2014
armv7lEvery few minutes the entire machine just hangs for a few seconds. I tried running top but it doesn’t show anything abnormal cpu% wise.
I notice it's hanging because I'm ssh'd in and when I try and type sometimes it'll take anywhere from 5-30 seconds until the text appears and I can do anything on the machine.
How can I find out which process is doing this? I said it happens every few minutes, but as far as I can tell it's quite random. Sometimes I won't notice it for a while, but then again, I'm not typing on it continuously.
I tried running top as I said; it seems to be updating the list every few seconds when I'm staring at it, then it'll pause for longer and it'll "catch up" and refresh 20x in 1 second then continue as normal.
I'm also running the Apache webserver on it; sometimes the pages take ages to load -- then I know it's hanging again. It'll take anywhere from 5-30 seconds or so and it'll work fine again for a while.
[edit]
I ran posted commands in the answers below.
I kept only seeing apache2 with 4096B write, 3.5% CPU but no hangs. Then it hung suddenly for about 10 seconds and the only thing that was off was rsyslogd: 0 0 |iotop 4507 40k 511B5.0%|jbd2/sda1-8 55 0 32k 0%
0 0 |iotop 4507 36k 570B 11%||
0 0 |iotop 4507 40k 719B 11%||11%|
0 0 |iotop 4507 39k 582B 11%||rsyslogd 285 0 8192B0.5%
0 0 |iotop 4507 31k 0 12%|11%|
0 0 |iotop 4507 8653B 600B1.0%|11%|
0 0 |iotop 4507 36k 479B 11%||11%|
0 0 |iotop 4507 42k 534B 11%||11%|
0 0 |iotop 4507 37k 404B 11%||jbd2/sda1-8 55 0 8192B 0%
0 0 |iotop 4507 40k 745B 11%||11%|
0 0 |sshd: bananapi@pts/4 4549 206B 280B 0%|11%|
0 0 |iotop 4507 37k 639B7.5%|11%|
0 0 |iotop 4507 40k 533B 11%||11%|
0 0 |iotop 4507 37k 385B 11%||11%|
0 0 |iotop 4507 41k 511B 11%||11%|
0 0 |iotop 4507 7520B 0 10%|11%|
0 0 |iotop 4507 29k 555B2.5%|11%|
0 0 |iotop 4507 40k 704B 11%||rsyslogd 285 0 8192B 0%... however not much CPU usage or disk IO from this process.
update:
again the only thing that's different after it freezes is it shows rsynclogd in the I/O log.
Could this really be the source? it only writes 8192 Bytes, 0% CPU usage
[edit3]
did a grep rsyslogd * in /var/log and got the following:syslog:Oct 18 04:28:10 lemaker rsyslogd: [origin software="rsyslogd" swVersion="7.4.4" x-pid="285" x-info="http://www.rsyslog.com"] rsyslogd was HUPed
syslog.1:Oct 18 04:00:01 lemaker rsyslogd: [origin software="rsyslogd" swVersion="7.4.4" x-pid="267" x-info="http://www.rsyslog.com"] exiting on signal 15.
syslog.1:Oct 18 04:00:43 lemaker rsyslogd: [origin software="rsyslogd" swVersion="7.4.4" x-pid="285" x-info="http://www.rsyslog.com"] start
syslog.1:Oct 18 04:00:43 lemaker rsyslogd: rsyslogd's groupid changed to 104
syslog.1:Oct 18 04:00:43 lemaker rsyslogd: rsyslogd's userid changed to 101
syslog.1:Oct 18 04:00:43 lemaker rsyslogd-2039: Could no open output pipe '/dev/xconsole': No such file or directory [try http://www.rsyslog.com/e/2039 ]not sure what to make of it except it's not performing as it should
[edit5]
Or could it be that it hangs and rsyslogd is just logging something about the fact that something went wrong somewhere. As in.. correlation does not equal causation? The last updated logs in /var/log:
syslog, auth.log, kern.log all by user "syslog" which is I think from rsyslogd
tail kern.log:Oct 18 20:43:59 lemaker kernel: [60223.243773] PHY: sunxi_gmac-0:00 - Link is Down
Oct 18 20:44:12 lemaker kernel: [60236.244107] PHY: sunxi_gmac-0:00 - Link is Up - 100/Full
Oct 18 20:44:22 lemaker kernel: [60246.244654] PHY: sunxi_gmac-0:00 - Link is Down
Oct 18 20:44:36 lemaker kernel: [60260.245033] PHY: sunxi_gmac-0:00 - Link is Up - 100/Full
Oct 18 20:45:12 lemaker kernel: [60296.246573] PHY: sunxi_gmac-0:00 - Link is Down
Oct 18 20:45:25 lemaker kernel: [60309.246906] PHY: sunxi_gmac-0:00 - Link is Up - 100/Full
Oct 18 20:45:57 lemaker kernel: [60341.248303] PHY: sunxi_gmac-0:00 - Link is Down
Oct 18 20:46:10 lemaker kernel: [60354.248630] PHY: sunxi_gmac-0:00 - Link is Up - 100/Full
Oct 18 20:46:16 lemaker kernel: [60360.249037] PHY: sunxi_gmac-0:00 - Link is Down
Oct 18 20:46:30 lemaker kernel: [60374.249405] PHY: sunxi_gmac-0:00 - Link is Up - 100/Full
I reainstalled rsynclog, even disabled it. It still freezes like before. I think rsysnclog is just logging something when it freezes, but it's not the problem. As in correlation does not equal causation .
I think the problem might just be the link is up/link is down, since i notice the "Freezes" while logged in trough SSH or connecting my web server. This might make it seem like it's frozen, while it's just the network link.
|
How can I see which process hangs my Banana-pi for few seconds every couple of minutes?
|
While running a command like
# dd if=/dev/sda of=/path/to/external/medium/file.imgon a live system will work, it's going to result in a number of problems which you won't have if you boot into a separate OS and make the image(s) from there:If you image an entire disk, it probably contains a boot loader and a partition table. Those are going to get in your way when you go to try and do forensics/recovery on the image.
What you really want is to image each filesystem independently:
# dd if=/dev/sda1 of=/path/to/external/medium/filesystem1.img
# dd if=/dev/sda2 of=/path/to/external/medium/filesystem2.img
...etc...Doing it this way makes mounting the filesystems trivial:
# mount -oloop,ro filesystem1.img /mnt/fs1(I show the mount done as root because on some Linuxes, loop devices are locked down, so regular users can't use them.)
You're snapshotting live, mounted filesystems, so when you mount them later, it's effectively no different than if you had power-cycled the machine. The partitions will be "dirty," which can make mounting them without forensically damaging them difficult.
You're using the suspect machine's copy of dd(1). If someone were trying to hide something from you, they could provide a sneaky or malicious copy of dd(1).Now, all that having been said, there are some good reasons to do an on-line clone. The best reason is that the system is using some form of filesystem or whole-disk encryption, and rebooting it will erase the decryption keys for the mounted volumes.
dd is not the right tool for this job, however, since that will just get you a copy of the encrypted-at-rest data. A regular backup is a better idea. E.g.,
# tar -cvJf --exclude={'/proc/*','/sys/*','/tmp/*'} \
/path/to/external/medium/everything.tar.xz /That won't discover hidden partitions and such, but at least it will force the OS to decrypt every file accessible directly from the root of the filesystem.
|
Pertaining to computer forensics, if the suspect's computer (which cannot be removed from the scene), is Linux, can you directly use tools such as dd or dcfldd on his computer to acquire the disk image? Or do you need to use forensic live cds like Helix, Penguin sleuth or FFCU on top of the existing OS?
|
How to acquire image of disk on Linux computer?
|
Generally speaking, there is not much that you can investigate if the process haven't logged anything implicitly or some kind of system wide logging solution was not deployed (most probably auditd).
Assuming you don't know what that process was trying to accomplish what you can do is: Run last and last -f /var/log/btmp | less or faillog to look for suspicious successful or failed login attempts.
Check /var/log/secure for any authentication related clues
Check /var/cron/tab and /etc/crontab to find any newly added jobs if any (also checking /var/log/cron would help to identify some suspicious jobs that were run which means that the cron configuration was modified to look in other folders for extra jobs)
Run lsmod for any suspicious kernel modules that are currently loaded (also dkms status for dynamically loaded ones) You also can check all the log files either by hand or grepping for a process name (if you know it). And yes, check /var/log/audit just in case auditd is set up and running. If so, you would probably find out some more information.
Anyway, it's more about searching for a needle in a haystack. You should make a lot of educated (or not so educated) guesses about what that process was doing to find anything.
|
There is a process that I know was listening on a certain port that is no longer running.
I would like to know when it stopped running, if it crashed, or any other info about that process.
Is there a way to do this?
|
How to get info on a dead process that was listening on a particular port?
|
I'm afraid there's no chance without a header backup.
The passphrase is only useful when a LUKS header is available that has that passphrase in a keyslot. Without that, there's pretty much no way to recover the volume key.
Part of the LUKS design is that if the LUKS header is erased (and any backups) then it's forensically infeasible to access the container.
|
Is there a way to recover an overwritten LUKS partition? Consider the following case:
I had a (external) hard drive (not SSD) which is completely LUKS encrypted containing an ext4 file system with some (important) data (in my case images and videos). The passphrase is known. I don't have a LUKS header backup.
Now I accidentally created a new LUKS partition on that drive (which overwrote the old one) and a new ext4 file system inside. Then I copied some new data (in my case the some backup data from my laptop; 160 GB (the external drive has a size of 1TB) to it.
Is there any way to recover the old LUKS partition with all the data or at least the images and videos (maybe without filenames).
Edit: Additional questionsIs there any way to revert bitwise the last operations (i.e. data transfer to the new partition, creation of the ext4 file-system, and creation of the LUKS volume)?
Maybe this reversion is possible on a physical level if one analyzes the magnetic structure of the disk surface? Can a forensic professional do this?
Are there any other promising approaches a forensic professional would try in this case?
As already said I didn't backup the LUKS header of the old volume. However as indicated by frostschutz, if I had opened the old volume before the accident and didn't reboot, the header might be found in the memory (but I did reboot in my case). Are there other places where I can search for the header? I usually mounted the old volume using the pmount tool.
|
Recover overwritten LUKS partition
|
You can delete the file from the Attic directory after removing it with cvs rm.
In your project directory, delete the file and commit the change:
cvs rm -f thefile
cvs commit -m 'deleted thefile' thefileThis moves the file thefile,v to the Attic directory in your CVSROOT/projectdir directory where you can delete it.
Assuming you have set the CVSROOT environment variable, you can now do a
rm "$CVSROOT/projectdir/Attic/thefile,v"and the file is gone with its history.
$ cvs stat thefile
cvs status: nothing known about `thefile'
===================================================================
File: no file thefile Status: Unknown Working revision: No entry for thefile
Repository revision: No revision control file
|
Cleaning up after a former employee, I've found that they accidentally included 800MB of data files in a commit to CVS years ago. Several other commits to the same project were made afterwards.
This data is extremely security sensitive and legally restricted and it needs to be removed completely (nothing hanging about in the Attic or filesystem anywhere).
How do I get rid of the files without corrupting CVS?
(It's a linux host, and I have root access and am CLI fluent, but not a CVS expert!)
|
how to remove dangerous stuff from old CVS commits?
|
Sparklines may help... first get the spark util and install the most text viewer. This hack displays an abstract view of the first 61 sectors of
/dev/sda:
for f in `seq 0 1 60` ; do :
printf "%.03i %s\n" $f \
$({ printf '4294967295\n'
sudo dd if=/dev/sda skip=$f bs=512 count=1 2> /dev/null |
od -v -A n -t uI ; } |
spark | sed 's/^.//' )
done | mostOutput on my system (abbreviated first two lines):
000 ▁▁▁▃▆▆▁▁▄▇▂▆▁▁▆▁▁▁▄▄▄▁ ...
001 ▁▆▃▇▂▁▁▁▄▃▆▂▄▂▁▁▁▁▁▁▁▂ ...Each row represents a disk sector. Short lines are small numbers,
tall lines are large numbers. Each sparkline char here represents
an unsigned integer, (4 bytes), which is relatively compact. If it
doesn't all fit on the screen in most, use the right and left
arrows to scroll sideways.
To see what empty data looks like replace the /dev/sda with
/dev/zero.
The above code can be used to skim a disk, just by changing the
seq values. Use sudo hdparm -i /dev/sda | grep CurCHS to get
the cylinder (tracks), heads, and sector numbers, which on my system
returns:
CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=312581808This means every 16383rd sector is the first sector of a (virtual)
track. For a mostly blank disk skimming these would show where the
data runs out.
Changing the seq above to seq 0 16383 $((16383*60)) would show
the first sectors of the first 61 tracks on the disk.
To make the sparkline show just 1 byte per char, change 4294967295
to 255, and uI to uC.Notes on how the code works:
dd sends one 512 byte sector of data to od which outputs
unsigned integers, which is the largest number that spark
understands.
spark uses relative heights calculated from the input, (try spark
<<< '1 2 3 4' to see how it works), which means unless there's a
leading maximum number, the different lines could be to different
scales. To avoid misleading different scales, printf is used to
prepend the correct maximum which makes spark use one consistent
scale, but leaves behind an unwanted first tall char, which is later
removed with sed.A similar technique can show a fuzzy overview of the data density of
a disk or partition. Instead of abstracting a
few bytes into a spark character, abstract a sampling of blocks,
or rather the relative compression ratios of a sampling of blocks.
Two more utils are required: pigz, (for mostly
headerless zlib compression), and pv. pv is really
optional, but a progress bar makes the wait less tedious.
The code:
d=sda b=512 c=1 m=$(( (512*$(</sys/block/${d/s???*/${d%%[0-9]*}/$d}/size))/b )) \
s=200 i=$((m/s)) ; \
for ((f=0;f<m;f+=i)) ; do
sudo dd if=/dev/${d} skip=$f bs=$b count=$c 2> /dev/null |
pigz -9z |
wc -c
done | pv -l -s $s -i "0.1" \
-F 'Read %b of '"$((s+1)) $((b*c))-byte"' blocks %p%e' |
sparkOutput (on my HD):
Read 201 of 201 512-byte blocks [=====================================>] 100%
▇███▁█▂██▃█▆▂▂██▃▆███▆█▅▁█████▇▂▇▂▁▇▂▂▂▆▄█▃▅█▁▄█▃▅▅▅▃▃▂▅
▃▂█▆▅▇▁▅▃▆▄▁█▃▇▁▁▂▂▅█████▇█████████▆█████████▅█▁████████
███████████████████████▆███████▆██▃███████▁████████▂███▂
▁▁▁▁▂▂▂▂██████████▁█▁▁▅▃▁▃█▂▅▄▅▁▁The hard drive $d is divided into 200 ($s) parts, and the first
block of each part is compressed with pigz, piped to wc for a byte
count, and the resulting list of numbers is fed to spark.
The 200 spark characters represent the data densities of 200
512 byte sample blocks. The filled-in chars are blocks with dense data which won't compress, the shorter chars are sparse data
which is quite compressible.
Set s=2000 for a more meaningful view. The variables are all at
the beginning, and can be tweaked as desired. Increase $b (but of the form 512*2^n only) or $c to read larger samples. It's interesting that increasing the sample sizes (reading an 8K block instead of 512 byte one) generally draws a very similar sparkline, which implies a 512 byte block is good enough...
|
Is there a command that allows me to "see" the raw bits of a disk? In other words, to ignore the filesystem and output the "big picture" of the literal zeros and ones as per the disk. (Ideally not requiring a TB-size temporary storage.)
What I'm actually looking for is a way to easily tell if sections of the disk contains long-repeating simple sequences, like all 0s, all 1s, all 01s, all 0101011s, etc, etc.
What's the best way to go about doing this?
|
Visualizing raw bits of disk
|
basically lets say you are a forensic investigator and you are given a linux
system like Ubuntu, and are asked to find suspicious startup executables, how
will you do it and what tools will you use to fasten the process?You can inspect every program executed on a machine using
forkstat. The output will contain
a ton of noise due to the sheer amount of processes spawning at any given time,
but the list you obtain through this should be exhaustive. [0]
Let’s assume the kernel on the system you’re analyzing has the
NETLINK_CONNECTOR
functionality enabled and your forkstat binary is not compromised, e. g. you
compiled and deployed it yourself.
You have to decide how early you want it to start listening for events.
Create a unit file and hook into the system startup
at an appropriate moment, e. g. basic.target:
# cat /etc/systemd/system/forkstat.service
[Unit]
Description=process sniffer[Service]
ExecStart=/sbin/forkstat[Install]
WantedBy=basic.targetVerify that it works by starting the service and observing the result with
journalctl -f. The forkstat output will then be captured in the system
journal. Note that this is a really early on during startup, before the root
filesystem is even available, so for this to work the forkstat binary must be
available in the initrd. How you add it to the initrd depends on the distro.
For Arch it’s as simple as adding it to the BINARIES=… line in
mkinitcpio.conf.
Enable the service, rebuild the initrd, reboot. After the new boot you can
use journalctl -b to review the captured events:
Dec 04 10:12:17 zombo.com systemd[1]: Started process sniffer.
Dec 04 10:12:17 zombo.com forkstat[318]: Time Event PID Info Duration Process
Dec 04 10:12:17 zombo.com forkstat[318]: 10:12:17 exec 321 [/sbin/modprobe -q -- iptable_nat]
Dec 04 10:12:17 zombo.com forkstat[318]: 10:12:17 fork 1 parent /sbin/init
Dec 04 10:12:17 zombo.com forkstat[318]: 10:12:17 fork 322 child /sbin/init
Dec 04 10:12:17 zombo.com forkstat[318]: 10:12:17 exit 313 0 0.610s /usr/sbin/rpc.idmapd
Dec 04 10:12:17 zombo.com forkstat[318]: 10:12:17 fork 2 parent [kthreadd]
Dec 04 10:12:17 zombo.com forkstat[318]: 10:12:17 fork 323 child [kthreadd]
Dec 04 10:12:17 zombo.com forkstat[318]: 10:12:17 fork 265 parent /usr/lib/systemd/systemd-udevd
Dec 04 10:12:17 zombo.com forkstat[318]: 10:12:17 fork 324 child /usr/lib/systemd/systemd-udevdYou will be interested mostly in the parent and child lines which
indicate what process executed which binary. I’ll refer you to the forkstat
manpage
for the details.
Caution: Since this is an exhaustive overview of process spawning activity, the
journal can get quite big. Make sure you set the journal limits to
appropriately large values to accommodate the tremendous amount of log
messages generated.
Also note that the veracity of this output depends on a trustworthy
kernel. If you suspect the kernel itself has been compromised, rootkit
style, you may want to deploy a known trustworthy kernel first.
[0] On a really busy system some events might get dropped which is an artifact
of the underlying netlink API that forkstat uses.
|
In Windows, Autoruns tool is a really helpful tool for forensic investigators to help them find suspicious startup executables and filter the benign ones.
but i couldn't anything good like this in linux, so what is the easiest way to achieve what autoruns does in finding suspicious startup apps? any tool like that in linux?
basically lets say you are a forensic investigator and you are given a linux system like Ubuntu, and are asked to find suspicious startup executables, how will you do it and what tools will you use to fasten the process?
|
What is the equivalent of autoruns tool in linux for finding suspicious startup executables?
|
I think you may run into some memory area used by PCI/ACPI or some such hardware. There might be a memory mapped device that doesn't like being accessed. I can't tell what address exactly causes the problem, but it's usual for some special areas to be located just under the 4 GB limit.
On one machine with 4 GB memory, the kernel prints the following on boot:
BIOS-e820: 0000000000000000 - 000000000009e400 (usable)
BIOS-e820: 000000000009e400 - 00000000000a0000 (reserved)
BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 - 00000000cf690000 (usable)
BIOS-e820: 00000000cf690000 - 00000000cf6e0000 (reserved)
BIOS-e820: 00000000cf6e0000 - 00000000cf6e3000 (ACPI NVS)
BIOS-e820: 00000000cf6e3000 - 00000000cf6f0000 (ACPI data)
BIOS-e820: 00000000cf6f0000 - 00000000cf700000 (reserved)
BIOS-e820: 00000000e0000000 - 00000000f0000000 (reserved)
BIOS-e820: 00000000fec00000 - 0000000100000000 (reserved)
BIOS-e820: 0000000100000000 - 0000000130000000 (usable)Part of the usable memory is above the 4 GB limit at 0x100000000 and there seems to be holes between 0xcf700000 and 0xfec00000.
The areas corresponding to "usable" memory are also shown in /proc/iomem, marked as "System RAM". (the file also contains information about the other memory areas.) You might be safer just reading from those areas.
$ grep "System RAM" /proc/iomem
00001000-0009e3ff : System RAM
00100000-cf68ffff : System RAM
100000000-12fffffff : System RAM
|
I am using the latest Ubuntu Linux with a custom kernel (4.2.0-36-generic), in which I have disabled the CONFIG_STRICT_DEVNEM, because I need to dump and search some terms in memory during a project.
However, when using:dd if=/dev/mem to print it on screen,
dd if=/dev/mem of=/home/user/Documents/file.dump to save it as a file, or
dd if=/dev/mem | hexdump -C | grep 'term' to directly find what I'm looking for,the system freezes and reboots while in the process.
I have checked with df -h and my disc has plenty of free space. Also, the process always stops after writing a 2.1Gb to 2.5Gb, out of a 8Gb RAM and before reaching addresses that start with 4 (if these make any difference). In addition, checking /var/log/syslog and /var/log/kern.log shows nothing relevant before the freezing.
Also, using parameters bs=1G count=2 successfully copies the first 2GB of the memory but then trying bs=1G count=2 skip=2 to get then next 2GB again freezes the system.
Would you suggest any solution so it is possible to dump the full memory or some other way to directly search terms in memory?
|
Accessing /dev/mem freezes Ubuntu
|
No general-purpose filesystem uses beginning-of-file or end-of-file sequences. They would be extremely impractical: what if a file contains these character sequences?
Most basic filesystems divide the storage into fixed-size blocks, and maintain a list of blocks for each file. The file size is kept separately, and how much of the last, partial block is used by the file is determined from that. Sophisticated filesystems refine this basic idea.
With HFS, the list of blocks that make up a file's content is stored as extents in the file record and in the extent overflow file. The size of allocation blocks (the basic unbroken unit of file content) is stored in the filesystem header.
|
I'm trying to recover some lost files by grep-scanning a hard disk. (The OS is Darwin 11.4.2. The file system is HFS.)
How can I determine where a file (or contiguous chunk thereof) begins and ends on disk? I'm thinking of something along the lines of a generic beginning-of-file (BOF) and end-of-file (EOF) sequences.
I'm hoping the search could automatically "parse" the scanned content into (at least) coherent chunks (by splitting it at BOF-or-EOF).
|
How are files or chunks delimited on disk?
|
From my personal experience most filecarvers like to make assumptions based on which filesystems they detect. You could create a loop device with 32GB offset just to make sure your scanner/filecarver does not get sidetracked by seemingly valid data you're not interested in (i.e. skip the area you know was overwritten). Note the offset should be 512 Byte or 4K aligned. If you know the exact size of bytes that were overwritten, use that instead.
losetup --find --show --read-only --offset $((32*1000*1000*1000)) /dev/sdxThen you can use any program of your liking on that loop device. photorec is one, there are others like foremost, scalpel, ... knock yourself out.
If you had partitions / logical volumes that started beyond the 32GB mark you can also try testdisk. If you had a filesystem with redundant metadata you could try to fix that too, but you need to know the original partition offset (e.g. 1 MiB) and some way to locate the metadata backups.
This is best done with overlays https://raid.wiki.kernel.org/index.php/Recovering_a_failed_software_RAID#Making_the_harddisks_read-only_using_an_overlay_file
An overlay allows you to run fsck or some other programs that write on a virtual /dev/mapper/sdxoverlay device, without actually performing those writes on the real disk.
|
We had a human accident at home and an external hard disk was copied a SD 32gb image card by mistake. The copy should be done to a SD image.
I guess 32gb of the external drive were overwritten, but as far as my knowledge of digital forensics, the most of the information should be there.
Can you please recommend me a good low level scanner to analyse bit-to-bit the information in the whole hard disk to recover pictures and word files (mainly)?
I used to know testdisk, is it valid for it?
I hope you can give us a hand on this.
Kindest regards
|
How to scan a hard disk at low level to recover files in partially overwritten partition?
|
I solved the problem by adding cameron to the gpio group:
sudo usermod -aG gpio cameron
gpio export 18 out
echo 1 > /sys/class/gpio/gpio18/valueNow everything works.
|
This is on a Raspberry Pi.
Here's the output of sudo ls -lL /sys/class/gpio/gpio18:
-rwxrwx--- 1 root gpio 4096 Mar 8 10:50 active_low
-rwxrwx--- 1 root gpio 4096 Mar 8 10:52 direction
-rwxrwx--- 1 cameron cameron 4096 Mar 8 10:50 edge
drwxrwx--- 2 root gpio 0 Mar 8 10:50 power
drwxrwx--- 2 root gpio 0 Mar 8 10:50 subsystem
-rwxrwx--- 1 root gpio 4096 Mar 8 10:50 uevent
-rwxrwx--- 1 cameron cameron 4096 Mar 8 10:50 valueSo looks like I should now have access to value, great. However:
cameron@raspberrypi~ $ echo 1 > /sys/class/gpio/gpio18/value
-bash: /sys/class/gpio/gpio18/value: Permission deniedWhat's going on? If I chmod 777 everything, then it works, but I shouldn't have to do that when I own the file.
|
Unable to write to a GPIO pin despite file permissions on /sys/class/gpio/gpio18/value
|
The GPIO interface seems to be built for system (uid root) use only and doesn't have the features a /dev interface would for user processes. This includes creation permissions.
In order to allow user processes (including daemons and other system services) access, the permissions need to be granted by a root process at some point. It could be an init script, a middleman, or a manual (sudo) command.
|
Can the default permissions and ownership of /sys/class/gpio/ files be set, e.g. by configuring udev? The point would be to have a real gid for processes that can access GPIO pins on a board.
Most "solutions" include suid wrappers, scripts with chown and trusted middleman binaries. Web searches turn up failed attempts to write udev rules.
(related: Q1)
(resources: avrfreaks, linux, udev)
|
Set GPIO permissions cleanly
|
That shell wrapper looks like an init script, but apparently it isn't (hence you need to use sudo there; scripts run by init would not require this).
This seems to be a very clumsy way to do this; the shell wrapper does not serve any purpose that could not be better served by the python program itself. Get rid of that; if you want an init script specifically, write a minimal one, but I suggest you move the logic of controlling the daemon from the init script into the daemon (UPSalarm.py) itself.
Since you want only one instance, define a pid file that the process is to use. When UPSalarm.py start is run, it will check for the existence of this file. If it does not exist, it writes its own pid to this file and continues. If it does exist, it gets the pid and then checks with the OS to see if a process with the pid exists and if so, what it is called. This will prove that either UPSalarm.py is already running, or not. If it is, exit with an "Already running" message.
When UPSalarm.py stop is run, a similar sequence is involved -- check for the pid file, if it exists check the pid, if the pid is valid for a process named UPSalarm.py, signal it to stop, presumably with SIGINT. UPSalarm.py itself should implement a signal handler for SIGINT, such that it deletes the pid file before it exits.
I am not a python programmer and this is not a programming site (for that, see Stack Overflow), but I promise all this is easily possible with python. To get the pid of the current process, use os.getpid().
For mapping a pid to a process name, read /proc/[pid]/cmdline and do a string search for UPSalarm.py (or better yet, the name of process as invoked, which would be sys.argv[0], see here).
For signal handling, start here and here.
To send a signal to another process, use os.kill().It should be easy to then configure monit to handle this daemon. You also then have the option of instead just using cron (or your own script) to call UPSalarm.py start at intervals, say every 5-10 minutes.
|
I have a daemon that monitors various things using the GPIO ports. I have used python to write the code for this using the RPi.GPIO module.
I would like to ensure that the daemon is always running, i.e., restart it after a crash and start it when the system boots (crucially before any user logs in -- this Pi runs headless). There is a little flashing LED that tells me its running, but that's not ideal.
I have read about using MONIT for this purpose but I'm having a few issues. My attempts so far have mainly been around this solution:
https://stackoverflow.com/questions/23454344/use-monit-monitor-a-python-program
This is my bash wrapper file, its called /home/pi/UPSalarm/UPSalarm.bash
#!/bin/bashPIDFILE=/var/run/UPSalarm.pidcase $1 in
start)
#source /home
#Launch script
sudo python /home/pi/UPSAlarm/UPSalarm.py 2>/dev/null &
# store PID value
echo $! > ${PIDFILE}
;;
stop)
kill `cat ${PIDFILE}`
# Proccess killed, now remove PID
rm ${PIDFILE}
;;
*)
echo "usage: scraper {start|stop}" ;;
esac
exit 0`This is my monit rule
check process UPSalarm with pidfile /var/run/UPSalarm.pid
start = "/home/pi/UPSalarm/UPSalarm start"
stop = "/home/pi/UPSalarm/UPSalarm stop"I have two problems: firstly, I get the wrong PID number in UPSalarm.pid. I am wondering if I get a PID number for sudo? This is why I have posted the question here; I need sudo because I need access to the GPIO ports. Secondly, it doesn't work. Thirdly, I am not sure what source does in the bash file?
I know monit has great documentation, but a worked example for python really would be helpful, I've been stuck for a good few days.
The following websites were also helpful:
https://www.the-hawkes.de/monitor-your-raspberrypi-with-monit.html (for setting up monit)
https://mmonit.com/monit/documentation/monit.html
And these two questions are related but don't solve my problem:
https://raspberrypi.stackexchange.com/questions/9938/monitoring-a-python-script-running-in-a-screen-session-with-monit
How to restart the Python script automatically if it is killed or dies
|
Running daemon involving GPIO on Pi
|
GPIO_V2_LINE_SET_VALUES_IOCTL seems safe enough; it matches the expected use of ioctl, “manipulat[ing] the underlying device parameters of special files”. It is implemented in linereq_set_values, which acquires a lock, but I don’t think that lock can block for an indefinite amount of time (its users are all non-blocking).Theoretically, one might expect ioctls to be non-blocking, since they are mostly intended to configure drivers. However, some ioctls do much more than that: for example, FICLONERANGE and FICLONE involve actual I/O, and worse than that, they are supported by some networked file systems such as NFS v4.2, so they could conceivably block indefinitely.See point 1 above.
|
I am writing some code around libgpiod's interface. For example, I want to set a line to output high. Under the hood, libgpiod opens an fd provided by the kernel for the line, and then calls ioctl(fd, GPIO_V2_LINE_SET_VALUES_IOCTL, ...).
My questions are:Is this particular ioctl() call (with the GPIO_V2... argument) theoretically (potentially) blocking in the same way that writing to an arbitrary file descriptor can be?Are ioctl() calls in general theoretically blocking? For example, requesting the line in the first place also involves an ioctl() on a fd for the chip. What about I2C ioctl()s?If it is blocking, is the underlying fd in the line struct (line->fd_handle->fd) the one I need to wait on in an event loop (eg. epoll() or an abstracted event library like libuv)?I have tried to answer this question through research, but (a) searching for any combination of "ioctl" and "blocking" just gives results for setting a fd to be blocking or not and (b) it's not in the man pages or kernel docs that I can find.
|
Are ioctl calls blocking?
|
You could use the kernel isolcpus option in conjunction with the taskset command.
On the Raspberry Pi reserve the core(s) you want to use by appending the following to the line in /boot/cmdline.txt.
E.g. to reserve cores 2 and 3.
isolcpus=2,3Then use taskset to assign programs to the core(s).
E.g. to launch the Python interpreter.
taskset -c 3 python(look here for information on how to use the command).
If this is Raspberry Pi specific do you need to bit bang? There may be already existing solutions.
|
Can a core be dedicated to one user-space app (e.g. for the purpose of bit-banging GPIO without any interruptions)?
|
Can one core on a multicore linux system be dedicated to one user-space app?
|
[Install]
Alias=gpio23.service
It's as simple as noting that there's no WantedBy setting in that section. You've told systemd to enable the service, but not actually described which target should want it when it is enabled.
StandardOutput=null
It is not wise to do this as an everyday practice. Let standard output be logged until it becomes an actual problem to do so (which it clearly is far from being in the case of a few echo commands).
ExecStart=/bin/bash …
And, similarly, don't name the Bourne Again shell unless you are explicitly relying upon Bashisms, which (again) you are not with just some echo commands.
A decade ago, the Debian and Ubuntu people went to quite some lengths to take the Bourne Again shell out of the system bootstrap process wherever it was possible, replacing it with the Almquist shell which had far less initialization overhead in non-interactive mode, which sped up bootstrap markedly. Idly using /bin/bash all over the place — in systemd service units no less! — instead of /bin/sh, undoes that good work.
|
I have a Raspberry Pi on Raspbian Stretch and I want to enable some GPIO pins at boot time.
I wrote the following service:
[Unit]
Description=GPIO23 exported as output, value off[Service]
Type=oneshot
ExecStart=/bin/bash -c 'echo "23" > /sys/class/gpio/export'
ExecStart=/bin/bash -c 'echo "out" > /sys/class/gpio/gpio23/direction'
ExecStart=/bin/bash -c 'echo "0" > /sys/class/gpio/gpio23/value'
StandardOutput=null[Install]
Alias=gpio23.serviceAfter login via SSH, I check the result:
pi@Hi-Fi:~ $ systemctl status gpio23
● gpio23.service - GPIO23 exported as output, value off
Loaded: loaded (/lib/systemd/system/gpio23.service; linked; vendor preset: enabled)
Active: inactive (dead)
pi@Hi-Fi:ls /sys/class/gpio/
export gpiochip0 unexportSince it hasn't been run (or it didn't work as intended), I start the service manually:
pi@Hi-Fi:~ $ sudo systemctl start gpio23
[sudo] password for pi:
pi@Hi-Fi:~ $ systemctl status gpio23
● gpio23.service - GPIO23 exported as output, value off
Loaded: loaded (/lib/systemd/system/gpio23.service; linked; vendor preset: enabled)
Active: inactive (dead)Jan 01 19:31:12 Hi-Fi systemd[1]: Starting GPIO23 exported as output, value off...
Jan 01 19:31:12 Hi-Fi systemd[1]: Started GPIO23 exported as output, value off.
pi@Hi-Fi:~ $ ls /sys/class/gpio/
export gpio23 gpiochip0 unexportNow it works.
How can I make it work immediately as intended?
|
Why are systemd scripts not producing the expected results at boot, but correctly afterwards?
|
Disclaimer: I have not read the latest gpio_keys code, just skimmed over it. Yet, I believe that there is a good explanation for the separation of GPIO keys from IRQs.
A kernel has an IRQ event table, so different events can be given to known IRQs. The list of events (callbacks, well actually pointers) is written into a PIC (a separate chip or integrated in the CPU) and when the given interrupt happen the execution context enters into the event function. These functions need to be small so not much time is lost inside the interrupt.
But what is really important here is that (unless the CPU is instructed to temporarily ignore interrupts) the kernel will answer every interrupt.
For a responsive application you want things connected to the GPIO pins to produce an interrupt (i.e. be like an IRQ). Yet, there may be application where you do not care about every click of the button or every change in the state of whatever is connected to the GPIO pin. One example could be a sensor, which you want to measure every, say, half a second. You do not want the sensor to tell the kernel when it is "pressed" you want a userspace application to poke the kernel to tell it the current state of the sensor every half a second. It is not hard to think of a sensor that exposes an interface that looks like a button, pretty much any sensor that has only two states (e.g. dark/light with a threshold) can look like a button.
|
I'm confused about the driver gpio_keys.
This driver distinguishes between two types of buttons:
IRQ-only buttons and GPIO-driven buttons
Could anyone explain the difference between one and another?
|
Driver gpio_keys type of buttons
|
Maybe like this?
if [ $(cat sys/class/gpio/gpio60/value) -eq 0 ]; then
echo 1 > sys/class/leds/beaglebone:green:usr2/brightness
else
echo 0 > sys/class/leds/beaglebone:green:usr2/brightness
fi
|
On my embedded system, I can toggle a user led with: echo > 1 sys/class/leds/beaglebone:green:usr2/value.
Similarly, I can find the value of a GPIO (gpio60) (set to input), with more sys/class/gpio/gpio60/value
I've been trying to write a script to set the state of the user led based on that of the input. The following produces no errors, but doesn't actually work.
#!/bin/bash
cd ../../../
if [ sys/class/gpio/gpio60/value = 0 ]; then
echo 1 > sys/class/leds/beaglebone:green:usr2/brightness;
[else echo 0 > sys/class/leds/beaglebone:green:usr2/brightness;]
fi
|
Basic script in Angstrom Linux running on a Beaglebone Black
|
When considering this, you should refer to the chart in man 7 bootup, that describes the overall structure of systemd-based boot process.
You could specify WantedBy=sysinit.target, but then you'll need to specify a couple things in the [Unit] section:
[Unit]
DefaultDependencies=no
After=local-fs.target
After=systemd-modules-load.service
Before=sysinit.targetand maybe also
ConditionPathExists=/dev/ttyS5Setting DefaultDependencies to no allows your service to run earlier in the boot process, but also requires you to be more explicit about your service's requirements.
Since the script is in /usr/local (which could be a separate filesystem), you'll have to ensure the filesystem is mounted before trying to execute your script. That can be achieved with After=local-fs.target.
You'll also have to ensure the kernel modules for your /dev/ttyS5 and your GPIO are loaded, unless your script is actively loading them. After=systemd-modules-load.service aims to achieve that, assuming that you've already used a /etc/modules-load.d/*.conf file to specify the appropriate modules. You could also run systemctl list-units *.device, find the .device units corresponding to your ttyS5 and/or your GPIO (if one exists) and set your service to run After= them.
If it turns out Before=sysinit.target is too early for your script (or zsh) to function correctly, then you could try WantedBy=basic.target and Before=basic.target instead.Or if "between local-fs.target and sysinit.target" is not early enough for you, then you'd have to write a initramfs-tools hook script (to be placed into /etc/initramfs-tools/hooks) to package your script and everything else it might need into initramfs at update-initramfs time, and change your current script into an initramfs-tools boot script (to be placed into one of the /etc/initramfs-tools/scripts/*/ directories).
I would recommend not bloating the initramfs with the zsh shell and its requirements, though: if you want to go to the initramfs route, you should first make your boot-time script runnable with /bin/dash (a lightweight POSIX shell) instead, since that's the default shell present in initramfs in modern Debian/Ubuntu.
Both the hook script and the boot script have specific requirements that need to be followed: man 7 initramfs-tools has examples on both types of scripts.
You'll also need to deal with the fact that during initramfs, all devices may not have been initialized yet: udev will be busy creating devices as kernels modules are being loaded. Your hook script would have to ensure the drivers for your /dev/ttyS5 and your GPIO will be included in the initramfs, and your boot script would have to either explicitly load them or check that they've been autoloaded before attempting to use the devices.
|
I am wondering where can I install this service that executes zsh script to run my script as soon as possible.
Script uses serial port at /dev/ttyS5 and gpio pins.
Is there a earlier target than multi-user.target that can still run zsh script?
[Unit]
Description=Acer projector control
After=multi-user.target[Service]
Type=simple
ExecStart=/usr/bin/zsh /usr/local/bin/ff.zsh -a acer
ExecStop=/usr/bin/zsh /usr/local/bin/ff.zsh -rb acer
RemainAfterExit=yes
Restart=on-failure
RestartSec=10s
TimeoutSec=5min[Install]
WantedBy=multi-user.targetUPDATE 2.
[Unit]
Description=Acer projector control
DefaultDependencies=no
After=local-fs.target
After=systemd-modules-load.service
Before=sysinit.target
ConditionPathExists=/dev/ttyS5
Before=shutdown.target
Conflicts=shutdown.target[Service]
Type=simple
RemainAfterExit=yes
ExecStart=/usr/bin/zsh /usr/local/bin/ff.zsh -a acer
ExecStop=/usr/bin/zsh /usr/local/bin/ff.zsh -rb acer
Restart=on-failure
RestartSec=30s
TimeoutSec=5min[Install]
WantedBy=sysinit.target
|
Where can I install systemd service that executes zsh script as early as possible
|
Those messages are produced by the kernel General Purpose I/O code, apparently on trying to load the module that is introduced by this patch or its more developed equivalent.
Short version:
The module finds the WMI programming interface it's looking for, but overlooks the fact that the interface reports no controllable GPIO lines in your hardware. It should have stopped the registration attempt and rejected the module installation with a -ENODEV error code. You can get rid of the messages by blacklisting the gpio-aaeon module, i.e. by creating a file named e.g. /etc/modprobe.d/no-aaeon-gpio-here.conf with the following contents:
blacklist gpio-aaeonYou have found a bug in that kernel module, and might want to report it to the Linux GPIO developers. Your hardware seems to present an interesting "corner case" for testing the gpio_aaeon module, which the developers apparently haven't considered. This is understandable as the module seems to be fairly new: the patch I linked above was posted in late May of this year.Long version:
The GPIO subsystem is complaining that the gpio_aaeon module attempted to register a chip that does not actually have any General Purpose I/O lines to control, so there is no point registering such a chip to the GPIO subsystem.
The registering happens in the probe function of the module:
+static int __init aaeon_gpio_probe(struct platform_device *pdev)
+{
+ int err, i;
+ int dio_number = 0;
+ struct aaeon_gpio_data *data;
+ struct aaeon_gpio_bank *bank;
+
+ /* Prevent other drivers adding this platfom device */
+ if (!wmi_has_guid(AAEON_WMI_MGMT_GUID)) {
+ pr_debug("AAEON Management GUID not found\n");
+ return -ENODEV;
+ }
+
+ dio_number = aaeon_gpio_get_number();
+ if (dio_number < 0)
+ return -ENODEV;
+
+ data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
+
+ data->nr_bank = ARRAY_SIZE(aaeon_gpio_bank);
+ data->bank = aaeon_gpio_bank;
+ platform_set_drvdata(pdev, data);
+ bank = &data->bank[0];
+ bank->chip.parent = &pdev->dev;
+ bank->chip.ngpio = dio_number;
+ bank->data = data;
+ err = devm_gpiochip_add_data(&pdev->dev, &bank->chip, bank);
+ if (err)
+ pr_debug("Failed to register gpiochip %d: %d\n", i, err);
+
+ return err;
+}Since the attempt to load the module did not simply end with the -ENODEV error, your system apparently has the WMI management API this driver is looking for... but when queried, the API actually says it has nothing to control.
In other words, the module can proceed into the dio_number = aaeon_gpio_get_number(); call, which ends up just calling a WMI method to get a single integer number, which is apparently the number of GPIO lines available for control through this API. The WMI method returns no error... but the number of lines it reports is apparently 0.
The function proceeds into allocating some memory and starts building up the structures required by the Linux GPIO subsystem to register the GPIO lines for control. Once it's done that, it calls the devm_gpiochip_add_data() function of the GPIO subsystem to register a new GPIO chip... but the GPIO subsystem performs some sanity checking and notices those structures actually specify there is 0 GPIO lines to control in the chip.
According to Elixir.bootlin.com Linux kernel cross-referencer, the devm_gpiochip_add_data() is a macro that just calls the devm_gpiochip_add_data_with_key() function with the two last parameters NULLed out. That, in turn, calls the gpiochip_add_data_with_key() function, which will produce the first error message you're seeing on line #628.
The other messages after that get produced as the chain of function calls gets unwound as each function returns an error code to its caller.
If the value returned by the aaeon_gpio_get_number() is really the number of GPIO lines the WMI API can control, then the test:
+ if (dio_number < 0)
+ return -ENODEV;should actually be:
+ if (dio_number < 1)
+ return -ENODEV;But if the number returned by the WMI API actually means something subtly different, like "the 0-based number of the last controllable GPIO line" (i.e. value 0 would mean "there is just one GPIO line #0 and no others"), then using the dio_number as the value of bank->chip.ngpio results in an off-by-one error and the module would miss the last controllable GPIO line in all systems that have this WMI API for GPIOs.
So either way, there is something that needs to be fixed.
|
I found this in my logs:
kernel: gpio gpiochip0: (gpio_aaeon): tried to insert a GPIO chip with zero lines
kernel: gpiochip_add_data_with_key: GPIOs 0..-1 (gpio_aaeon) failed to register, -22
kernel: gpio-aaeon: probe of gpio-aaeon.0 failed with error -22What does it mean and how should I solve it?
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 21.04
Release: 21.04
Codename: hirsute
|
What gpio gpiochip0 kernel error means and how to solve?
|
Rather than persuading Docker of anything, just give test_user access to the gpiochips on both the host and docker_image. Then you can run Docker as test_user as before.
Typically on the Pi, the gpios are in the gpio group, so add test_user to that group (adduser test_user gpio), in both the host and the docker_image.
Not sure if that is valid for Ubuntu on Pi though (being a Raspberry Pi OS user myself). If not you will need to setup a group on the gpiochips as well. But as long as test_user has the appropriate permissions to access the gpiochip devices, in both the host and docker image, you should be good.
e.g. this works for me with no root involvement:
pi@devpi4:~ $ docker run -t --rm -i -u test_user --privileged -v /sys:/sys -v /dev:/dev libgpiod_axs gpiodetect
gpiochip0 [pinctrl-bcm2711] (58 lines)
gpiochip1 [raspberrypi-exp-gpio] (8 lines)where the libgpiod_axs image is an image with libgpiod installed, and has a test_user who is a member of the gpio group, as is the pi user on the host (who could equally be named test_user). Note that the GID of the group must match in the docker image and host.
|
We have an internal test system for our multi-platform software library which runs, with its zoo of third-party tools, inside an [Ubuntu] Docker container.
To keep things simple, the host machine AND the Docker container both run as the same user, test_user, fixed as UID 1000/GID 1000; this way volumes can be mapped between the two without issue.
However, I now need the Docker container to be able to access devices on the host machine (e.g. GPIOs). This ONLY seems to work if I run the Docker container specifically as the root user, i.e. this successfully permits access to GPIOs on the host (as evidenced by gpiodetect, which uses the libgpio API that we now want to test):
docker run -t --rm -i -u root --privileged -v /sys:/sys -v /dev:/dev docker_image /bin/bash
root@f1f7ca240c1e:/workdir# gpiodetect
gpiochip0 [pinctrl-bcm2711] (58 lines)
gpiochip1 [raspberrypi-exp-gpio] (8 lines)...whereas, if I add test_user to the root group, both inside the Docker container and on the host machine, none of these do:
docker run -t --rm -i -u test_user --privileged -v /sys:/sys -v /dev:/dev docker_image /bin/bash
test_user@57130c86c196:/workdir$ gpiodetect
gpiodetect: unable to access GPIO chips: Permission denieddocker run -t --rm -i -u 1000:1000 --privileged -v /sys:/sys -v /dev:/dev docker_image /bin/bash`
test_user@57130c86c196:/workdir$ gpiodetect
gpiodetect: unable to access GPIO chips: Permission deniedUnfortunately running the Docker container as root, as well as not being desirable, is not an easy option as it messes up the mappings with the host machine (lots of shouts of dubious users from Git and the like).
Is there a way to persuade Docker that the [non-root] user it is running as has root privileges and so can have GPIO access?
FYI, on the host:
host:~ $ groups test_user
test_user: test_user root...and in the Docker container:
test_user@1716f343e8c7:/workdir$ groups test_user
test_user: test_user root
test_user@1716f343e8c7:/workdir$
|
Docker with device [GPIO] access while running as a specified user that is not `root`
|
Going by the Allwinner_H3_Datasheet Section 3.3 ~pg80 (via link at the bottom of the Banana Pi page, only the EINT pins support interrupt.
According to the same Banana Pi page, CON2-P128 corresponds to PC4 on the H3, so not one of the PA or PG EINT pins and so no interrupt support.
Nothing the software, be it the kernel GPIO driver or libgpiod, can do to make that line provide interrupts. Your only options are to poll that line or switch to one of the EINT pins.
Btw, one of comments suggested using libgpiod v2 gpioset's interactive mode to get the line value as a performance optimization. Speaking as the author of that mode, that will not work - gpioset will hold the line output, and the value the get returns is the value the line is currently being set to (in case you toggle it a few times and lose track). So not what you want. General rule - don't use gpioset on input lines being driven externally - that can let the magic smoke out.
|
I am trying to monitor GPIO events using libgpiod on the armbian linux.
Accourding to pinout of my device (BananaPI Zero M2 /w H3 allwinner chip)
I have pin CON2-P18 hooked on impulse button so I can test it.
First I'll find what line the pin is:
# gpiofind "CON2-P18"
gpiochip0 68then I'll try to monitor it with gpiomon with no luck:
# gpiomon --rising-edge 0 68
gpiomon: error waiting for events: No such devicehowever I can confirm gpioget utility recognizes it and behaves properly on the button event:
# gpioget --bias=pull-down 0 68
0
root@bananapim2zero:~# gpioget --bias=pull-down 0 68
1
root@bananapim2zero:~# gpioget --bias=pull-down 0 68
0I can also set it using gpioset utility:
# gpioset -B pull-down gpiochip0 68=0I have verified the same process for monitoring CON2-P16 and that all works fine!
The same error and behavior I get when I try to monitor pin CON2-P18.
To simply use another pin would be kind of troublesome for me, because I have already designed and got manufactured PCBs using forementioned pins/lines. And I would like to use gpiomon utility instead of endless looping on gpioget.
Am I doing something wrong or is the lib faulty?
libgpiod v. 1.6.2-1
# uname -a
Linux bananapim2zero 6.1.11-sunxi #23.02.2 SMP Sat Feb 18 05:52:53 UTC 2023 armv7l GNU/Linuxthanks!
EDIT:
providing strace of
'faulty' command: $ strace sudo gpiomon --bias=pull-down --rising-edge gpiochip0 68:
execve("/usr/bin/sudo", ["sudo", "gpiomon", "--bias=pull-down", "--rising-edge", "gpiochip0", "68"], 0xbed32684 /* 24 vars */) = 0
access("/etc/suid-debug", F_OK) = -1 ENOENT (No such file or directory)
brk(NULL) = 0x192b000
fcntl64(0, F_GETFD) = 0
fcntl64(1, F_GETFD) = 0
fcntl64(2, F_GETFD) = 0
access("/etc/suid-debug", F_OK) = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6fd6000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/tls/v7l/neon/vfp/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/tls/v7l/neon/vfp", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/tls/v7l/neon/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/tls/v7l/neon", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/tls/v7l/vfp/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/tls/v7l/vfp", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/tls/v7l/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/tls/v7l", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/tls/neon/vfp/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/tls/neon/vfp", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/tls/neon/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/tls/neon", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/tls/vfp/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/tls/vfp", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/tls/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/tls", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/v7l/neon/vfp/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/v7l/neon/vfp", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/v7l/neon/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/v7l/neon", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/v7l/vfp/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/v7l/vfp", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/v7l/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/v7l", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/neon/vfp/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/neon/vfp", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/neon/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/neon", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/vfp/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/vfp", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=24663, ...}) = 0
mmap2(NULL, 24663, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6fcf000
close(3) = 0
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\364\"\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=107848, ...}) = 0
mmap2(NULL, 237700, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f74000
mprotect(0xb6f8d000, 65536, PROT_NONE) = 0
mmap2(0xb6f9d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19000) = 0xb6f9d000
mmap2(0xb6f9f000, 61572, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f9f000
close(3) = 0
openat(AT_FDCWD, "/usr/lib/sudo/libselinux.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libselinux.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0@R\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=108036, ...}) = 0
mmap2(NULL, 179236, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f48000
mprotect(0xb6f61000, 65536, PROT_NONE) = 0
mmap2(0xb6f71000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19000) = 0xb6f71000
mmap2(0xb6f73000, 3108, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f73000
close(3) = 0
openat(AT_FDCWD, "/usr/lib/sudo/libutil.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libutil.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\200\n\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=9800, ...}) = 0
mmap2(NULL, 73908, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f35000
mprotect(0xb6f37000, 61440, PROT_NONE) = 0
mmap2(0xb6f46000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0xb6f46000
close(3) = 0
openat(AT_FDCWD, "/usr/lib/sudo/libsudo_util.so.0", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\320=\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=79628, ...}) = 0
mmap2(NULL, 145056, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f11000
mprotect(0xb6f24000, 61440, PROT_NONE) = 0
mmap2(0xb6f33000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12000) = 0xb6f33000
close(3) = 0
openat(AT_FDCWD, "/usr/lib/sudo/libpthread.so.0", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libpthread.so.0", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\25K\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=113596, ...}) = 0
mmap2(NULL, 152152, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6eeb000
mprotect(0xb6efe000, 61440, PROT_NONE) = 0
mmap2(0xb6f0d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12000) = 0xb6f0d000
mmap2(0xb6f0f000, 4696, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f0f000
close(3) = 0
openat(AT_FDCWD, "/usr/lib/sudo/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\331v\1\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=971712, ...}) = 0
mmap2(NULL, 1040988, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6dec000
mprotect(0xb6ed6000, 61440, PROT_NONE) = 0
mmap2(0xb6ee5000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe9000) = 0xb6ee5000
mmap2(0xb6ee8000, 8796, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6ee8000
close(3) = 0
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libcap-ng.so.0", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0H\16\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=13860, ...}) = 0
mmap2(NULL, 78068, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6dd8000
mprotect(0xb6ddb000, 61440, PROT_NONE) = 0
mmap2(0xb6dea000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0xb6dea000
close(3) = 0
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libpcre2-8.so.0", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\250\31\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=415588, ...}) = 0
mmap2(NULL, 479836, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6d62000
mprotect(0xb6dc7000, 61440, PROT_NONE) = 0
mmap2(0xb6dd6000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x64000) = 0xb6dd6000
close(3) = 0
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libdl.so.2", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0000\n\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=9772, ...}) = 0
mmap2(NULL, 73924, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6d4f000
mprotect(0xb6d51000, 61440, PROT_NONE) = 0
mmap2(0xb6d60000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0xb6d60000
close(3) = 0
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6fcd000
set_tls(0xb6fcdbd0) = 0
mprotect(0xb6ee5000, 8192, PROT_READ) = 0
mprotect(0xb6d60000, 4096, PROT_READ) = 0
mprotect(0xb6f0d000, 4096, PROT_READ) = 0
mprotect(0xb6dd6000, 4096, PROT_READ) = 0
mprotect(0xb6dea000, 4096, PROT_READ) = 0
mprotect(0xb6f33000, 4096, PROT_READ) = 0
mprotect(0xb6f46000, 4096, PROT_READ) = 0
mprotect(0xb6f71000, 4096, PROT_READ) = 0
mprotect(0xb6f9d000, 4096, PROT_READ) = 0
mprotect(0x43f000, 4096, PROT_READ) = 0
mprotect(0xb6fd8000, 4096, PROT_READ) = 0
munmap(0xb6fcf000, 24663) = 0
set_tid_address(0xb6fcd778) = 10974
set_robust_list(0xb6fcd780, 12) = 0
rt_sigaction(SIGRTMIN, {sa_handler=0xb6eef66d, sa_mask=[], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0xb6e13841}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {sa_handler=0xb6eef6f1, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0xb6e13841}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
ugetrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
statfs("/sys/fs/selinux", 0xbea1655c) = -1 ENOENT (No such file or directory)
statfs("/selinux", {f_type=EXT2_SUPER_MAGIC, f_bsize=4096, f_blocks=7438627, f_bfree=6853088, f_bavail=6769594, f_files=1855392, f_ffree=1745592, f_fsid={val=[2118024466, 2550696797]}, f_namelen=255, f_frsize=4096, f_flags=ST_VALID|ST_NOATIME}) = 0
brk(NULL) = 0x192b000
brk(0x194c000) = 0x194c000
openat(AT_FDCWD, "/proc/filesystems", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
read(3, "nodev\tsysfs\nnodev\ttmpfs\nnodev\tbd"..., 1024) = 386
read(3, "", 1024) = 0
close(3) = 0
access("/etc/selinux/config", F_OK) = -1 ENOENT (No such file or directory)
prlimit64(0, RLIMIT_AS, NULL, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}) = 0
prlimit64(0, RLIMIT_AS, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}, NULL) = 0
prlimit64(0, RLIMIT_CORE, NULL, {rlim_cur=0, rlim_max=RLIM64_INFINITY}) = 0
prlimit64(0, RLIMIT_CPU, NULL, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}) = 0
prlimit64(0, RLIMIT_CPU, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}, NULL) = 0
prlimit64(0, RLIMIT_DATA, NULL, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}) = 0
prlimit64(0, RLIMIT_DATA, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}, NULL) = 0
prlimit64(0, RLIMIT_FSIZE, NULL, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}) = 0
prlimit64(0, RLIMIT_FSIZE, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}, NULL) = 0
prlimit64(0, RLIMIT_LOCKS, NULL, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}) = 0
prlimit64(0, RLIMIT_MEMLOCK, NULL, {rlim_cur=65536*1024, rlim_max=65536*1024}) = 0
prlimit64(0, RLIMIT_NOFILE, NULL, {rlim_cur=1024, rlim_max=1024*1024}) = 0
prlimit64(0, RLIMIT_NOFILE, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}, NULL) = -1 EPERM (Operation not permitted)
prlimit64(0, RLIMIT_NOFILE, {rlim_cur=256, rlim_max=RLIM64_INFINITY}, NULL) = -1 EPERM (Operation not permitted)
prlimit64(0, RLIMIT_NOFILE, {rlim_cur=1024*1024, rlim_max=1024*1024}, NULL) = 0
prlimit64(0, RLIMIT_NPROC, NULL, {rlim_cur=2962, rlim_max=2962}) = 0
prlimit64(0, RLIMIT_NPROC, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}, NULL) = -1 EPERM (Operation not permitted)
prlimit64(0, RLIMIT_NPROC, {rlim_cur=2962, rlim_max=2962}, NULL) = 0
prlimit64(0, RLIMIT_RSS, NULL, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}) = 0
prlimit64(0, RLIMIT_RSS, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}, NULL) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
prlimit64(0, RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}, NULL) = 0
fcntl64(0, F_GETFL) = 0x2 (flags O_RDWR)
fcntl64(1, F_GETFL) = 0x2 (flags O_RDWR)
fcntl64(2, F_GETFL) = 0x2 (flags O_RDWR)
openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=3041456, ...}) = 0
mmap2(NULL, 2097152, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6b4f000
mmap2(NULL, 2596864, PROT_READ, MAP_PRIVATE, 3, 0x6d000) = 0xb68d5000
close(3) = 0
openat(AT_FDCWD, "/etc/localtime", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=2329, ...}) = 0
fstat64(3, {st_mode=S_IFREG|0644, st_size=2329, ...}) = 0
read(3, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\10\0\0\0\10\0\0\0\0"..., 4096) = 2329
_llseek(3, -1479, [850], SEEK_CUR) = 0
read(3, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\t\0\0\0\t\0\0\0\0"..., 4096) = 1479
close(3) = 0
stat64("/etc/sudo.conf", {st_mode=S_IFREG|0644, st_size=3975, ...}) = 0
openat(AT_FDCWD, "/etc/sudo.conf", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=3975, ...}) = 0
read(3, "#\n# Default /etc/sudo.conf file\n"..., 4096) = 3975
read(3, "", 4096) = 0
close(3) = 0
geteuid32() = 1000
access("/usr/local/bin/sudo", X_OK) = -1 ENOENT (No such file or directory)
access("/usr/bin/sudo", X_OK) = 0
stat64("/usr/bin/sudo", {st_mode=S_IFREG|S_ISUID|0755, st_size=135928, ...}) = 0
openat(AT_FDCWD, "/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=2996, ...}) = 0
read(3, "# Locale name alias data base.\n#"..., 4096) = 2996
read(3, "", 4096) = 0
close(3) = 0
openat(AT_FDCWD, "/usr/share/locale/en_US.UTF-8/LC_MESSAGES/sudo.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_US.utf8/LC_MESSAGES/sudo.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_US/LC_MESSAGES/sudo.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en.UTF-8/LC_MESSAGES/sudo.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en.utf8/LC_MESSAGES/sudo.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en/LC_MESSAGES/sudo.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "sudo", 4sudo) = 4
write(2, ": ", 2: ) = 2
write(2, "effective uid is not 0, is /usr/"..., 133effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?) = 133
ioctl(2, TCGETS, {B9600 opost isig icanon echo ...}) = 0
) = 1
write(2, "\n", 1
) = 1
exit_group(1) = ?
+++ exited with 1 +++'working' $ sudo strace gpiomon --bias=pull-down --rising-edge gpiochip0 15 command:
execve("/usr/bin/gpiomon", ["gpiomon", "--bias=pull-down", "--rising-edge", "gpiochip0", "15"], 0xbed83760 /* 16 vars */) = 0
brk(NULL) = 0x17ce000
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f11000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=24663, ...}) = 0
mmap2(NULL, 24663, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6f0a000
close(3) = 0
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libgpiod.so.2", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\260!\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=21952, ...}) = 0
mmap2(NULL, 86024, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6ed4000
mprotect(0xb6ed9000, 61440, PROT_NONE) = 0
mmap2(0xb6ee8000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0xb6ee8000
close(3) = 0
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\331v\1\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=971712, ...}) = 0
mmap2(NULL, 1040988, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6dd5000
mprotect(0xb6ebf000, 61440, PROT_NONE) = 0
mmap2(0xb6ece000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe9000) = 0xb6ece000
mmap2(0xb6ed1000, 8796, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6ed1000
close(3) = 0
set_tls(0xb6f12180) = 0
mprotect(0xb6ece000, 8192, PROT_READ) = 0
mprotect(0xb6ee8000, 4096, PROT_READ) = 0
mprotect(0x4a1000, 4096, PROT_READ) = 0
mprotect(0xb6f13000, 4096, PROT_READ) = 0
munmap(0xb6f0a000, 24663) = 0
rt_sigprocmask(SIG_BLOCK, [INT TERM], NULL, 8) = 0
signalfd4(-1, [INT TERM], 8, 0) = 3
openat(AT_FDCWD, "/dev", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC|O_DIRECTORY) = 4
fstat64(4, {st_mode=S_IFDIR|0755, st_size=3300, ...}) = 0
brk(NULL) = 0x17ce000
brk(0x17ef000) = 0x17ef000
getdents64(4, 0x17ce1b0 /* 165 entries */, 32768) = 4896
getdents64(4, 0x17ce1b0 /* 0 entries */, 32768) = 0
close(4) = 0
openat(AT_FDCWD, "/dev/gpiochip0", O_RDWR|O_CLOEXEC) = 4
lstat64("/dev/gpiochip0", {st_mode=S_IFCHR|0600, st_rdev=makedev(0xfe, 0), ...}) = 0
stat64("/dev/gpiochip0", {st_mode=S_IFCHR|0600, st_rdev=makedev(0xfe, 0), ...}) = 0
access("/sys/bus/gpio/devices/gpiochip0/dev", R_OK) = 0
openat(AT_FDCWD, "/sys/bus/gpio/devices/gpiochip0/dev", O_RDONLY) = 5
read(5, "254:0\n", 15) = 6
close(5) = 0
ioctl(4, GPIO_GET_CHIPINFO_IOCTL, 0xbee98018) = 0
openat(AT_FDCWD, "/dev/gpiochip1", O_RDWR|O_CLOEXEC) = 5
lstat64("/dev/gpiochip1", {st_mode=S_IFCHR|0600, st_rdev=makedev(0xfe, 0x1), ...}) = 0
stat64("/dev/gpiochip1", {st_mode=S_IFCHR|0600, st_rdev=makedev(0xfe, 0x1), ...}) = 0
access("/sys/bus/gpio/devices/gpiochip1/dev", R_OK) = 0
openat(AT_FDCWD, "/sys/bus/gpio/devices/gpiochip1/dev", O_RDONLY) = 6
read(6, "254:1\n", 15) = 6
close(6) = 0
ioctl(5, GPIO_GET_CHIPINFO_IOCTL, 0xbee98018) = 0
close(4) = 0
close(5) = 0
openat(AT_FDCWD, "/dev/gpiochip0", O_RDWR|O_CLOEXEC) = 4
lstat64("/dev/gpiochip0", {st_mode=S_IFCHR|0600, st_rdev=makedev(0xfe, 0), ...}) = 0
stat64("/dev/gpiochip0", {st_mode=S_IFCHR|0600, st_rdev=makedev(0xfe, 0), ...}) = 0
access("/sys/bus/gpio/devices/gpiochip0/dev", R_OK) = 0
openat(AT_FDCWD, "/sys/bus/gpio/devices/gpiochip0/dev", O_RDONLY) = 5
read(5, "254:0\n", 15) = 6
close(5) = 0
ioctl(4, GPIO_GET_CHIPINFO_IOCTL, 0xbee98058) = 0
ioctl(4, GPIO_GET_LINEINFO_IOCTL, 0xbee9807c) = 0
ioctl(4, GPIO_GET_LINEEVENT_IOCTL, 0xbee9809c) = 0
ioctl(4, GPIO_GET_LINEINFO_IOCTL, 0xbee9803c) = 0
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 1 ([{fd=5, revents=POLLIN}])
read(5, "\233\\D\336\201\10\0\0\1\0\0\0\0\0\0\0", 16) = 16
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
write(1, "event: RISING EDGE offset: 15 t"..., 63event: RISING EDGE offset: 15 timestamp: [ 9353.872825499]
) = 63
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 1 ([{fd=5, revents=POLLIN}])
read(5, "\213\273\312\6\203\10\0\0\1\0\0\0\0\0\0\0", 16) = 16
write(1, "event: RISING EDGE offset: 15 t"..., 63event: RISING EDGE offset: 15 timestamp: [ 9358.847687563]
) = 63
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000^C) = 1 ([{fd=3, revents=POLLIN}])
strace: Process 10962 detached
|
gpiomon from libgpiod library seem not to behave correctly
|
You could add your module to the modules.d folder, and it'll get picked up by systemd at boot time.
so make a file called /etc/modules-load.d/<featurename>.conf
and let it contain
<modulename>where is the name of the .ko file without the .ko extension
you can get documentation for modules-load.d by typing man modules-load.d at your terminal
|
I'm trying to insert the [.]Ko (Kernel Object) file for the on-board GPIO into my Linux kernel which succeeds using the command insmod < file-name.ko > But when the OS/Device Reboots, the kernel no longer has the mod inserted (checking using lsmod). I have also tried placing it in /lib/modules/4.19.0-14-amd64/kernel/drivers/gpio and running the "sudo update-initramfs -u" to update boot init but didn't work.
Is there any way to insert a kernel module permanently (sustains reboot)?
P.S. I don't want to use "@reboot insmod" in crontab. Using a Debian GNU/Linux 10 (buster)
|
Cannot make persistant Insertion of a kernel object (debian) using Insmod
|
The advantage of option 2 is that you can validate the request in a single place. Say for a dishwasher you can ensure the door sensor says the door is closed before you turn on the water. Sure you can tell people to check the door status bit before they set the water on bit, but will they all do so?
A potential disadvantage of options 1 and 3 is permissions. It depends on how sophisticated the embedded device is, but you might want to have different userids doing different things, for example a home router might have a different uid running an http server doing the web UI and a different daemon operating the front panel LEDs. Whilst it is possible for gpio drivers to have fine grained access control, most have an all or nothing approach. With option 2 you can decide which users can access which facilities at a fine level.
The downside of option 2 is it is more complicated, and usually requires code in the kernel.
|
I believe I could not fully understand the benefits of writing device drivers in embedded systems for some specific devices, such as GPIO, when there are alternative ways of doing the same job.You can access the GPIOs via sysfs and device tree.Write a new device tree overlay and enable it
Go to the /sys/class/gpio
Export required pin and start using it (via simple shell calls or inside the c/c++ app)Write your own driver.Code the real functionalities.
Expose the driver to a node (like /dev/tty) in userspace.
Write another c/c++ code to access the driver (also it can be accessed via simple shell calls)
If you need any new functionalities, first change the driver then your code. (Why?)Use directly /dev/mem;Include mman.h and use /dev/mem object to set or get the GPIO status.So,1 -> is going to be deprecated and slow. (Ok, absolutely beneficial for fast prototyping)
2 -> How is that faster than 1? 1st one is also another GPIO driver, isn't it?
3 -> Isn't it best and fastest way?I asked several questions above but here is my biggest question; why shouldn't I go straight with the 3rd solution?
|
Driver development vs sysfs access vs mmap for GPIOs
|
So first off: you're doing GPIO things in your python script. Honestly, you should just use the very same library you use there (which I don't know) to read the GPIO state and behave accordingly! Same for your do python… ; sleep 10; done loop: this would really be something you should rather integrate in your python script.
Secondly, sure, just check the value of the GPIO-pseudofile, depending on your kernel setup probably in /sys/class/gpio/gpio{number}/value (might need to set the direction of that pin with echo in > /sys/class/gpio/gpio{number}/direction; if it's not there, you might need to export it first by echo {number} > /sys/class/gpio/export) ; that's the deprecated sysfs interface, but I bet on default kernels for the RPi it's still enabled. Alternatively, use the gpio tool that you can install for your Linux distro, with gpio read {id}.
|
So I built an MLB scoreboard with a RPI 3. Right now the display can either show my favorite teams playing, OR all the teams playing and cycle through them as they are going on. I would like to add a toggle switch to the back of the scoreboard to select either the All-Teams or My-Teams depending on who's playing at that time. I have two separate nearly identical directories for the scoreboard accommodating either All-Teams or My-Teams.
Right now I have a cron file called "start-scoreboard.sh" that will start the score board showing either All-Teams, or My-Teams depending on what I have entered into "cd /home/pi/mlb-led-scoreboard-(All-Teams OR My-Teams here)" within the cron file.
Is there a way for the RPI to read the state of a gpio pin and run either All-Teams OR My-Teams directories? Here is an example of what I have in my "start-scoreboard.sh" cron file with the All-Teams directory listed...
!/bin/bash
u/reboot sleep 60 $$ start-scoreboard.sh
cd /home/pi/mlb-led-scoreboard-All-Teams
n=0
until [ $n -ge 10 ]
do
python main.py --led-gpio-mapping=adafruit-hat --led-brightness=50 --led-slowdown-gpio=3 --led-rows=32 --led-cols=64 && break
n=$[$n+1]
sleep 10
done
|
How to read a pin state on a Raspberry Pi and select (either/or) between two entries in a cron file?
|
Apparently this was already done using a FT232H.
https://github.com/rm-hull/luma.oled/issues/185
|
I've a bunch of SSD1351 OLED displays like this one:Those are driven over a SPI Interface and I use them in the Raspberry Pi and other ARM SBCs like the NanoPi with the following libraries:https://github.com/rm-hull/OPi.GPIO
https://luma-oled.readthedocs.io/en/latest/
https://pillow.readthedocs.io/en/stable/Those ARM SBCs have integrated SPI that is exposed in Linux at /dev/spidevX.Y.
Is it possible to drive this screen from a standard x86 computer? I own a FT4232H Mini Module (GPIO/UART/SPI to USB) and also found out the AK-MCP2210 (USB to SPI Bridge) however I'm not sure they will expose the screen in /dev/ nor if luma-oled can be used.
Thank you.
|
x86: Drive a SSD1351 OLED Display
|
I finally found this is done with a kernel feature called vga arbiter. Whichever VGA adapter is used as primary by the BIOS ends up being flagged a the "bootvga" device. Its possible to force vga arbiter to select and use the next vga adapter by using the stub driver for the undesired VGA adapter. Retrieve the pci device id using lspci -nn | grep VGA
Add this parameter to your kernel command line pci-stub.ids=0000:0000
When I move to RHEL 7, I'll be doing pci passthrough with this disabled adapter. Remember Nvidia graphics cards also include an audio device and end up in the same IOMMU group as the VGA device. Both pci device ids will need to be stubbed.
|
I have an HP DL380G9 server with two discreet nvidia graphics card installed running RHEL 6 with Kernel 2.6.32-573. Both cards have the same chipset (NV117) but different models. K620 (Slot 5 address 88:00.0), K2200 (Slot 4 address 84:00.0). The K2200 is the selected card for Linux to output plymouth and boot messages.
Swapping the cards results in the HP Server BIOS hitting a page fault, even after clearing CMOS and BIOS settings. Swapping the cards back fixes the issue. There is no option in the BIOS to select a primary discreet graphics card. Linux appears to select the graphics card with the lowest PCI Bus Address.
Is there a kernel command line option or some other configuration file to select a different graphics card for the default pre-X11 display?
|
Select graphics card for console output
|
I think I finally fixed it!
I need to create a xorg.conf file and add set the correct driver to radeon; it was fbdev before.
Section "Device"
### Available Driver options are:-
### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
### <string>: "String", <freq>: "<f> Hz/kHz/MHz",
### <percent>: "<f>%"
### [arg]: arg optional
#Option "ShadowFB" # [<bool>]
#Option "Rotate" # <str>
#Option "fbdev" # <str>
#Option "debug" # [<bool>]
Identifier "Card0"
Driver "radeon"
BusID "PCI:1:0:0"
EndSectionNow my glxinfo doesn't display libvmpipe anymore:
OpenGL renderer string: Gallium 0.4 on AMD REDWOOD
GL_MESA_texture_signed_rgba, GL_NV_conditional_render, GL_NV_depth_clamp,
GL_MESA_window_pos, GL_NV_blend_square, GL_NV_conditional_render, Gala is using 0% CPU now.
@mikeserv, your comment pointed me into the right direction. I knew my X was being software rendered somehow, but didn't know exactly how. Thank you.
|
I am using ElementaryOS with the default Drivers and my Gala process is constantly using tons of CPU (sometimes more than 200%).
I have looked everywhere but couldnt find a solution. I tried to install the proprietary ATI drivers but then I can't login in the system (black screen).
My graphic card is an ATI Mobility Radeon 5730.
Here is the result of glxinfo command:
name of display: :0
display: :0 screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
GLX_ARB_multisample, GLX_EXT_visual_info, GLX_EXT_visual_rating,
GLX_EXT_import_context, GLX_EXT_texture_from_pixmap, GLX_OML_swap_method,
GLX_SGI_make_current_read, GLX_SGIS_multisample, GLX_SGIX_fbconfig,
GLX_SGIX_pbuffer, GLX_MESA_copy_sub_buffer, GLX_INTEL_swap_event
client glx vendor string: Mesa Project and SGI
client glx version string: 1.4
client glx extensions:
GLX_ARB_create_context, GLX_ARB_create_context_profile,
GLX_ARB_get_proc_address, GLX_ARB_multisample, GLX_EXT_import_context,
GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_EXT_framebuffer_sRGB,
GLX_EXT_create_context_es2_profile, GLX_MESA_copy_sub_buffer,
GLX_MESA_multithread_makecurrent, GLX_MESA_swap_control,
GLX_OML_swap_method, GLX_OML_sync_control, GLX_SGI_make_current_read,
GLX_SGI_swap_control, GLX_SGI_video_sync, GLX_SGIS_multisample,
GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group,
GLX_EXT_texture_from_pixmap, GLX_INTEL_swap_event
GLX version: 1.4
GLX extensions:
GLX_ARB_get_proc_address, GLX_ARB_multisample, GLX_EXT_import_context,
GLX_EXT_visual_info, GLX_EXT_visual_rating,
GLX_MESA_multithread_makecurrent, GLX_OML_swap_method,
GLX_SGI_make_current_read, GLX_SGIS_multisample, GLX_SGIX_fbconfig,
GLX_SGIX_pbuffer, GLX_EXT_texture_from_pixmap
OpenGL vendor string: VMware, Inc.
OpenGL renderer string: Gallium 0.4 on llvmpipe (LLVM 0x300)
OpenGL version string: 2.1 Mesa 8.0.4
OpenGL shading language version string: 1.20
OpenGL extensions:
GL_ARB_multisample, GL_EXT_abgr, GL_EXT_bgra, GL_EXT_blend_color,
GL_EXT_blend_minmax, GL_EXT_blend_subtract, GL_EXT_copy_texture,
GL_EXT_polygon_offset, GL_EXT_subtexture, GL_EXT_texture_object,
GL_EXT_vertex_array, GL_EXT_compiled_vertex_array, GL_EXT_texture,
GL_EXT_texture3D, GL_IBM_rasterpos_clip, GL_ARB_point_parameters,
GL_EXT_draw_range_elements, GL_EXT_packed_pixels, GL_EXT_point_parameters,
GL_EXT_rescale_normal, GL_EXT_separate_specular_color,
GL_EXT_texture_edge_clamp, GL_SGIS_generate_mipmap,
GL_SGIS_texture_border_clamp, GL_SGIS_texture_edge_clamp,
GL_SGIS_texture_lod, GL_ARB_multitexture, GL_IBM_multimode_draw_arrays,
GL_IBM_texture_mirrored_repeat, GL_ARB_texture_cube_map,
GL_ARB_texture_env_add, GL_ARB_transpose_matrix,
GL_EXT_blend_func_separate, GL_EXT_fog_coord, GL_EXT_multi_draw_arrays,
GL_EXT_secondary_color, GL_EXT_texture_env_add, GL_EXT_texture_lod_bias,
GL_INGR_blend_func_separate, GL_NV_blend_square, GL_NV_light_max_exponent,
GL_NV_texgen_reflection, GL_NV_texture_env_combine4,
GL_SUN_multi_draw_arrays, GL_ARB_texture_border_clamp,
GL_ARB_texture_compression, GL_EXT_framebuffer_object,
GL_EXT_texture_env_combine, GL_EXT_texture_env_dot3, GL_MESA_window_pos,
GL_NV_packed_depth_stencil, GL_NV_texture_rectangle, GL_ARB_depth_texture,
GL_ARB_occlusion_query, GL_ARB_shadow, GL_ARB_texture_env_combine,
GL_ARB_texture_env_crossbar, GL_ARB_texture_env_dot3,
GL_ARB_texture_mirrored_repeat, GL_ARB_window_pos,
GL_EXT_stencil_two_side, GL_EXT_texture_cube_map, GL_NV_fog_distance,
GL_APPLE_packed_pixels, GL_APPLE_vertex_array_object, GL_ARB_draw_buffers,
GL_ARB_fragment_program, GL_ARB_fragment_shader, GL_ARB_shader_objects,
GL_ARB_vertex_program, GL_ARB_vertex_shader, GL_ATI_draw_buffers,
GL_ATI_texture_env_combine3, GL_ATI_texture_float, GL_EXT_shadow_funcs,
GL_EXT_stencil_wrap, GL_MESA_pack_invert, GL_MESA_ycbcr_texture,
GL_NV_primitive_restart, GL_ARB_fragment_program_shadow,
GL_ARB_half_float_pixel, GL_ARB_occlusion_query2, GL_ARB_point_sprite,
GL_ARB_shading_language_100, GL_ARB_sync, GL_ARB_texture_non_power_of_two,
GL_ARB_vertex_buffer_object, GL_ATI_blend_equation_separate,
GL_EXT_blend_equation_separate, GL_OES_read_format,
GL_ARB_pixel_buffer_object, GL_ARB_texture_compression_rgtc,
GL_ARB_texture_float, GL_ARB_texture_rectangle,
GL_ATI_texture_compression_3dc, GL_EXT_packed_float,
GL_EXT_pixel_buffer_object, GL_EXT_texture_compression_rgtc,
GL_EXT_texture_mirror_clamp, GL_EXT_texture_rectangle,
GL_EXT_texture_sRGB, GL_EXT_texture_shared_exponent,
GL_ARB_framebuffer_object, GL_EXT_framebuffer_blit,
GL_EXT_framebuffer_multisample, GL_EXT_packed_depth_stencil,
GL_ARB_vertex_array_object, GL_ATI_separate_stencil,
GL_ATI_texture_mirror_once, GL_EXT_draw_buffers2, GL_EXT_draw_instanced,
GL_EXT_gpu_program_parameters, GL_EXT_texture_compression_latc,
GL_EXT_texture_sRGB_decode, GL_OES_EGL_image, GL_ARB_copy_buffer,
GL_ARB_draw_instanced, GL_ARB_half_float_vertex, GL_ARB_instanced_arrays,
GL_ARB_map_buffer_range, GL_ARB_texture_rg, GL_ARB_texture_swizzle,
GL_ARB_vertex_array_bgra, GL_EXT_separate_shader_objects,
GL_EXT_texture_swizzle, GL_EXT_vertex_array_bgra,
GL_NV_conditional_render, GL_AMD_draw_buffers_blend,
GL_ARB_ES2_compatibility, GL_ARB_draw_buffers_blend,
GL_ARB_draw_elements_base_vertex, GL_ARB_explicit_attrib_location,
GL_ARB_fragment_coord_conventions, GL_ARB_provoking_vertex,
GL_ARB_sampler_objects, GL_ARB_shader_texture_lod,
GL_ARB_vertex_type_2_10_10_10_rev, GL_EXT_provoking_vertex,
GL_EXT_texture_snorm, GL_MESA_texture_signed_rgba, GL_ARB_robustness,
GL_ARB_texture_storagexorg.log file -> http://pastebin.com/acbCeMB5
|
ElementaryOS Gala using more than 100% CPU constantly
|
Let pacman handle dependency issues
I assume you have tried to simply install the wanted packages using (you might also want to pass --asdeps to pacman):
pacman -S nvidia-304xx lib32-nvidia-304xx-libglpacman should inform you about arising conflicts and ask you whether you want to remove conflicting packages: simply answer "Yes".
Consider changing to a rescue mode first, just in case, by issuing:
systemctl isolate rescue.targetor append systemd.unit=rescue.target to the kernel parameters add boot time.
Now assuming that did not work: try the next solution.
chroot into your installation from a live medium
Boot using a live medium, then mount you root partition and bind /dev /sys /proc into the just mounted root directory:
mount /dev/sd<X><n> /mnt
mount -o bind /dev /mnt/dev
mount -o bind /sys /mnt/sys
mount -o bind /proc /mnt/procchroot into your archlinux installation:
chroot /mntAnd remove the unwanted packages (-dd tells pacman to skip all dependency checks):
pacman -Rdd nvidia-libgl lib32-nvidia-libgl mesaInstall the package you actually wanted (you might also want to pass --asdeps to pacman):
pacman -S nvidia-304xx lib32-nvidia-304xx-libglHopefully after installing these packages the dependencies are fulfilled again.
Exit the chroot:
exit
umount /mnt/dev
umount /mnt/proc
umount /mnt/sys
umount /mntCross your fingers and reboot.
You could actually try and run pacman -Rdd booted into your installation – but I consider doing so safer chrooted from a live medium.
|
The machine has a NVIDIA GeForce 7350 LE graphics card, and I realised that I set up the wrong graphics driver when setting up an Arch Linux machine. I also chose the wrong versions of libgl and lib32-libgl in the course of downloading software.
The installed packages are: nvidia-libgl, lib32-nvidia-libgl, and mesa.
The needed packages are: nvidia-304xx and lib32-nvidia-304xx-libgl.
The question is: how can I safely uninstall the former packages and install the latter without messing up dependencies? Many packages on the system rely on those first 3. I am completely new to package management in Arch Linux.
Update: I downloaded the XFCE desktop environment and the LXDM display manager. At this point the computer hangs during boot after saying "reached target graphical interface". I can switch to another tty and log in, but it constantly switches me back to tty1 (where it appears to be frozen) and it's rather difficult to do much of anything. I think the problem has to do with the graphics drivers. Any help would be appreciated.
|
Replace Incorrect Packages which are Dependencies
|
They both are used and supports different set of codecs. Even more some va-api drivers run nvdpau interfaces and vice versa.
Archlinux wiki is good at explaining some basic things with its tables, even non distro specific stuff, which aplies to many distros:
https://wiki.archlinux.org/index.php/VA-API
https://wiki.archlinux.org/index.php/VDPAU
|
I wanted to compile a variant of mplayer and came across these options: VAAPI VDPAU.
I once read somewhere that one of these is for the newer graphic cards (like new gforce GT) and overlaps the other. Or I am totally wrong and they are different technologies for different hardware?
|
VAAPI or VDPAU which one is a newer Tech?
|
Sandy Bridge’s outputs don’t have enough bandwidth to support your monitor’s full resolution at 60Hz, however it should be possible to create a mode which will get you some of the way there.
This article gives details on the calculation process. In your case, the important factors are that your monitor’s native resolution is 3840×2160, and that HDMI 1.4 has a maximum pixel clock of 340MHz. Using umc, we can use this to determine an appropriate mode line:
$ umc 3840 2160 340000000 # 3840x2160x30.00 @ 65.994kHz
Modeline "3840x2160x30.00" 340.000000 3840 4080 4496 5152 2160 2164 2168 2200 -HSync +VSyncTo try this, run
xrandr --newmode "3840x2160x30.00" 340.000000 3840 4080 4496 5152 2160 2164 2168 2200 -HSync +VSync
xrandr --addmode HDMI-1 "3840x2160x30.00"
xrandr --output HDMI-1 --mode "3840x2160x30.00"If it proves too high for the integrated GPU, or the monitor doesn’t like it, you can try reducing the pixel clock, or reducing the blanking timing (which should be fine on a modern screen):
$ umc 3840 2160 30 --rbt # 3840x2160x29.98 @ 65.688kHz
Modeline "3840x2160x29.98" 262.750000 3840 3888 3920 4000 2160 2163 2167 2191 +HSync -VSyncOnce you have a working mode line, you can store it permanently by adding a configuration file, say /etc/X11/xorg.conf.d/30-hdmi-4k.conf, containing:
Section "Monitor"
Identifier "HDMI-1"
ModelName "Your monitor"
Modeline "3840x2160x29.98" 262.750000 3840 3888 3920 4000 2160 2163 2167 2191 +HSync -VSync
EndSection
|
I have current Debian testing, can't set resolution for display dell U2718Q:
# inxi -Gxx
Graphics: Card: Intel 2nd Generation Core Processor Family Integrated Graphics Controller
bus-ID: 00:02.0 chip-ID: 8086:0116
Display Server: x11 (X.Org 1.19.5 ) drivers: intel
Resolution: [emailprotected]
OpenGl: renderer: Mesa DRI Intel Sandybridge Mobile
version: 3.3 Mesa 17.2.5 (compat-v: 3.0) Direct Render: yes/etc/X11/xorg.conf:
Section "Device"
Indentifier "Intel Graphics"
Driver "intel"
Option "AccelMethod" "sna"
Option "TearFree" "true"
EndSectionBut it didn't help with resolution.
I try to set:
# xrandr --output HDMI-1 --mode 3840x2160_60.00
xrandr: Configure crtc 0 failedI tried also with option --crtc, but there is no result.
xrandr output:
# xrandr
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 8192 x 8192
LVDS-1 connected (normal left inverted right x axis y axis)
1366x768 60.10 +
1360x768 59.80 59.96
1024x768 60.04 60.00
960x720 60.00
928x696 60.05
896x672 60.01
960x600 60.00
960x540 59.99
800x600 60.00 60.32 56.25
840x525 60.01 59.88
800x512 60.17
700x525 59.98
640x512 60.02
720x450 59.89
640x480 60.00 59.94
680x384 59.80 59.96
576x432 60.06
512x384 60.00
400x300 60.32 56.34
320x240 60.05
VGA-1 disconnected (normal left inverted right x axis y axis)
HDMI-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 609mm x 349mm
2048x1280 59.99
2048x1080 24.00
1920x1080 60.00* 60.00 50.00 59.94 30.00 25.00 24.00 29.97 23.98
1920x1080i 60.00 50.00 59.94 50.00
1600x1200 60.00
1600x900 60.00
1280x1024 75.02 60.02
1152x864 75.00
1280x720 60.00 50.00 59.94
1024x768 75.03 60.00
800x600 75.00 60.32
720x576 50.00
720x576i 50.00
720x480 60.00 59.94
720x480i 60.00 59.94
640x480 75.00 60.00 59.94
720x400 70.08
3840x2160_60.00 59.98
DP-1 disconnected (normal left inverted right x axis y axis)I have xserver-xorg-video-intel, xserver-xorg-video-all, xserver-xorg-core packages installed.
Please any help.
Upd:
Processor: Intel Core i5-2467M CPU @ 1.60GHz x 2
port: HDMI 2.0
/var/log/Xorg.0.log
[ 18.449] (II) LoadModule: "intel"
[ 18.456] (II) Loading /usr/lib/xorg/modules/drivers/intel_drv.so
[ 18.469] (II) Module intel: vendor="X.Org Foundation"
[ 18.469] compiled for 1.19.0, module version = 2.99.917
[ 18.469] Module class: X.Org Video Driver
[ 18.469] ABI class: X.Org Video Driver, version 23.0
[ 18.469] (II) intel: Driver for Intel(R) Integrated Graphics Chipsets:
i810, i810-dc100, i810e, i815, i830M, 845G, 854, 852GM/855GM, 865G,
915G, E7221 (i915), 915GM, 945G, 945GM, 945GME, Pineview GM,
Pineview G, 965G, G35, 965Q, 946GZ, 965GM, 965GME/GLE, G33, Q35, Q33,
GM45, 4 Series, G45/G43, Q45/Q43, G41, B43
[ 18.470] (II) intel: Driver for Intel(R) HD Graphics
[ 18.470] (II) intel: Driver for Intel(R) Iris(TM) Graphics
[ 18.470] (II) intel: Driver for Intel(R) Iris(TM) Pro Graphics
[ 18.490] (II) intel(0): Using Kernel Mode Setting driver: i915, version 1.6.0 20170403
[ 18.490] (II) intel(0): SNA compiled: xserver-xorg-video-intel 2:2.99.917+git20161206-1 (Timo Aaltonen <[emailprotected]>)
[ 18.490] (II) intel(0): SNA compiled for use with valgrind
[ 18.494] (--) intel(0): Integrated Graphics Chipset: Intel(R) HD Graphics 3000
|
Can't set correct display resolution
|
There are several Intel drivers options which, if they don't work perfectly with your hardware, can cause issues like this:The big one is lvds_downclock, but it defaults to off. If you've changed that default, that's the first one to try. (It's possible some kernel versions defaulted to on, so its worth a try to force-disable it).
i915_enable_fbc can cause various display issues. The default is per-chip, you may want to try turning it off.Both of the above will probably increase power usage a little.Finally, powersave defaults to true, turning it off will disable a bunch of powersaving stuff at once. This will probably work, but you'll notice the battery life hit.There are two ways to set these values:On the kernel command line, like this: i915.i915_enable_fbc=0. Yes, you need the i915. prefix, even when the option name starts with i915. You can test temporarily by editing the command line in GRUB before booting, and set permanently in the grub config (edit /etc/default/grub, then run update-grub. Or dpkg-reconfigure grub-pc).
Create a new file in /etc/modprobe.d, for example /etc/modprobe.d/local-i915.conf. Then inside it, put options i915 i915_enable_fbc=0 lvds_downclock=0 (etc.). Note that you do not use the i915. prefix here. After editing, run update-initramfs -u.Another option is to try a newer kernel. Currently, Debian Backports has 3.12. Newer kernels have fixed a lot of bugs in the Intel video driver, and also have better knowledge of when which hardware particular powersaving features work on.
|
I installed Debian 7 on an Asus Eee PC 2101HA.
Sometimes the screen goes black for 1 second.
My VGA card is VGA compatible controller: Intel Corporation System Controller Hub (SCH Poulsbo) Graphics Controller (rev 07)
|
Occasional screen blackouts on Debian 7
|
To install NVIDIA driver on Ubuntu, use the ppa:graphics-drivers/ppa PPA.
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
ubuntu-drivers devices
sudo apt install nvidia-settings nvidia-graphics-drivers-535You will get the nvidia-smi again (a part of nvidia-utils installed as dependency)
Other method: NVIDIA Driver Installation Quickstart Guide
Supported products for the 535 driver version.
|
I tried to install Nvidia driver on my Asus laptop GU603H powered by rtx 3060 max-q mobile graphic card. I couldn't update my driver via GUI so I tried to tty1 using following steps:
1- purging all Nvidia related packages
2- install driver via .run file
At the final stage installation a message can be seen indicating successful process. However, I encounter this message after reboot:Also nvidia-smi command doesn't work, it shows message implies unsuccessful installation of drivers.
I'm new to Linux because of that can't whats going wrong here. How can I fix the problem? Any help such as links will be appreciated
|
Nvidia driver install on Ubuntu 22.04.3 TLS
|
Yaay, solved it. I changed the boot settings of BIOS to UEFI only and turned off CSM. Then, flashed the USB drive with the GPT partition scheme and ISO image. And it worked! Now I am at the archlinux terminal prompt.
|
Trying to install Archlinux on my laptop, I get a black screen after I pick Arch Linux archiso x86_64 UEFI CD and hitting Enter on the boot menu. I waited for about 10 minutes and the black screen persists.
I also tried hitting e and appending nomodeset or nomodeset i915.modeset=0 to the boot line before hitting Enter, yet the black screen persists.
Intel(R) HD Graphics 620 is the display adapter on my Lenovo Thinkpad T470 20HD laptop with UEFI boot mode.
Windows is already installed on the laptop. I flashed the USB drive in Windows using Rufus with an image of archlinux with the GPT partition scheme and the DD option because the USB drive with the ISO image option did not get me to this boot menu at all.
Any help would be much appreciated.
|
Black screen after booting archlinux installation program from usb drive
|
Solution found
lscfg |grep -i Graphic
+ lai0 U787F.001.DPM5MVH-P1-C2-T1 GXT135P Graphics Adapter
|
How to know wich video card is present in my aix workstation?
I have tried:
lsdev |grep video
lsdev|grep vga
prtconfbut no info.
I see a vga is installed on workstation.
|
AIX: show video card
|
The issue was that the nvidia-kernel package of Bumblebee did not install, due to my lacking libvdpau.
|
I've installed Bumblebee with Ryan McQuen's crazybee.sh script, described here, and I'm actually able to startx successfully now (because Bumblebee uses the on-board Intel graphics by default), but when I invoke optirun to run a program with the Nvidia card, I get:
[ERROR]Cannot access secondary GPU
Failed to initialize the NVIDIA kernel moduleThe "Turbo" light on the laptop, which indicates if the Nvidia card is on, turns on when I invoke optirun, which is good.
I've tried the solutions to this "Cannot access secondary GPU" problem on ArchWiki, but to no avail…
Also, my trackpad freezes upon logging into KDE, so I'm thinking this might involve an issue in xorg.conf.
I'm running slackware64-current with the 3.14.27 kernel.
There's a thread about the "failed to initialize kernel module" part of this issue here, but it's old, from 2004.
thanks
|
[ERROR]Cannot access secondary GPU…Failed to initialize the NVIDIA kernel module [closed]
|
The only meaningful advantage in buying an ATI or Nvidia card is to use them for hardware accelerated OpenGL rendering, generally in 3D. Otherwise they are just a waste of power and money.
The only thing which makes use of openGL on a general purpose GUI desktop are some DE specific special effects such as a "spinning cube" to switch workspaces, etc. Generally these are not super heavy and work fine with software acceleration, so having a proper 3D card is not going to matter much in this context.
Just go buy anything (checking the chip and linux driver status first). It does not matter. Again, do waste money (and hassles with proprietary drivers) getting a gaming/CAD card from ATI/Nvidia. That is competently and totally pointless. Anything made in the past 5 years (in fact, the past 10-15 years) will be just fine. It does not even particularly matter how much video memory it has on board.
|
I have server with displays and a keyboard-mouse for displaying network map status and for use as a shell and virtual console in my server room. Need a recent video card that is > $100 that can support the hardware requirements. I do not need to do any heavy rendering, but multiple open windows and graphics on Gnome2x desktop.
I am required to use CentOS 6.5. =-/
My hardware:
Dell PowerEdge R210
- Intel Core (i3 or i5, family6 model 37 stepping 2) 1.2GHz
- 4GB DDR3 ram
- 1 available PCIx slot (full size/height, it is on a riser/right-angle card)
2x Apple Cinema HD 30" (M9179LL/A)
I have tried an ATI HD3450 and several similar older cards. Double screwed with older ATI; the chipsets are unsupported by current drivers (proprietary and ElRepo), and the legacy drivers do not support current Xorg packages (so I have to downgrade etc. ad naseum).
I have also tried a Geforce 7300 GT that I cannibalized from an old Mac Pro. Nouveau driver does not like/recognize the card, NVidia driver install script says the adapter is not initialized (bad card? incompatible with Dell hw?)
I'm done with old used hardware. Any suggestions on a decent, inexpensive, currently supported video adapter that will drive these two displays at native 2560x1600 resolution?
|
Graphics card recommendation, Dell PowerEdge R210 & CentOS 6.5 [closed]
|
Solved.
Steps to solve:Unload previous v4l2loopback sudo modprobe -r v4l2loopback
git clone https://github.com/umlaeute/v4l2loopback/
make && sudo make install (if you're using secure boot, you'll need to sign it first https://ubuntu.com/blog/how-to-sign-things-for-secure-boot)
sudo depmod -a
Load the videodev drivers sudo modprobe videodev
sudo insmod ./v4l2loopback.ko devices=1 video_nr=2 exclusive_caps=1 Change video_nr based on how many cams you already got. Zero indexed
ls -al /dev/video* Use /dev/video[video_nr] with ffmpeg
sudo ffmpeg -f x11grab -r 60 -s 1920x1080 -i :0.0+1920,0 -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 -vf 'hflip,scale=640:360' /dev/video2
Go to https://webcamtests.com and test your dummy camProfit!If you want this to persist between boots, https://askubuntu.com/a/1024786/721238 should do it.
|
I have two commands, one that lets me record my screen to an AVI video file, and another which lets me stream a video file as a (fake) "webcam". This is really useful in apps that doesn't support selecting one screen to share (I'm looking at you Slack).
command #1 (https://askubuntu.com/a/892683/721238):
ffmpeg -y -f alsa -i hw:0 -f x11grab -framerate 30 -video_size 1920x1080 -i :0.0+1920,0 -c:v libx264 -pix_fmt yuv420p -qp 0 -preset ultrafast screenStream.avi
command #2 (https://unix.stackexchange.com/a/466683/253391):
ffmpeg -re -i screenStream.avi -map 0:v -f v4l2 /dev/video1
Why can't I just run both of these in parallel? Well, the second command starts streaming from the beginning of the file, whenever I use my "webcam". So I have to time it really close, otherwise there is latency.
I've tried lots and lots of solutions (including solutions with gstreamer instead of ffmpeg), can't get anything to work. This is my last hope.
How can I stream my desktop/screen to /dev/video1 as a (fake) "webcam" on Ubuntu?
|
How can I stream my desktop/screen to /dev/video1 as a (fake) "webcam" on Linux?
|
Nowadays GStreamer has really nice tracers mechanisms to measure latency as for the whole pipeline or for individual elements
This is how this can be done with gst-launch
env GST_DEBUG="GST_TRACER:7" \
GST_TRACERS="latency(flags=element+pipeline)" \
GST_DEBUG_FILE=./latency.log \
gst-launch-1.0 -v videotestsrc pattern=snow ! video/x-raw,width=640,height=480,framerate=30/1 ! videoconvert ! autovideosink./latency.log will contain a lot of logs like this:
...
0:00:06.072184000 40898 0x11d816920 TRACE GST_TRACER :0:: element-latency, element-id=(string)0x11e848210, element=(string)videotestsrc0, src=(string)src, time=(guint64)16000, ts=(guint64)6072172000;
0:00:06.072209000 40898 0x11d816920 TRACE GST_TRACER :0:: element-latency, element-id=(string)0x11e850440, element=(string)capsfilter0, src=(string)src, time=(guint64)28000, ts=(guint64)6072200000;
0:00:06.072224000 40898 0x11d816920 TRACE GST_TRACER :0:: element-latency, element-id=(string)0x11e824660, element=(string)videoconvert0, src=(string)src, time=(guint64)17000, ts=(guint64)6072217000;
0:00:06.072468000 40898 0x11d816920 TRACE GST_TRACER :0:: element-latency, element-id=(string)0x11e83f280, element=(string)autovideosink0, src=(string)src, time=(guint64)21594000, ts=(guint64)6072456000;
....So here you have a starting point to analyze latency (time=(guint64)... values) per element and experiment with different settings
More details in this article https://gstreamer.freedesktop.org/documentation/additional/design/tracing.html?gi-language=c#use-cases
|
I'm using a RTP pipeline to stream video from a camera over local network.
The pipeline is: camera > h264enc > RTP > UDP > receiver_and_display
How can I find out how the latency is composed?
|
Measuring latency in a GStreamer pipeline
|
I've got the rtsp streaming on '/dev/video1' working with the following command:
ffmpeg -i rtsp://admin:[emailprotected]:554/CH001.sdp -f v4l2 -pix_fmt yuv420p /dev/video1.
Thank you guys for the great support.
|
I would like to access my security camera that communicates through rtsp feed with an API that only supports a character video kind of entry (I'm new on linux, and I'm not sure if it's called "character video" the '/dev/video1' sort). I followed this post and I get the output below for the following command:
gst-launch-1.0 -v rtspsrc location=rtsp://admin:[emailprotected]:554/CH001.sdp ! v4l2sink device=/dev/video1...Progress: (request) Sending PLAY request...ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc3: Internal data flow error.
Additional debug info:
gstbasesrc.c(2943): gst_base_src_loop (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc3:
streaming task paused, reason not-linked (-1)How do i solve this error? Do you know any way other than gstream for this task?
PS: there are more on the message, I've just resumed to be more readable.
|
How to access a security camera and covert it to /dev/video?
|
I finally drop gstreamer and used ffmpeg without any more issues.
Command looks like this:
ffmpeg -fflags nobuffer -flags low_delay -rtsp_transport tcp -stimeout 1000000 -i <RTSP_stream_addr> -pix_fmt bgra -loglevel
|
I'm trying to forward video file to the framebuffer on my device that has no X. I'm using gstreamer with fbdevsink plugin.When I test it with
gst-launch-1.0 videotestsrc ! fbdevsinkit works perfectly.
However when I try to open any video file on my device with command
gst-launch-1.0 filesrc location=right_top1.mp4 ! fbdevsinkit stops working immediately with output
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:00.006988697
Setting pipeline to NULL ...
Freeing pipeline ...I cannot figure out what is going on, because even when I add debugging (-v --gst-debug-level=2) output is the same.
If it matters, I'm working on Nvidia Jetson Nano with Yocto OS.
Do you guys have any idea how to resolve or just debug it?
|
Got EOS from element "pipeline0" on gst fbdevsink
|
You need the x264 media player in Firefox by Cisco which is usually already built-in (do not install anything). Please check it by looking at the list of installed plugins within Firefox: Menu: Add-Ons -> Plugins
Reference: Firefox's Open-H.264 plugin
You could, now, however, be hit by this new bug here:
Bug: Firefox for Android no longer automatically downloads the Cisco OpenH264 plugin as of version 68
Since this change was introduced by Mozilla in version 68, you could downgrading to a lower version - perhaps the latest LTS version?! - and try playing the video. According to Mozilla (second reference above), an existing plugin will not be uninstalled which means that once you have the plugin (check the Firefox menu), you could try upgrading again.
If you have installed the mentioned plugin and still cannot play some HTML5 content, here is an entry in openSUSE Linux's support database:
SDB: Firefox MP4/H.264 Video Support
(in short, due to patent issues some packages are missing from openSUSE but the well-known Packman repository for SuSE provides the necessary libav* packages. They are also automatically pulled in if you enable the Packman repo and then install vlc from that repo (select it in yast2 sw_single) or use zypper).
|
I have been trying to play live streams on youtube, but it does not play any at all.
Everything it says its that the browser does not support it (html5).
So what packages are missing in order to being able to play it?
Kernel> 4.18.7 (64 bits)
Opensuse thumbleweed
Firefox 68.0.1 UPDATE
Thanks to Ned64, I discover that this is a issue related to the distro (suse) and its discussed the only method to solve hereありがとうございます
|
What packages are needed for playing live streams of youtube?
|
It was renamed to gstreamer-libav
|
While trying to solve an issue about loading MPEG videos in Matlab, I found several suggestions to install the FFmpeg plugin for Gstreamer.
However, I can't find this functionality on Debian 9 [1]. It was available on Debian 7, though [2].
This is not really an XY question. I'm still looking for alternatives for my issue with Matlab, but I am also interested in knowing what changed in Gstreamer or if I'm assuming anything wrong. Is there another package that supplies the functionality I was expecting from gstreamer0.10-ffmpeg?
[1] - https://packages.debian.org/search?suite=default§ion=all&arch=any&searchon=names&keywords=gstreamer1.0-ffmpeg
[2] - https://packages.debian.org/search?suite=default§ion=all&arch=any&searchon=names&keywords=gstreamer0.10-ffmpeg
|
What happened to gstreamer-ffmpeg and can I replace it?
|
I could not convert the video stream using GStreamer. But ffmpeg works for me. I started sending and receiving video streams using Ffmpeg for both remote and local machines.
For Local Linux Machine:
ffmpeg -i /dev/video0 -f mpegts udp://<ip>:<port>For Remote Linux Machine
ffmpeg -i udp://<ip>:<port> -f v4l2 /dev/video3NOTE: /dev/video3 is a virtual camera on the remote machine
|
I'm trying to share my computer's camera with the remote computer. In order to do this, I wanted to share my own computer's camera with the udp port(stream), take the stream on the remote computer and put it on the virtual camera. So I thought I could use my own camera on platforms like google meet with my remote computer.
My application steps are as follows;
I started camera stream from local pc (/dev/video0) with use gstream udpsink and I could get stream data on remote pc like below:
gst-launch-1.0 -e -v udpsrc port=5001 ! application/x-rtp, encoding-name=JPEG,payload=26 ! rtpjpegdepay ! jpegdec ! autovideosink I created a virtual camera on the remote pc like below:
sudo modprobe v4l2loopback exclusive_caps=1 video_nr=3 card_label="VirtualCAM"
At this point, I want to convert this stream data to video device. I tried to use v4l2sink device=/dev/video5 instead of autovideosink but I got some error.
Do you have any suggestion?
|
How to convert stream data which come over udp to video device?
|
It is perfectly possible to install multiple versions of a library in Debian. Pinning is the way to go. In this case I decided to obtain libgstreamer0.10 from Debian Unstable (running Debian Testing myself).
Create the file /etc/apt/sources.list.d/unstable.list with contents:
deb http://ftp.nl.debian.org/debian/ unstable main
deb-src http://ftp.nl.debian.org/debian/ unstable mainThen, create /etc/apt/preferences.d/unstable with contents:
Package: *
Pin: release a=unstable
Pin-Priority: 200Now run apt-get update. To check if everything went ok, type apt-cache policy libgstreamer0.10-0. It should report something like:
libgstreamer0.10-0:
Installed: (none)
Candidate: 0.10.36-1.5
Version table:
0.10.36-1.5 50
200 http://ftp.nl.debian.org/debian unstable/main amd64 Packages
100 /var/lib/dpkg/statusNote that this adds all packages from unstable with a lower priority. It is also possible to single out one or a few packages. See the documentation on pinning for more details.
PS For me the reason to do this was solving an RStudio dependency on libgstreamer-0.10: "rstudio: error while loading shared libraries: libgstreamer-0.10.so.0: cannot open shared object file: No such file or directory" (added these details so others may find this after a search).
PPS The link given by @jofel (partly) answers the why part of your question.
|
I have a computer that runs Debian Stretch which has Gstreamer 1.0 installed. I am trying to run a Processing sketch that uses the Processing video library which in turn relies on Gstreamer 0.10. This produces a runtime error because they removed a symbol gst_object_sink.
It seems a PITA to try to rebuild the Processing video library with different Java bindings for Gstreamer 1.0.
Thus the question: Is it possible to install on the same system a second version (0.10) of Gstreamer?The problem seems to be that libgstreamer0.10-0 appears in Wheezy, Jessie, SID, but not Stretch/Testing.... Why would that be, and how to fix it?
|
Is it possible to install both Gstreamer 0.10 and Gstreamer 1.0 at the same time?
|
The generic v4l2 standard doesn't know anything about "front-facing" and "back-facing" or "side-facing" cameras.
Such an attribute mostly (only?) makes sense when it comes to smartphones.
It doesn't make sense for my good old analog camera nor my USB Webcam nor my builtin laptop webcam, all of which I've used with v4l2.
It doesn't make much sense for my panoramic camera either (as the front/back dichotomy is too coarse in this case), but that is not supported by v4l2 anyhow...
So:v4l2 doesn't expose a standard property to communicate that camera orientationas a consequence, v4l2loopback does neitherI've never seen any GStreamer stream that would expose the camera orientation either, but it seems there was discussion about such a thing (and obviously it was turned down due to the lack of a standardized source https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/520)i guess the answer is: "no, not possible"
|
I've created a couple of v4l2loopback devices for use as virtual webcams, and have been able to get Chrome to recognize them via navigator.mediaDevices.enumerateDevices(). I've also been able to construct gstreamer pipelines to send video and image data to these virtual webcams. what I haven't been able to do is designate any of these devices as front-facing, as reported by InputDeviceInfo.getCapabilities(). is this possible to do with v4l2loopback parameters? is it possible to do by configuring my gstreamer pipeline somehow?
|
how do I set properties of a v4l2loopback device and make them visible to my web browser?
|
Ok, let's look at the codec. The codec description is a graph representation of the analog parts of the codec chip. Go through the description node by node, and make a picture as you do that (connection describes the input nodes), you are going to need it.
Your codec has actually 3 D/A converters, for Line Out, Speaker and Headphone (nodes 0x02, 0x03 and 0x04). However, ALSA in the default configuration can only drive one of these (for whatever reason). Each of the D/A Audio Outputs is then fed to a mixer (nodes 0x0c, 0x0d and 0x0e). The other input of each of these mixers is a feedback mixer (node 0x0b). The feedback mixer in turn gets signals from the most of the pins, including the inputs, and it has ALSA mixer controls associated with it (XXX Mic Playback Volume, XXX Mic Playback Switch).
Note that there's no "line in" and simple "mic" inputs, so I assume your "line in" is one of the Mic's, and your "mic" is the other Mic.
So: Try turning on Front Mic Playback Switch and Rear Mic Playback Switch in alsamixer, set volumes for Front Mic Playback Volume and Rear Mic Playback Volume, and this should allow you to monitor both inputs when playing back to either Line-Out or the Headphones. The last part seems to be important, because if I interpret the values correctly, ALSA has not enabled one of the three 2-input mixers. According to your amixer output, you seem to already have tried that, but increase the volume to make sure you are not missing it.
If that doesn't work, make another pastebin copy of /proc/asound/card*/codec\#* with these settings in effect and playback active, so we can debug what goes wrong.
|
I'm currently trying to get Mic-in and Line-in monitored on Headphones port and Line-Out, respectively.
I tried with aplay / arecord even with alsamixer configuration; it doesn’t work.
How can I make this work?
Here is what aplay -l and arecord -l gives me:
aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC662 rev1 Analog [ALC662 rev1 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC662 rev1 Digital [ALC662 rev1 Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC662 rev1 Analog [ALC662 rev1 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 2: ALC662 rev1 Alt Analog [ALC662 rev1 Alt Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0"line out" is not listed in aplay -l even though I have it in alsamixer
More details, output of :
cat /proc/asound/card*/codec#* :
https://pastebin.com/embed_js/X0Yir5mr
amixer :
https://pastebin.com/embed_js/r2B8X21V
|
Alsa: get audio from specific Input to specific Output stream for monitoring
|
´gstreamer-plugins-ugly' : You can search http://rpm.pbone.net/index.php3 and see the available repo´s : rpmfusion.repo, el.repo, nux.repo, atrpms.repo, repoforge.repo (= rpmforge.repo ).
One is compatible with the Redhat repo : That's rpmfusion : http://rpmfusion.org/ >>> http://download1.rpmfusion.org/free/el/updates/6/i386/rpmfusion-free-release-6-1.noarch.rpm
The other can cause trouble at an update. ( # yum update ).
|
What yum repository provides gstreamer-plugins-ugly (or/and other gstreamer plugins) for Red Hat Linux 6? And do repositories for CentOS and Fedora suit for Red Hat?
Reason of this question is that explicit query of RHEL repositories in Google leads to CentOS and Fedora repositories but as far as I know problems with binary compatibility between same applications in different Linux distributions may occur. Is that correct?
|
rhel repositories with gstreamer-plugins-ugly
|
Reworked answer based on new info; and a couple of quick edits subsequently -
What Happened to your Fedora Repos?
Did you edit out the fedora repos from your dnf repolist outputs?
Because you don't appear to have them...
And maybe lets confirm you are running fedora 23 :) cat /etc/redhat-release
Assuming you are truly missing them, do the following, otherwise jump ahead to the 'At least we have fedora repos' section
dnf install ftp://195.220.108.108/linux/fedora/linux/releases/23/Everything/x86_64/os/Packages/f/fedora-repos-23-1.noarch.rpm
# make sure they are enableddnf config-manager --set-enabled fedora updates updates-testing
# clean
dnf clean all# Optional, potentially large update, but I highly recommend it.
dnf updateIf you got a large update, particularly if the kernel, systemd, dnf / yum / rpm were updated then reboot before contuining:
At Least We Have Fedora Repos Now
The following commands will remove all of the rpmfusion repos and reinstall the latest version. Barring any errors on route, we should then be able to enable them appropriately.
If you get failures similar to those you received before:file /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-fedora from install of rpmfusion-free-release-22-1.noarch conflicts with file from package rpmfusion-free-release-23-0.1.noarchat any point, stop, and move right to the section on removing GPG keys from RPM, located at the bottom of this post.
Hopefully you don't have to do that it. It's not pleasant.
One caveat - I don't have any more fedora 23 machines; just F24, so I tested this code on one of those. Shouldn't be an issue, and I note a couple spots where it lead to a bit of uncertainty.
Run all commands as root. If at any point an uninstall command results in numerous 'dependent' packages also being designed for uninstallation, do not continue - that shouldn't happen.
# clean up dnf just because
dnf clean all# pull together a list of all installed rpmfusion packages
rpmflst=$(rpm -qa | grep rpmfusion)# for a sanity check, review that output; we're going to uninstall them all
echo $rpmflst#now remove - only click 'y' if it looks reasonable
dnf remove $rpmflst# Double check for any stragglers
cd /etc/yum.repos.d/
ll# Delete any .repo files (or mv them somewhere like ~/ to be safe) EXCEPT these EDIT - was 3, now 4 - forgot google:
#fedora.repo
#fedora-updates.repo
#fedora-updates-testing.repo
#google-chrome.repo# install 'free'
dnf install http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-23.noarch.rpm# install 'not-free'
dnf install http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-23.noarch.rpm# The first repo should be the only one needed for vlc, but we will enable a couple others (for depdendencies) as rpmfusion is harmless (I couldn't test this as vlc is in the rawhide repo for F24 beta)dnf config-manager --set-enabled rpmfusion-free-updates-testing rpmfusion-free rpmfusion-free-updates-testing rpmfusion-nonfree rpmfusion-nonfree-updates rpmfusion-nonfree-updates-testing# Some of those enables could fail - if they are empty, etc. For that type of error keep on going
# tidy up
dnf clean all# Download metadata (optional - its a check of the config without involving an install)
dnf makecache# assuming you've had no GPG errors, try installing vlc now
dnf install vlcGPG Conflict Error Resolution
Basically we need to just delete the GPG keys that report conflicts. There is a clear guide at the link below, and since this isn't the topic of your question, and I'm sick of typing, I'll just point you to it
https://blog.laimbock.com/2014/05/02/how-to-remove-an-imported-gpg-key-from-rpm/
Once the offending GPG key is removed, you should be able to retry the step that failed and continue from there.
If you subsequently get an error such as "missing GPG key for repo XYZ", then edit the repository file (I can't find CLI option that persists), as follows:
cd /etc/yum.repos.d/
# Find the file that contains the offending repo config (e.g. rpmfusion-free-updates-testing)
vi rpmfusion-free-updates-testing.repo
Find the line where gpgcheck=1 and change to gpgcheck=0Now you should be able to continue on.
|
I see the following repositories when I do a repolist:
1) google-chrome
2) rpmfusion-nonfree
3) rpmfusion-nonfree-updates-testingBut commands like yum install vlc and others line yum install gstream-plugins-ugly do not not work.
I tried installing the free rpmfusion repos
[root@dhcp223-30 yum.repos.d]# sudo rpm -ivh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
Retrieving http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
warning: /var/tmp/rpm-tmp.M25qoM: Header V4 RSA/SHA1 Signature, key ID 97f4d1c1: NOKEY
Preparing... ################################# [100%]
package rpmfusion-free-release-23-0.1.noarch (which is newer than rpmfusion-free-release-22-1.noarch) is already installed
file /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-fedora from install of rpmfusion-free-release-22-1.noarch conflicts with file from package rpmfusion-free-release-23-0.1.noarch
file /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-fedora-latest from install of rpmfusion-free-release-22-1.noarch conflicts with file from package rpmfusion-free-release-23-0.1.noarch
file /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-fedora-rawhide from install of rpmfusion-free-release-22-1.noarch conflicts with file from package rpmfusion-free-release-23-0.1.noarch
file /etc/yum.repos.d/rpmfusion-free-updates-testing.repo from install of rpmfusion-free-release-22-1.noarch conflicts with file from package rpmfusion-free-release-23-0.1.noarch
file /etc/yum.repos.d/rpmfusion-free-updates.repo from install of rpmfusion-free-release-22-1.noarch conflicts with file from package rpmfusion-free-release-23-0.1.noarchand then enabling it
[root@dhcp223-30 yum.repos.d]# sudo dnf config-manager --enablerepo=rpmfusion-free-release-stable
Error: Unknown repo: 'rpmfusion-free-release-stable'Please use the link to find the output of dnf repolist all
http://pastebin.com/AqgCdCSU
TIA
|
Unable to install video plugins for fedora 23
|
This was a result of one of its dependencies: font-config, which sets the default font for many things.
|
I recently installed gstreamer-ffmpeg-0.10.i686 on RHEL 7. As a result of this text in my java program has become slightly larger (maybe 2 or 3 font sizes), which is enough to mess with some of the UI elements. My guess is that gstreamer-ffmpeg or one of its dependencies is adjusting global font settings.
I tried doing a "yum history undo #" to revert back to before gstreamer-ffmpeg, but a few font changes persist (though not all).
gstreamer itself is already installed.
The culprit I assumed was the dependency: fontconfigs, but I unpacked the rpm and diff'ed the files inside with the originals (I have another image of this machine) and saw no changes, I've been looking through the file contents of each dependency, but I'm not seeing why these changes exist.
I also tried a "find /etc/ -mtime -1", but all of the files either seem unrelated to fonts or are the same as before. I tried the same on /var and /usr with the same results.
Most notably /etc/X11/xorg.conf is the same, including the fontpath value, though based on the modified time it was touched in some way by the installation.
I am looking to make use of gstreamer-ffmpeg, but I also want to change the fonts on my java app back the way it was previously, I'm assuming that gstreamer-ffmpeg or a dependency changes something somewhere, but I can't seem to find where.
|
Why does gstreamer-ffmpeg change the fonts for java applications?
|
I think I was having the same problem, or at least the same symptoms, on Ubuntu 20.10. It was affecting Clementine and gst-play-1.0 from the command line in the same way. Problem started after upgrading from 20.04. In my case it only affected a few albums in my collection out of ~680 ogg files. Turns out it was a specific encoder that is likely problematic. When running ogginfo on these files it would show the Vendor string as such:
Vendor: Xiphophorus libVorbis I 20010813 (1.0 rc2)
and an error like this:
WARNING: Hole in data (128 bytes) found at approximate offset 5265129 bytes. Corrupted Ogg.
So it could be that you are also experiencing a bug in an older encoder which previous versions of GStreamer ignored, but now have problems with.
I found that re-encoding the files with ffmpeg fixed the issue:
ffmpeg -i file.ogg -acodec copy newfile.ogg
I also posted basically the same details on the bug report you opened here:
https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/issues/848
|
Starting recently, about 2-3 weeks ago, I believe after some update, Clementine stopped playing OGG files. All other formats that I have play without any issues. At the same time VLC can play these same OGG files.
When it fails, Clementine pops an error window with the following message only: Internal data stream error.At the same time, this error message gets printed to the terminal:
(clementine:647736): GStreamer-CRITICAL **: 11:27:26.111: gst_pad_get_range_unchecked: assertion '!*buffer || res_buf == *buffer' failed(clementine:647736): GStreamer-CRITICAL **: 11:27:26.111: gst_mini_object_unref: assertion 'GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) > 0' failed
11:27:26.186 WARN unknown QTimeLine::start: already running
11:27:26.691 WARN unknown QTimeLine::start: already running
11:27:26.691 WARN unknown QTimeLine::start: already running
11:27:26.695 WARN unknown QTimeLine::start: already running Version info:Fedora 33 5.9.11-200.fc33.x86_64
clementine.x86_64: 1.4.0-3.rc1.20200617gitedb8c3b.fc33.1
gstreamer1.x86_64: 1.18.2-1.fc33
gstreamer1-libav.x86_64: 1.18.1-1.fc33
gstreamer1-plugin-openh264.x86_64: 1.16.2-2.fc33
gstreamer1-plugins-bad-free.x86_64: 1.18.2-1.fc33
gstreamer1-plugins-bad-free-extras.x86_64: 1.18.2-1.fc33
gstreamer1-plugins-base.x86_64: 1.18.2-1.fc33
gstreamer1-plugins-good.x86_64: 1.18.2-1.fc33
gstreamer1-plugins-good-gtk.x86_64: 1.18.2-1.fc33
gstreamer1-plugins-good-qt.x86_64: 1.18.2-1.fc33
gstreamer1-plugins-ugly.x86_64: 1.18.1-1.fc33
gstreamer1-plugins-ugly-free.x86_64: 1.18.2-1.fc33Any idea on what caused it and how to fix it?
|
Clementine with GStreamer can't play OGG files
|
In Pulseaudio: Make a "null" sink
pacmd load-module module-null-sink sink_name=public-sink-1 sink_properties=device.description=Public-Sink-1then use pavucontrol, command line options or application menu options (if available) to redirect all sound output you want to "reference" to this sink.
Every Pulseaudio sink has an associated .monitor source, so other applications can record or process audio from this associated source in the normal way (i.e., selecting the source with pavucontrol etc.).
|
I'd like to create a dynamically named audio source that can then be referenced by other programs on my system. For example something like this:
gst-launch-1.0 audiotestsrc ! alsapubsink name='Test Source'
and then I'd reference it in other programs like:
gst-launch-1.0 alsasrc device='Test Source' ! ... ! autoaudiosink
Of course there is no alsapubsink element. Is there any means of doing this sort of thing using either ALSA or Pulse, or perhaps other tools I'm not aware of?
|
How can I "publish" an audio source for consumption by other programs using ALSA and/or Pulse?
|
I have the same problem with Qt5.10.
I must go back to Qt5.8 to get it working.
|
I am using Fedora 28. I'm trying to run this code
from PyQt5.QtCore import QCoreApplication, QUrl
from PyQt5.QtMultimedia import QMediaContent, QMediaPlayer
from PyQt5.QtWidgets import QApplication
import sys
import osdef handle_state_change(state):
if state == QMediaPlayer.LoadingMedia:
print('loading')
if state == QMediaPlayer.LoadedMedia:
print('loading finished')
player.play()
if state == QMediaPlayer.EndOfMedia:
print('playing finished')
QCoreApplication.quit()app = QApplication(sys.argv)url = QUrl.fromLocalFile(os.path.abspath('./redalert.mp3'))content = QMediaContent(url)
player = QMediaPlayer()
player.mediaStatusChanged.connect(handle_state_change)
player.setVolume(50)
player.setMedia(content)app.exec()However, it throws this error
Got keys from plugin meta data ("gstreamermediaplayer")
QFactoryLoader::QFactoryLoader() checking directory path "/home/ziggs/PycharmProjects/mozart/venv/bin/mediaservice" ...
Cannot load library /home/ziggs/PycharmProjects/mozart/venv/lib/python3.6/site-packages/PyQt5/Qt/plugins/mediaservice/libgstmediaplayer.so: (/lib64/libQt5MultimediaGstTools.so.5: version `Qt_5_PRIVATE_API' not found (required by /home/ziggs/PycharmProjects/mozart/venv/lib/python3.6/site-packages/PyQt5/Qt/plugins/mediaservice/libgstmediaplayer.so))
QLibraryPrivate::loadPlugin failed on "/home/ziggs/PycharmProjects/mozart/venv/lib/python3.6/site-packages/PyQt5/Qt/plugins/mediaservice/libgstmediaplayer.so" : "Cannot load library /home/ziggs/PycharmProjects/mozart/venv/lib/python3.6/site-packages/PyQt5/Qt/plugins/mediaservice/libgstmediaplayer.so: (/lib64/libQt5MultimediaGstTools.so.5: version `Qt_5_PRIVATE_API' not found (required by /home/ziggs/PycharmProjects/mozart/venv/lib/python3.6/site-packages/PyQt5/Qt/plugins/mediaservice/libgstmediaplayer.so))"
defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"I have googled the error and tried installing the relevant plugins
dnf list qt5-qtmultimedia gstreamer-plugins-ugly
Letzte Prüfung auf abgelaufene Metadaten: vor 0:45:12 am Mo 18 Jun 2018 21:42:00 CEST.
Installierte Pakete
gstreamer-plugins-ugly.x86_64 0.10.19-27.fc28 @rpmfusion-free
qt5-qtmultimedia.x86_64 5.10.1-1.fc28 @anaconda
Verfügbare Pakete
gstreamer-plugins-ugly.i686 0.10.19-27.fc28 rpmfusion-free
qt5-qtmultimedia.i686 5.10.1-1.fc28 fedora
|
PyQt5 QMediaPlayer defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"
|
There is no requirement that the entries are stored in any particular order. Programs like ls typically sort them, and the shell also sorts them when it expands filenames. The sorting is determined by the locale, and in particular the LC_ALL or LC_COLLATE environment variables. You can create custom locales if you would like particular sorting orders, see these answers
To see the unsorted list of filenames use ls -fa (f for fast, a for all), which just lists the files in the order that readdir() presents them.
For the filenames shown in the question, just giving directoryname/* will give the filenames in the correct order to the player.
|
I have the following problem with the Gstreamer player gst123:
when I'm playing back folders gst123 does not play the files in alphabetical order. When I have my files ordered like this:
01.mp3
02.mp3
03.mp3I would expect the player to play the files back in this order, which it doesn't. I also did not really grasp which order it is actually using. gst123 does have some options to not play in order:
-z, --shuffle
Shuffle playlist before playing. -Z, --random
Play files in random order forever.I'm not using any of these.
Does anyone know this problem or a way to fix it?
I'm using gst123 version: 0.3.3-1+b3
The gstreamer plugins that I'm using are:
gstreamer1.0-plugins-ugly/testing,now 1.12.2-1 i386
gstreamer1.0-plugins-good/testing,now 1.12.2-1 i386
gstreamer1.0-plugins-base/testing,now 1.12.2-1 i386
gstreamer1.0-plugins-bad/testing,now 1.12.2-1 i386for some reasons I was not able to playback MP3 after some upgrades so I also installed:
gstreamer1.0-fluendo-mp3I'm using a:
Debian GNU/Linux buster/sid
Kernel: Linux 4.11.0-1-686-pae
|
gst123 does not play files in right order when playing back folders/
|
I realize this is an (relatively) old post, but I was just struggling with this in Ubuntu 20.04, and I though I'd share my workaround.
First, I was getting three error messages with the version of Sound Converter installed with Ubuntu 20.04:Failed to load module "appmenu-gtk-module"
id3mux gstreamer element not found
faac gstreamer element not foundI fixed the first by installing appmenu-gtk3-module. I fixed the second by installing gstreamer1.0-plugins-bad, but I got stuck on the third.
My workaround came from this this article, which describes a method for installing the latest (v. 4.0.1) version of Sound Converter. Here are the steps:Uninstall soundconverter:
sudo apt remove soundconverterAdd the xtradeb PPA:
sudo add-apt-repository ppa:xtradeb/appsUpdate:
sudo apt updateInstall soundconverter:
sudo apt install soundconverterUse Software & Updates to remove the PPA, because it includes a lot of other software that you may not want to update to the latest version.Note that the command line flags are different in the latest version of Sound Converter. You can see the new ones with:
soundconverter -hThere doesn't seem to be a manual entry for it.
With the latest version of Sound Converter and the dependencies above, I was able to do conversions from FLAC to OGG and MP3 without any errors, though I do still get the message:
ERROR: Disabling aac-enc output. Do you have "gst-plugins-bad" installed?I'm not doing any conversions to AAC, so I guess that's okay.
|
I am running Ubuntu 20.04 on a Lenovo Thinkpad X1 Tablet. A few years ago I wrote a bash script using soundconverter to transcode some of my music to mp3 files when I need to use a player that only has mp3 capability (like my car and my swimming player). I tried to use my script recently and got the following error
faac gstreamer element not foundI did some research and found that the faac plugin in not included in the Ubuntu 20.04 package gstreamer1.0-plugins-bad nor -ugly. But I also found that there is a lame (mp3 library) gstreamer plugin which is installed. Additionally I found that running soundconverter in gui mode could transcode to mp3 without problem. So I have three possible solutions but don't know how to pursue any of thermIf soundconverter can transcode to mp3 in gui, I am guessing there is some option that will enable this in batch mode. Does anyone know how?Is there a way to ask soundconverter to use gstreamer's lame plugin rather then the faac plugin to transcode to mp3?Does anyone know how to install the gstreamer faac plugin on Ubuntu 20.04?
|
Soundconverter error encoding to mp3
|
For the "invalid ROS_HOSTNAME" is connected with the environment variables.
Look at this page:
https://wiki.ros.org/ROS/EnvironmentVariables
The assumption here is that your Cam is compatible with ROS.
Have you try this before calibration:
roscd gscam
cd bin
export GSCAM_CONFIG="v4l2src device=/dev/video0 ! video/x-raw-rgb,framerate=30/1 ! ffmpegcolorspace"
rosrun gscam gscamHave you try camera_calibration package:
http://wiki.ros.org/camera_calibrationI am not sure if gscam is compatible with noetic.
https://index.ros.org/r/gscam/#noeticBack then people have solved this by making sure gscam dependencies have met, and adding
"<param if="$(arg GST10)" name="gscam_config" value="v4l2src.....".
Have this looked:
https://github.com/ros-drivers/gscam/issues/25
https://github.com/ros-drivers/gscam/tree/master/examplesAlso, consider closing :::https://stackoverflow.com/questions/65865736/ros-camera-calibration
So we don't answer the same question twice.
I had indigo and I know how painful the compatibility issues are.
Good luck!
|
I have a VM with ROS Noetic installed and I want to run a camera calibration on my USB Webcam. I followed the following guide and for the launcher, I put the following code:
<launch>
<!-- This launchfile should bring up a node that broadcasts a ros image
transport on /webcam/image_raw --> <arg name="DEVICEl" default="/dev/video0"/>
<!-- The GStreamer framerate needs to be an integral fraction -->
<arg name="FPS" default="30/1"/>
<arg name="PUBLISH_FRAME" default="false"/> <node ns="left" name="gscam_driver_v4l" pkg="gscam" type="gscam" output="screen">
<param name="camera_name" value="default"/>
<param name="camera_info_url" value="package://gscam/examples/uncalibrated_parameters.ini"/>
<param name="gscam_config" value="v4l2src device=$(arg DEVICEl) ! video/x-raw-rgb,framerate=$(arg FPS) ! ffmpegcolorspace"/>
<param name="frame_id" value="/v4l_frame_l"/>
<param name="sync_sink" value="true"/>
</node> <node if="$(arg PUBLISH_FRAME)" name="v4l_transform" pkg="tf" type="static_transform_publisher" args="1 2 3 0 -3.141 0 /world /v4l_frame 10"/>
</launch>I try to launch it and get the following response:
... logging to /home/dragonros/.ros/log/e62adeac-5d96-11eb-b879-09066182755f/roslaunch-ubuntu-42560.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.invalid ROS_HOSTNAME (an empty string)
invalid ROS_HOSTNAME (an empty string)
started roslaunch server http://ubuntu:35479/SUMMARY
========PARAMETERS
* /left/gscam_driver_v4l/camera_info_url: package://gscam/e...
* /left/gscam_driver_v4l/camera_name: default
* /left/gscam_driver_v4l/frame_id: /v4l_frame_l
* /left/gscam_driver_v4l/gscam_config: v4l2src device=/d...
* /left/gscam_driver_v4l/sync_sink: True
* /rosdistro: noetic
* /rosversion: 1.15.9NODES
/left/
gscam_driver_v4l (gscam/gscam)ROS_MASTER_URI=http://localhost:11311process[left/gscam_driver_v4l-1]: started with pid [42574]
[ WARN] [1611445425.340701580]: invalid ROS_HOSTNAME (an empty string)
[ INFO] [1611445425.361034554]: Using gstreamer config from rosparam: "v4l2src device=/dev/video0 ! video/x-raw-rgb,framerate=30/1 ! ffmpegcolorspace"
[ INFO] [1611445425.366515919]: camera calibration URL: package://gscam/examples/uncalibrated_parameters.ini
[ INFO] [1611445425.366725052]: Loaded camera calibration from package://gscam/examples/uncalibrated_parameters.ini(gscam:42574): GStreamer-WARNING **: 15:43:45.455: 0.10-style raw video caps are being created. Should be video/x-raw,format=(string).. now.
[ INFO] [1611445425.455679084]: Time offset: 1611418553.717
[ INFO] [1611445425.555216304]: Publishing stream...
[ INFO] [1611445425.555412447]: Started stream.
[ERROR] [1611445425.555446013]: Could not get gstreamer sample.
[ INFO] [1611445425.555455586]: Stopping gstreamer pipeline...
[ INFO] [1611445425.557306732]: GStreamer stream stopped!
[ INFO] [1611445425.557374812]: Cleaning up stream and exiting...
[left/gscam_driver_v4l-1] process has finished cleanly
log file: /home/dragonros/.ros/log/e62adeac-5d96-11eb-b879-09066182755f/left-gscam_driver_v4l-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor...
... shutting down processing monitor complete
doneIt says that it could not get gstreamer sample. Also, for some reason, when I plug my camera in to the computer, it creates both /dev/video0 and /dev/video1. This also what I get if I run rosrun gscam gscam. What should I do?
|
ROS Camera Calibration GStreamer Error
|
I was able to work around this problem by changing the SAL_USE_VCLPLUGIN environment variable in the file /etc/profile.d/libreoffice-still.sh. Originally, all lines in that file were uncommented, which I think made SAL_USE_VCLPLUGIN default to gtk3. I seemed to fix the problem by uncommenting the export SAL_USE_VCLPLUGIN=gen line. Unfortunately this option makes the user interface not look as good, although it still seems to be functional.
pre-2021 note
This answer has been updated. Prior to 2021, one of the options in /etc/profile.d/libreoffice-still.sh was export SAL_USE_VCLPLUGIN=gtk. That option made embedded videos play well and made the user interface look nice. However, this option is no longer available. I also tried adding it manually but it doesn't seem to have the same effect.
references:https://ask.libreoffice.org/en/question/200288/impress-video-playback-mp4-flickering-ubuntu-18-19-lo-6/https://wiki.archlinux.org/index.php/LibreOffice#Theme
|
I'm using LibreOffice Impress on Arch Linux to make a presentation. When I embed a video into my presentation, the video initially plays fine, but gets distorted after a few seconds. The distortion seems to involve a combination of screen tearing, flickering, and other things. I read here that LibreOffice requires gstreamer to play videos, so I have installed Arch's gstreamer package as well as all of the associated plugins packages. I also tried using different video formats and different codecs, but that didn't help.
|
LibreOffice distorts embedded videos
|
GStreamer comes in two primary release flavours: the old, deprecated, unmaintained 0.10 release series and the new, shiny 1.x releases.
Some Linux distributions or software providers may still make the older releases available for compatibility with old software (although I can't find any Linux distribution that still provides GStreamer 0.10 in their current distribution repositories). For more info about the 0.10 series, see e.g. Wikipedia.
Release 1.0 was made in the second half of 2012, and this is the current series of releases that people should be using (see a bit further down on that Wikipedia page I just linked to).
It is important to know what major release of an API like GStreamer one is using, as the API usually introduces incompatible changes with the change of major versions. This is why all GStreamer packages are tagged with 1; to tell them apart from any old version 0.10 package that may still be in circulation, and to also distinguish them from future versions 2.x and 3.x etc.
See also the GStremaer FAQ about the differences between versions 0.10 and 1.0.
|
Why are GStreamer packages always named gstreamer1-*? What is 1? Why not just gtsreamer-*?
|
Why are GStreamer packages always named "gstreamer1-*"?
|
I was almost ready to submit my question and I did one more Internet search. I found this tutorial which shows several extra flags added to the udpsrc and udpsink elements. Adding the following flags got the example working so that I could see video and hear sound via RTSP:host=127.0.0.1 on all udpsink elements
address=127.0.0.1 on all udpsource elementsI think the other flags in that tutorial that I left off are likely the defaults.
|
I am trying to run the rtpbin example an Ubuntu 21.10 VirtualBox VM with GStream 1.18.5.I set up GStreamer and have been able to run many of the basic and playback tutorials.
I've also read through a good portion of Application Developer Manual.Doing everything from C code seems straightforward but the rtpbin example uses gst-launch-1.0 (covered in one of the basic tutorials).
I couldn't get the rtpbin example to run without errors initially:ffenc_h263 and ffdec_h263 (WARNING: erroneous pipeline: no element "ffenc_h263"), so I replaced them with avenc_h263 and avdec_h263, respectively
v4l2srcwas looking for a device that wasn't available in /dev so I switched to videotestsrc.To make sure these substitutions weren't a problem, I got rid of the RTSP and UDP stuff and checked by running:
gst-launch-1.0 videotestsrc ! videoconvert ! avenc_h263 ! rtph263pay \
! rtph263depay ! avdec_h263 ! xvimagesinkand saw the "bars" video. I also ran
gst-launch-1.0 audiotestsrc ! amrnbenc ! rtpamrpay ! rtpamrdepay ! amrnbdec ! alsasinkand heard that annoying test tone. Based on this, I think the issue is with UDP and RTSP.
Running
gst-launch-1.0 rtpbin name=rtpbin \
videotestsrc ! videoconvert ! avenc_h263 ! rtph263pay ! rtpbin.send_rtp_sink_0 \
rtpbin.send_rtp_src_0 ! udpsink port=5000 \
rtpbin.send_rtcp_src_0 ! udpsink port=5001 sync=false async=false \
udpsrc port=5005 ! rtpbin.recv_rtcp_sink_0 \
audiotestsrc ! amrnbenc ! rtpamrpay ! rtpbin.send_rtp_sink_1 \
rtpbin.send_rtp_src_1 ! udpsink port=5002 \
rtpbin.send_rtcp_src_1 ! udpsink port=5003 sync=false async=false \
udpsrc port=5007 ! rtpbin.recv_rtcp_sink_1shows
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
0:00:59.0 / 99:99:99 # This is counting upThen in a different window, I run
gst-launch-1.0 rtpbin name=rtpbin \
udpsrc caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263-1996" \
port=5000 ! rtpbin.recv_rtp_sink_0 \
rtpbin. ! rtph263depay ! avdec_h263 ! xvimagesink \
udpsrc port=5001 ! rtpbin.recv_rtcp_sink_0 \
rtpbin.send_rtcp_src_0 ! udpsink port=5005 sync=false async=false \
udpsrc caps="application/x-rtp,media=(string)audio,clock-rate=(int)8000,encoding-name=(string)AMR,encoding-params=(string)1,octet-align=(string)1" \
port=5002 ! rtpbin.recv_rtp_sink_1 \
rtpbin. ! rtpamrdepay ! amrnbdec ! alsasink \
udpsrc port=5003 ! rtpbin.recv_rtcp_sink_1 \
rtpbin.send_rtcp_src_1 ! udpsink port=5007 sync=false async=falseand see
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClockI expect to see some UDP ports open (5000, 5001, 5002, 5003, 5005, and 5007). Sure enough, running netstat shows:
rtsp@rtsp-VirtualBox:~$ sudo netstat -apn | grep -w 500[0-9]
udp 0 0 0.0.0.0:5000 0.0.0.0:* 7076/gst-launch-1.0
udp 0 0 0.0.0.0:5001 0.0.0.0:* 7076/gst-launch-1.0
udp 0 0 0.0.0.0:5002 0.0.0.0:* 7076/gst-launch-1.0
udp 0 0 0.0.0.0:5003 0.0.0.0:* 7076/gst-launch-1.0
udp 0 0 0.0.0.0:5005 0.0.0.0:* 6862/gst-launch-1.0
udp 0 0 0.0.0.0:5007 0.0.0.0:* 6862/gst-launch-1.0 To make sure all the ports were workingI installed from snap rtsp-test-server and VLC
I was able to stream video over the ports provided by rtsp-test-server.
I suppose this isn't a perfect test since TCP ports are being used instead of UDP but it was easy to test so I gave it a shot.But I'm not seeing any video or hearing any sound. Can someone point out my error(s)?
|
Why does rtpbin example from Gstreamer not work?
|
Solution found: before launch gstreamer the card must be "unmute" with this command.
v4l2-ctl -d /dev/video0 --set-ctrl mute=0
|
With this script
#!/bin/sh
videodevice="/dev/video0"
alsadevice="hw:2,0"gst-launch-1.0 -q v4l2src device="$videodevice" do-timestamp=true norm="PAL" pixel-aspect-ratio=1 \
! video/x-raw,format=YUY2,framerate=25/1,width=720,height=576 \
! queue max-size-buffers=0 max-size-time=0 max-size-bytes=0 \
! mux. \
alsasrc device="$alsadevice" do-timestamp=true \
! audio/x-raw,format=S16LE,rate=48000,channels=2 \
! queue \
max-size-buffers=0 max-size-time=0 max-size-bytes=0 \
! mux. matroskamux name=mux \
! queue max-size-buffers=0 max-size-time=0 max-size-bytes=0 \
! filesink location=vhs.mkvThe video is ok, but audio is mute.
I have checked with alsamixer and pavucontrol and audio capture volume is OK.
With mencoder audio works fine using the options
forceaudio:immediatemode=0Something similar with gstreamer?
|
gstreamer and vhs capture: video ok, but sound mute
|
It turns out the were two issues with what I was doing:Gstreamer does sometimes support mp3 files, see this link for the formats it does support. Replacing the filesrc with audiotestsrc ! convertaudio fixes it, although I'm not sure why it needs to be converted.
Because the Bluetooth device is an audio target I needed to use bluez_sink instead of bluez_source.This is the final command that manages to play audio on the speaker.
gst-launch-1.0 audiotestsrc ! pulsesink device=bluez_sink.FC_58_FA_68_B4_8B
|
I'm using a Raspberry pi zero with a Bluetooth dongle and I'm trying to play an mp3 file to a Bluetooth speaker. I managed to get them both connected after a lot of trying, this is the full list of commands I execute to get everything working:
rfkill unblock 0
sudo hciconfig hci0 up
sudo hciconfig hci0 piscan
pulseaudio -k
pulseaudio -D
bluetoothctl -a
scan on
connect 30:95:E3:95:46:F7
exitTo now stream the audio to the speaker I'm using the following gstreamer command:
gst-launch-1.0 filesrc location=song.mp3 ! pulsesink device=bluez_source.30_95_E3_95_46_F7And that results in the following error:
pi@raspberrypi:~ $ gst-launch-1.0 filesrc location=song.mp3 ! pulsesink device=bluez_source.30_95_E3_95_46_F7
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstPulseSink:pulsesink0: The stream is in the wrong format.
Additional debug info:
gstaudiobasesink.c(1119): gst_audio_base_sink_preroll (): /GstPipeline:pipeline0/GstPulseSink:pulsesink0:
sink not negotiated.
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...song.mp3 is a normal audio file, I can play it just fine with my phone, vlc and windows media player. The speaker also works fine with my phone.
What can I do to solve this issue?
|
Gstreamer ' The stream is in the wrong format.'
|
You can almost do what you want with hexdump, but I can't figure out how to get quotes & single backslashes into the format string. So I do a little post-processing with sed. As a bonus, I've also indented each line by 4 spaces. :)
hexdump -e '16/1 "_x%02X" "\n"' filename | sed 's/_/\\/g; s/.*/ "&"/'Edit
As Cengiz Can pointed out, the above command line doesn't cope well with short data lines. So here's a new improved version:
hexdump -e '16/1 "_x%02X" "\n"' filename | sed 's/_/\\/g; s/\\x //g; s/.*/ "&"/'As Malvineous mentions in the comments, we also need to pass the -v verbose option to hexdump to prevent it from abbreviating long runs of identical bytes to *.
hexdump -v -e '16/1 "_x%02X" "\n"' filename | sed 's/_/\\/g; s/\\x //g; s/.*/ "&"/'
|
I have a binary file I would like to include in my C source code (temporarily, for testing purposes) so I would like to obtain the file contents as a C string, something like this:
\x01\x02\x03\x04Is this possible, perhaps by using the od or hexdump utilities? While not necessary, if the string can wrap to the next line every 16 input bytes, and include double-quotes at the start and end of each line, that would be even nicer!
I am aware that the string will have embedded nulls (\x00) so I will need to specify the length of the string in the code, to prevent these bytes from terminating the string early.
|
How to dump a binary file as a C/C++ string literal?
|
The traditional BSD hexdump utility uses the platform's endianness, so the output you see means your machine is little-endian.
Use hexdump -C (or od -t x1) to get consistent byte-by-byte output irrespective of the platform's endianness.
|
On my machine I get the following output when I run these commands:
$ echo foos > myfile
$ hexdump myfile
6f66 736f 000aThe output from hexdump is little-endian. Does this mean that my machine is little-endian, or does hexdump always use little-endian format?
|
Does hexdump respect the endianness of its system?
|
There are lots of ways of storing numbers - ASCII (which can have locale specific variants, such as using ',' to separate fractional part OR as a thousands grouping), binary integer (variable number of bits)/float/double (all of which may vary depending on endian architecture and whether software producing the file formalises the representation), BCD (uncompressed, packed, fixed point and other variants), Bi-quinary coded decimal ...
There is no standard.
|
The binary file has strings and some numbers, If I do
od -c filename or strings filename, I can see the strings properly. But, what about numbers? They are in some weird format.
The text after doing od -c filename is like this:0000000 036 \0 032 004 S D \0 \0 \0 \0 s e q 1
0000020 \0 \0 \0 \0 \0 \0 \0 \0 \t \0 ó 002 3 001
0000040 & \0 032 \f O 2 006 \0 \0 \0 o s f u s 1
0000060 ó 002 3 001 ÿ \r \0 \0 \t \0 \0 @ 3 ×
0000100 233 º 004 \0 é 003 \0 \0 & \0 032 \f O 2 7 \0
0000120 \0 \0 o s f e u 1 ó 002 3 001 é 235
0000140 \0 \0 035 003 \0 @ 3 × 233 º 004 \0 Ñ \a \0 \0
0000160 ä \0 032 \f O r E \0 \0 \0 o s f a p 1How to decipher this?
I even tried hexdump -C filename
The output is like this:00000000 1e 00 1a 04 53 44 00 00 00 00 73 65 71 31 20 20 |....SD....seq1 |
00000010 20 20 00 00 00 00 00 00 00 00 09 00 f3 02 33 01 | ..........ó.3.|
00000020 26 00 1a 0c 4f 32 06 00 00 00 6f 73 66 75 73 31 |&...O2....osfus1|
00000030 20 20 f3 02 33 01 ff 0d 00 00 09 00 00 40 33 d7 | ó.3.ÿ......@3×|
00000040 9b ba 04 00 e9 03 00 00 26 00 1a 0c 4f 32 37 00 |.º..é...&...O27.|
00000050 00 00 6f 73 66 65 75 31 20 20 f3 02 33 01 e9 9d |..osfeu1 ó.3.é.|
00000060 00 00 1d 03 00 40 33 d7 9b ba 04 00 d1 07 00 00 |.....@3×.º..Ñ...|
00000070 e4 00 1a 0c 4f 72 45 00 00 00 6f 73 66 61 70 31 |ä...OrE...osfap1|To clarify, the main file which is a regular file had one attribute which was displaying is some weird format, so we are looking at the raw/binary file.
Doing octal dump on the regular file, resolved the viewing problem.
With grep 'id=123' regular_file | head -1 | od -c, I was able to see what number was in there. I was expecting 1, it showed to us as 001.
|
How to interpret an octal or hex dump of a binary file?
|
Like in the standard od command or hd, it means all the elided lines are the same as the preceding line. You can pass -v to make it display those lines anyway. From hexdump(1):The -v option causes hexdump to display all input data. Without the -v option, any number of groups of output lines, which would be identical to the immediately preceding group of output lines (except for the input offsets), are replaced with a line comprised of a single asterisk.
|
I've been doing an exersice in attempt to understanding some of what's going on under the hood of a program. I wrote a small C program, and compiled it on i386 Linux (Ubuntu 12.04) using gcc. I then did a hexdump -C on the output to text file. I noticed that there were some gaps on the offset with an *:
00000670 00 3f 1a 3b 2a 32 24 22 1c 00 00 00 40 00 00 00 |.?.;*2$"....@...|
00000680 94 fd ff ff 05 01 00 00 00 41 0e 08 85 02 42 0d |.........A....B.|
00000690 05 03 01 01 c5 0c 04 04 38 00 00 00 60 00 00 00 |........8...`...|
000006a0 80 fe ff ff 61 00 00 00 00 41 0e 08 85 02 41 0e |....a....A....A.|
000006b0 0c 87 03 41 0e 10 86 04 41 0e 14 83 05 4e 0e 30 |...A....A....N.0|
000006c0 02 4a 0e 14 41 0e 10 c3 41 0e 0c c6 41 0e 08 c7 |.J..A...A...A...|
000006d0 41 0e 04 c5 10 00 00 00 9c 00 00 00 b4 fe ff ff |A...............|
000006e0 02 00 00 00 00 00 00 00 10 00 00 00 b0 00 00 00 |................|
000006f0 a2 fe ff ff 04 00 00 00 00 00 00 00 00 00 00 00 |................|
00000700 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000f10 00 00 00 00 ff ff ff ff 00 00 00 00 ff ff ff ff |................|
00000f20 00 00 00 00 00 00 00 00 01 00 00 00 10 00 00 00 |................|
00000f30 0c 00 00 00 d4 82 04 08 0d 00 00 00 cc 85 04 08 |................|
00000f40 f5 fe ff 6f ac 81 04 08 05 00 00 00 2c 82 04 08 |...o........,...|
00000f50 06 00 00 00 cc 81 04 08 0a 00 00 00 54 00 00 00 |............T...|
00000f60 0b 00 00 00 10 00 00 00 15 00 00 00 00 00 00 00 |................|
00000f70 03 00 00 00 f4 9f 04 08 02 00 00 00 20 00 00 00 |............ ...|
00000f80 14 00 00 00 11 00 00 00 17 00 00 00 b4 82 04 08 |................|
00000f90 11 00 00 00 ac 82 04 08 12 00 00 00 08 00 00 00 |................|
00000fa0 13 00 00 00 08 00 00 00 fe ff ff 6f 8c 82 04 08 |...........o....|
00000fb0 ff ff ff 6f 01 00 00 00 f0 ff ff 6f 80 82 04 08 |...o.......o....|
00000fc0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000ff0 00 00 00 00 28 9f 04 08 00 00 00 00 00 00 00 00 |....(...........|
00001000 26 83 04 08 36 83 04 08 46 83 04 08 56 83 04 08 |&...6...F...V...|
00001010 00 00 00 00 00 00 00 00 47 43 43 3a 20 28 55 62 |........GCC: (Ub|
00001020 75 6e 74 75 2f 4c 69 6e 61 72 6f 20 34 2e 36 2e |untu/Linaro 4.6.|
00001030 33 2d 31 75 62 75 6e 74 75 35 29 20 34 2e 36 2e |3-1ubuntu5) 4.6.|
00001040 33 00 00 2e 73 79 6d 74 61 62 00 2e 73 74 72 74 |3...symtab..strt|
00001050 61 62 00 2e 73 68 73 74 72 74 61 62 00 2e 69 6e |ab..shstrtab..in|
00001060 74 65 72 70 00 2e 6e 6f 74 65 2e 41 42 49 2d 74 |terp..note.ABI-t|
00001070 61 67 00 2e 6e 6f 74 65 2e 67 6e 75 2e 62 75 69 |ag..note.gnu.bui|
00001080 6c 64 2d 69 64 00 2e 67 6e 75 2e 68 61 73 68 00 |ld-id..gnu.hash.|
00001090 2e 64 79 6e 73 79 6d 00 2e 64 79 6e 73 74 72 00 |.dynsym..dynstr.|My question is, how should I interpret the *? I assume it means there's a gap in the file, but then the question turns to why does a gap exist? Is this part of the standard format of an ELF file?
|
What does `*` mean using hexdump -C?
|
Try hexdump -v -e '/1 "%02X\n"'. That displays one hex byte per line, so the line output buffering won't stop the line from being displayed.
Then you only have to type A and return to know the hex value for A. You still have to type return, because the shell buffers also does line buffering on the input.
man ascii also works. :-)
|
If I opened hexdump without any argument in the terminal:
hexdumpWhen I type something in the terminal and press Enter, hexdump will display the hex values for whatever characters I type.
But hexdump will only display the hex values if I type 16 characters, for example:Here, I typed the character a 15 times and I pressed Enter(so hexdump received 16 characters (15a + \n)).
But if I type less than 16 characters, for example:Here, I typed the character a 14 times and I pressed Enter(so hexdump received 15 characters (14a + \n)). And in this case hexdump did not display anything.
Can I make hexdump display the hex values for whatever length of characters it receives instead of it waiting for 16 characters to be received?
Note: I do not want to "use options both for hexdump and xxd to display one byte as hex per line" (as suggested in a comment here). What I want to do basically is for example to know what the hex value for A without having to type an extra 15 characters to get it.
|
How to make hexdump not wait for 16 characters from stdin to display their hex values?
|
You can extract the byte values in the text segment with:
$ objcopy -O binary -j .text f.o foThe -O binary option:objcopy can be used to generate a raw binary file by using an output target of binary (e.g., use -O binary). When objcopy generates a raw binary file, it will essentially produce a memory dump of the contents of the input object file. All symbols and relocation information will be discarded. The memory dump will start at the load address of the lowest section copied into the output file.The -j .text option:-j sectionpattern
--only-section=sectionpattern
Copy only the indicated sections from the input file to the output file. This option may be given more than once.
Note that using this option inappropriately may make the output file unusable. Wildcard characters are accepted in sectionpattern.The end result is a file (fo) with the binary values of only the .text section, that is the executable code without symbols or relocation information.
And then print the hex values of the fo file:
$ od -An -v -t x1 fo
55 48 89 e5 48 89 7d f8 48 89 75 f0 48 8b 45 f8
8b 10 48 8b 45 f0 8b 00 0f af d0 48 8b 45 f8 89
10 90 5d c3
|
Say for example I've got this C function:
void f(int *x, int *y)
{
(*x) = (*x) * (*y);
}When saved to f.c, compiling with gcc -c f.c produces f.o. objdump -d f.o gives this:
f.o: file format elf64-x86-64Disassembly of section .text:0000000000000000 <f>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 48 89 7d f8 mov %rdi,-0x8(%rbp)
8: 48 89 75 f0 mov %rsi,-0x10(%rbp)
c: 48 8b 45 f8 mov -0x8(%rbp),%rax
10: 8b 10 mov (%rax),%edx
12: 48 8b 45 f0 mov -0x10(%rbp),%rax
16: 8b 00 mov (%rax),%eax
18: 0f af d0 imul %eax,%edx
1b: 48 8b 45 f8 mov -0x8(%rbp),%rax
1f: 89 10 mov %edx,(%rax)
21: 5d pop %rbp
22: c3 retq I'd like it to output something more like this:
55 48 89 e5 48 89 7d f8 48 89 75 f0 48 8b 45 f8 8b 10 48 8b 45 f0 8b 00 0f af d0 48 8b 45 f8 89 10 5d c3I.e., just the hexadecimal values of the function. Is there some objdump flag to do this? Otherwise, what tools can I use (e.g. awk, sed, cut, etc) to get this desired output?
|
Get hex-only output from objdump
|
Unix, of which Linux is just one flavour, has a long and rich history. It has not been developed by a single company or group, nor following a master plan, and has evolved by adaption to many niches. You can find many examples where multiple tools cover similar or the same functionality. They have been implemented by different people at different times for similar purposes; check their manpages for hints.
Thanks to the rise of Open Source in general, and the possibilities of the information age, we can enjoy the benefit of many of these tools being generally available to our use. The attempt to merge them into one will result in one more being available.Enjoy; these are amazing times!
A selection for further reading:https://en.wikipedia.org/wiki/History_of_Unix
http://www.catb.org/esr/writings/taoup/html/historychapter.html
http://www.catb.org/esr/writings/cathedral-bazaar/
https://www.levenez.com/unix/
|
What is the difference between the od, hd, hexdump and xxd commands ?
They are all commands for dumping files and they can all dump it in various formats such as hexadecimal, octal or binary. Why creating different programs ?
|
What is the difference between the od, hd, hexdump and xxd commands?
|
xxd can also convert the other way
xxd -r
|
I know that xxd is used to convert texts to hexdump but I want to do the opposite: convert an hex dump to text! Is there some command that I can use? Thanks for the help!
|
How to convert hexdump to text?
|
As others have pointed out, this is because hexdump -x treats the files as containing 2-byte words. On little endian systems (almost all desktops are), this means the bytes will be swapped before they are displayed. This means that the byte values are printed in pairs and that the order of these bytes are swapped. Since you have an odd number of bytes, hexdump just adds a zero to make up the final pair. The zero is then swapped with the 0a. This is documented behaviour for hexdump, so it is not lying to you!
Using hexdump -C is a better command to get a formatted output that shows the bytes in the order they are in the file. Also the 0a is a new line and was probably added quietly by whatever created the file (vim does this by default). Eg, echo will always add a new line if you don't tell it not to. In bash:
echo -e '\xcf\x9e' | hexdump -Cwill give the same result, but suppressing the newline with -n will give what you expected:
echo -ne '\xcf\x9e' | hexdump -CTo stop vim from adding the newline:
:set noeol
:set binary
|
I have a file I created (in vim), for testing purposes (testing UTF-8 output in an SSH client). Odd things, however, are happening to this file.
I wondered what bytes were in the file, so I used hexdump:
username@computername:~$ hexdump -x intl.txt
0000000 9ecf 000a
0000003Ok, there's four bytes in there, How the 00 and the 0a got in there, I'm not clear, but whatever. Here's where it gets weird, though:
username@computername:~$ ls -al intl.txt
-rw-rw-r-- 1 username username 3 Mar 26 15:14 intl.txtWait, it's three bytes? What's going on here?
As if that wasn't odd enough, hexdump -C gives very different output:
username@computername:~$ hexdump -C intl.txt
00000000 cf 9e 0a |...|
00000003Vim is also a bit confused about the file. When I start it up, it gives this in the status line:
"intl.txt" 1L, 3CUp top, however, I get this (using set list):
Ϟ$
~
~
~
~So, it thinks there's 3 characters, but only prints one. I could understand if it printed the koppa and a blank line under it...
|
Why do ls and hexdump disagree about my file size?
|
Failing a dump program with suitable dump options, you can always cobble something together by using both hexdump and xdd and then joining the output with paste. Its not pretty, but using a shell that supports process substitution (bash will do):
mkfifo fifo
echo -e '\x00\x01\x02\x03' |
tee fifo |
paste -d' ' \
<(hexdump -v -e '1/1 "%_ad: "' -e '4/1 "%02X "' -e '1/1 " :\n"') \
<(xxd -b -c 4 fifo | cut -d' ' -f 2-)Output:
0: 00 01 02 03 : 00000000 00000001 00000010 00000011 ....
4: 0A : 00001010 .
|
I really like hexdump, especially because you can define a custom format; say:
$ echo -e '\x00\x01\x02\x03' | hexdump -v -e '1/1 "%_ad: "' -e '4/1 "%02X "' -e '1/1 " : "' -e '4/1 "%_p"' -e '1/1 "\n"'
0: 00 01 02 03 : ....
4: 0A : .So, I can choose to have, say, 4 bytes per line, written as hexadecimal first, then as characters. But, what I'm missing here, is a "binary string" (or "bit string") formatting character; e.g. I'd like to write something like -e '4/1 "%08b "' somewhere in that command line, and get, e.g.:
0: 00 01 02 03 : 00000000 00000001 00000010 00000011 : ....
4: 0A : 00001010 : .Of course, then probably one would have to specify endianness (if groups of more than one byte should be formatted) etc... But in any case, this kind of formatting doesn't exist, as far as I can see in the hexdump manual.
So my question is - what alternatives do I have on a Linux command line, so that I could obtain a formatted dump that includes binary strings as above, and yet to the greatest extent possible preserves the customizability of the hexdump program (in terms of byte grouping) when using its -e option?
|
Achieving hexdump-like format, that includes binary strings, on the command line?
|
Not that simple nor obvious... try
hexdump -v -e '"%08.8_ax "' -e' 4/1 "%02x " " " 4/1 "%02x " " " 4/1 "%02x " " " 4/1 "%02x " ' -e '" |" 16/1 "%_p" "|\n"' file
|
I'm trying to get the output of my hexdump command to look similar to hexedit default. I've been playing with the format strings using -e, but since there are not very good documentation, that visually describe how to use it, I am failing to get it right.
Currently, I have:
# hexdump -C -n 0x100 m1.bin
00000090 00 00 00 00 00 56 08 00 00 00 00 00 04 00 00 00 |.....V..........|
000000a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|But I would like to have it with one more space separating the 4 bytes, like this:
00000090 00 00 00 00 00 56 08 00 00 00 00 00 04 00 00 00 |.....V..........|
000000a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|alternatively like this:
00000090 0000 0000 0056 0800 0000 0000 0400 0000 |.....V..........|
000000a0 0000 0000 0000 0000 0000 0000 0000 0000 |................|Also, if it would be possible to get some color, that would be really great. So far I haven't been able to get any color at all from hexdump.
EDIT
Also great for piping is to leave out address, char field and newlines (\n) with:
# hexdump -e '16/1 "%04.2x"' -n 40 m1.bin
54 4f 43 00 00 00 00 00 00 00 00 00 00 00 00 ...
|
How to get Hexdump output in same format as hexedit?
|
It means that one or more lines were suppressed, because they are identical to the previous line; in this case, it means that the line starting at 00001e0 is all zeroes, same as that starting at 00001d0.
To determine the number of deleted lines, you need to look at the addresses involved and the length of each line; in this case, a single line was deleted.
If you're using od, this is controlled by the -v flag. By default od will suppress duplicate lines, -v tells it not to.
|
I see sometimes star symbol (*) in the hex editor, like
...
00001d0 0000 0000 0000 0000 0000 0000 0000 0000
*
00001f0 0000 0000 0000 0000 0008 0000 0000 0000
...It is probably some sort of separator.
However, there are many other separators too.
What is the meaning of this star symbol in hex data?
|
What is the meaning of Star symbol * in Hex data?
|
0000000 in this example is the offset (hexadecimal, counted from the start of the file) of the first byte printed in a particular line.
0000006 in this example is the number (in hexadecimal) of bytes in a file. There are five characters in the word "hello" and a line feed character (0x0A).
Try echoing a longer text or repeating echo "hello" >> 1.txt several times to increase the size of the file. Then see the hexdump results.
|
I created a simple file, 1.txt:
echo "hello" >> 1.txtThen I dumped it:
hexdump 1.txtAnd the terminal output:
0000000 68 65 6c 6c 6f 0a
0000006What do 0000000 and 0000006 mean?
|
What do these numbers in a 'hexdump' of a file mean?
|
Thanks to @JdeBP for the hint, I was able to create a small testcase that does the same as hexdump:
#include <stdio.h>int main(void){
char buf[64]; size_t r;
for(;;){
printf("eof=%d, error=%d\n", feof(stdin), ferror(stdin));
r = fread(buf, 1, sizeof buf, stdin);
printf("read %zd bytes, eof=%d, error=%d\n",
r, feof(stdin), ferror(stdin));
if(!r) return 0;
}
}When run on a glibc based system (typical linux desktop).
prompt$ ./fread-test
eof=0, error=0
<control-D>
read 0 bytes, eof=1, error=0prompt$ ./fread-test
eof=0, error=0
hello
<control-D>
read 6 bytes, eof=1, error=0
eof=1, error=0
<control-D>
read 0 bytes, eof=1, error=0When run on bsd, solaris, busybox (uclibc), android, etc:
prompt$ ./fread-test
eof=0, error=0
hello
<control-D>
read 6 bytes, eof=1, error=0
eof=1, error=0
read 0 bytes, eof=1, error=0Based on my inexpert interpretation of the standard, this looks like a bug in glibc (the GNU C library).
About fread:For each object, size calls shall
be made to the fgetc() function and the results stored, in the order
read, in an array of unsigned char exactly overlaying the object.About fgetc:If the end-of-file indicator for the input stream pointed to by
stream is not set and a next byte is present, the fgetc() function
shall obtain the next byteIt seems that glibc will try to "obtain the next byte" even if the eof indicator is set.
Indeed, it actually is a bug in the GNU C library, not present in the BSD or musl C libraries. It was known about in 2005. Ulrich Drepper closed the bug report without fixing the bug in 2007. It was discussed in 2012, where it was noted that other C libraries did not and do not have this behaviour, that the 1999 C Standard is quite specific about it, and that Solaris even has a special mechanism for this which is invoked when c99 is used as the compiler instead of cc.
It was finally fixed in 2018. The fix is in version 2.28 of the GNU C library. The current "stable" version of Debian, version 9, is on version 2.24 of the GNU C library, and this bug thus continues to manifest itself, 14 years after being reported.
As noted in the GNU C library discussions, there is the possibility of softwares that were written to require the quirks of the GNU C library without regard to other C libraries such as musl or the behaviour on other platforms. However, in the aforementioned discussions over the years no such program was identified. Whereas several programs that are broken by the old GNU C library, to require users to signal EOF twice in succession, have been identified; including amongst others hexdump here and patch on StackOverflow back in 2018.
|
When run from a terminal, hexdump does not react to a single ^D at the beginning of the line, as cat, od, bc, etc. do, unless there was no input yet:
prompt% hexdump -C
<control-D>
prompt% hexdump -C
hello
<control-D><control-D> # a single ^D won't do
00000000 68 65 6c 6c 6f 0a |hello.|
00000006I can reproduce this on both fedora 28 and debian 9. Despite hexdump being provided by bsdmainutils on Debian, this does not happen on bsd.
Is this just a bug? Are there any other programs known to exhibit this behavior?
|
Why does hexdump try to read through EOF?
|
Because you didn't add the -v option to hexdump.-v Cause hexdump to display all input data. Without the -v option, any number of groups of output lines, which would be identical to the immediately preceding group of output lines (except for the input offsets), are replaced with a line comprised of a single asterisk.Therefore you need:
$ hexdump -n32 -xv test.bin
0000000 8888 8888 8888 8888 8888 8888 8888
0000010 8888 8888 8888 8888 8888 8888 8888
0000020
|
Why does hexdump seem to miss out parts of the file, while xxd does not? The file is 32 bytes. So xxd output is correct.
$ xxd test.bin
0000000: 8888 8888 8888 8888 8888 8888 8888 8888 ................
0000010: 8888 8888 8888 8888 8888 8888 8888 8888 ................
$ hexdump -n32 -x test.bin
0000000 8888 8888 8888 8888 8888 8888 8888 8888
*
0000020
|
Why do I get different output from hexdump compared to xxd?
|
od is a standard command. In od -An -tx1 -w1 -v, the only thing that is not POSIX is the -w option.
You can replace it with:
od -An -vtx1 | LC_ALL=C tr -cs '0-9a-fA-F' '[\n*]' | grep .Which would work in any POSIX-compliant system and does work on FreeBSD at least:
$ echo test | od -An -vtx1 | LC_ALL=C tr -cs 0-9a-fA-F '[\n*]' | grep .
74
65
73
74
0aOr with one sed invocation to replace the tr+grep:
od -An -vtx1 | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//;/./!d
s/[[:blank:]]\{1,\}/\
/g'(or
od -An -vtx1 | sed -n 's/[[:blank:]]*\([^[:blank:]]\{2\}\)[[:blank:]]*/\1\
/g;s/\n$//p')
With perl (not a POSIX command but ubiquitous on anything but embedded systems):
perl -ne '
BEGIN{$/ = \8192; $, = $\ = "\n"}
print unpack "(H2)*", $_'Which is also the fastest of the 3 in my tests (compared to GNU od) by a significant margin for anything but small files (also than hexdump, not than vim's xxd).
|
Suppose we want a minimalist one-byte per line ASCII hex dump. Under Linux using GNU od, this works:
echo foo | od -An -tx1 -w1 -vOutput:
66
6f
6f
0aBut that won't work with BSD derivatives, because the BSD od util has different flags.
What's the most portable *nix method? Failing that, what are the best available methods?
|
Portable one-byte per line hex dump
|
This appears to be a bug in that implementation of hexdump.
The function responsible is
print(struct hexdump_pr *pr, unsigned char *bp)in hexdump-display.c. It copies the correct number of bytes into a suitable variable, so that sign-extending can happen when passing the value to printf(). But for single bytes, it doesn't bother - it just dereferences the pointer, which was to an unsigned char.case F_INT:
{
short sval; /* int16_t */
int ival; /* int32_t */
long long Lval; /* int64_t, int64_t */ switch(pr->bcnt) {
case 1:
printf(pr->fmt, (unsigned long long) *bp);
break;
case 2:
memmove(&sval, bp, sizeof(sval));
printf(pr->fmt, (unsigned long long) sval);
break;To fix it, patch the function to use the same "copy to local variable" approach:--- text-utils/hexdump-display.c.orig 2015-10-05 15:18:43.458759033 +0100
+++ text-utils/hexdump-display.c 2016-08-19 14:58:35.507705329 +0100
@@ -146,13 +146,15 @@
}
case F_INT:
{
+ char cval; /* int8_t */
short sval; /* int16_t */
int ival; /* int32_t */
long long Lval; /* int64_t, int64_t */ switch(pr->bcnt) {
case 1:
- printf(pr->fmt, (unsigned long long) *bp);
+ memmove(&cval, bp, sizeof(cval));
+ printf(pr->fmt, (unsigned long long) cval);
break;
case 2:
memmove(&sval, bp, sizeof(sval));
|
I want to read /dev/input/mice with hexdump. Format is described at here at StackOverflow. What I need is to read one byte (flags), print it in hex format, then read two bytes (x and y move offset) and print each in signed decimal format.
I use hexdump from util-linux 2.28 on Arch Linux.
The best I was able to put together is
hexdump /dev/input/mice -e '/1 "%03x" 2/1 " %03d" /0 "\n"'The format string:/1 "%03x" reads one byte and prints it as hex number
2/1 " %03d" reads one byte and prints it as signed decimal integer, repeats two times
/0 "\n" reads zero bytes and prints end of lineThe problem is that for value 0xFF the %d specifier prints 255 instead of -1. The format is taken from C, which extends the width properly, so how to force this proper width extension here?
|
Print one byte signed number with hexdump
|
According to the man page, %d, %i, %o, %u, %X, %x Four byte default, one, two and four byte
counts supported.And there doesn't appear to be any integer type where eight byte is supported (you'd also need %u, not %d for unsigned ints).
You could use perl instead here:
perl -ne 'BEGIN{$/ = \24} # 24 byte input records
printf "%015u %6u %6u %6u %6u\n", unpack "QL4"' < binfile(QL4 being 1 unsigned quad (64bit) followed by 4 unsigned longs (32bit))
|
I am trying to display a binary file with records consisting of:
8 bytes unsigned int
4 bytes unsigned int
4 bytes unsigned int
4 bytes unsigned int
4 bytes unsigned intI try to display it using hexdump as follows:
hexdump -v -e '1/8 "%015d " 4/4 " %6d" "\n"' binfileBut I get:
hexdump: d: bad byte countI am using FreeBSD 12 -if relevant-
|
Bad byte count while using hexdump
|
The U+FEFF character is encoded in UTF-8 over 3 bytes: ef bb bf.
xxd or hexdump shows you the byte content, so those 3 bytes, not the character that those 3 bytes encode like vim -b does.
To remove that BOM (which doesn't make sense in UTF-8) and fix other idiosyncrasies of Microsoft text files (which is likely the source of your problem), you can use dos2unix.
$printf '\ufefffoobar\r\n' | hd
00000000 ef bb bf 66 6f 6f 62 61 72 0d 0a |...foobar..|
0000000b
$printf '\ufefffoobar\r\n' | uconv -x name
\N{ZERO WIDTH NO-BREAK SPACE}\N{LATIN SMALL LETTER F}\N{LATIN SMALL LETTER O}\N{LATIN SMALL LETTER O}\N{LATIN SMALL LETTER B}\N{LATIN SMALL LETTER A}\N{LATIN SMALL LETTER R}\N{<control-000D>}\N{<control-000A>}
$printf '\ufefffoobar\r\n' | uconv -x hex
\uFEFF\u0066\u006F\u006F\u0062\u0061\u0072\u000D\u000A
$printf '\ufefffoobar\r\n' | dos2unix | hd
00000000 66 6f 6f 62 61 72 0a |foobar.|
00000007
|
I have a Java class which the compiler refuses to compile due to \ufeff at the start of the file. I can view the fact that the BOM is present by vim -b file.java, but neither xxd nor hexdump show the two bytes. Is there some way to make them do so?
|
Why does xxd not show the byte order mark?
|
Here is a quick example:
hexdump -f foo.cfg foo.logand foo.cfg contains
"%06.6_ao " 12/1 "%3_c_L[red:0x0a] "
"\n"and the result only colors when writing to a terminal (not redirected). Looking at the result by capturing the output using script, the result looks like this in a text editor:
Script started on Fri 04 Nov 2016 09:23:32 PM EDT
000000 f o o ^[[31m \n^[[0m f o o . l o g ^[[31m \n^[[0m^M
000014 s d d m - a u t h 0 2 4^M
000030 0 b f b 3 - a d 0 6 - 4^M
000044 7 0 7 - b a 1 3 - 1 f e^M
000060 0 7 5 9 e a e 7 4 ^[[31m \n^[[0m s d^M
000074 d m - a u t h 0 b 1 9 9^M
000110 b f 5 - c 7 3 4 - 4 5 f^M
000124 f - a 4 8 0 - f 5 a a c^M
000140 e c 3 e 1 b 0 ^[[31m \n^[[0m s d d m^M
000154 - a u t h 4 0 7 1 d 2 1^M
000170 b - 6 0 4 7 - 4 a 8 5 -^M
000204 8 1 3 6 - f 3 8 9 0 d 6^M
000220 a b a d 0 ^[[31m \n^[[0m s d d m - a^M
|
I'm trying to display a hexdump of a file and highlight carriage returns in red. I'm having a really hard time understanding the format of the formats option (-e).
Is it something like:
hexdump -e "_L[red:0A]" practice_file_1.txt?
I'm slowly solving the puzzle, but I probably don't know a higher level knowledge base that would make this more understandable, like the printf(3) syntax or something, but I don't know what it is...
Also, is it even related to the -L tag? (Do I need to use the -L option?)
References:the “FORMATS” section in hexdump(1);
fprintf(3).
|
Hexdump format syntax - color
|
Apparently it keys off of the width of your terminal. If you size the terminal just right you can get hexedit to show you 8 columns instead of 9.
Example
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
00000080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
000000A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
000000C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
000000E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
00000100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
00000120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
00000140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
00000160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
00000180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
000001A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
000001C0 01 00 EE FE FF FF 01 00 00 00 AF 32 CF 1D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........2....................
000001E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA ..............................U.
00000200
00000220
00000240
00000260
00000280I had the column width of the above terminal set to 151x55.
$ resize
COLUMNS=151;
LINES=55;
export COLUMNS LINES;
|
I am using hexedit to show/edit disk MBR (512 Bytes, copied with dd).
When I open the file, hexedit displays the file as 9 columns, 4 bytes
per column (36 bytes per line). That is very unfortunate. I need to have
it aligned in a meaningful way (ie 8 columns, 32 columns per line)
I could not find any way to do it in the manual page.
Is there a trick I could use ?
UPDATE:
here are the commands I use:
dd if=/dev/sda of=sda.img bs=512 count=1
hexedit sda.imgregarding the output I get, it looks similar to slm's, only with 9 columns instead of 8.
|
hexedit: change number of columns (bytes per line)
|
You can display the contents of a file with cat, but with binary files that will often result in "garbage". For binary files you can use od -x (or xxd):
od -x file.binthat makes everything byte readable as hex words for any file (understanding what that means is more difficult and dependent on the program that wrote the file, but fortunately that is not what you asked for).
|
I have object of class
class X {
private DateTime dt; "constructor, set/get"
}I have one instance of this object serialized in file.bin.
I want to show content of `file.bin on the Linux console in human readable way.
|
Convert serialized Java object to human readable
|
You are using a little endian CPU, the 16 bit words hexdump is showing are byte swapped.
6 is the offset of the second dump line which is empty, your file containing only six bytes.
Use od -c or od -t x1 to get the expected order:
$ od -c test.txt
0000000 p r o v a \n
0000006
$ od -t x1 test.txt
0000000 70 72 6f 76 61 0a
0000006
|
I saw this question Why does Ctrl-D (EOF) exit the shell? and wanted to try the example on the second answer.
So i've created a file and used hexdump:
federico@home ~ $ cat > test.txt
prova
^C
federico@home ~ $ hexdump test.txt
0000000 7270 766f 0a61
0000006The second row has '6' in the end, and if i try to use http://www.rapidtables.com/convert/number/hex-to-ascii.htm to decode from hex to ascii i get a strange letters order.
Why does this happen?
Thanks
|
Strange ascii from hexdump of text file
|
There are no multiple variants of DNS, but RFC 1035 on this subject was amended by RFC2535 "DNS Security Extensions".
Its section 6.1 shows the message format: 1 1 1 1 1 1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| ID |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|QR| Opcode |AA|TC|RD|RA| Z|AD|CD| RCODE |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| QDCOUNT |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| ANCOUNT |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| NSCOUNT |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| ARCOUNT |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+As you can see, the 3 bits previous Z field is now split between Z, AD and CD.
Hence, your 0x20 = 0b00100000 is to be split as follows:RA = 0 : recursion NOT available from the server replying this message
Z = 0 : as expected, should be 0
AD = 1 : "all the data included in the answer and authority
portion of the response has been authenticated by the server
according to the policies of that server."
CD = 0 : checking not disabled (makes sense in query, not in a response, it is defined as "Pending (non-authenticated) data is
acceptable to the resolver sending the query.")
RCODE = 0 : No error DNS specifications are complicated, often ambiguous, split in many documents, etc.
This recent effort can help finding its way:
https://powerdns.org/hello-dns/
|
When I was scrutinizing the DNS query sent by the dig, I found something odd from what RFC's state. I don't know the different variants of DNS protocols out there, but from RFC 1035 Z : Reserved for future use. Must be zero in all queries and responses.This is the memory snapshot of the received DNS query, exported from the eclipse IDE in the debugging mode.
00000000 F5 F4 01 20 00 01 00 00 00 00 00 01 03 77 77 77 06 67 6F 6F 67 6C 65 03 63 6F 6D 00 00 01 00 01 00 00 29 10 00 00 00 00 ... .........www.google.com.......).....
00000028 00 00 0C 00 0A 00 08 1F 0A 12 91 67 67 B0 B9 ...........gg..Mapping the corresponding bits to DNS fields (From the RFC 1035)
F5F4 -> DNS Transaction ID.
01 -> QR, Opcode, AA, TC, RD
20 -> 00100000 => RA -> 0 , Z -> 010
Z is non zero! Does dig use some other variant of DNS, if at all the DNS variants exists? Or should it be considered as an issue in the dig?
|
Understanding the dig's DNS query: Does dig set non zero value for Z field?
|
You are correct writing that the original ext2 superblock specification does not make provision for storing the file system creation date.
But leaves 788 bytes Unused starting from offset 236.
Unused meaning free for use by the programs creating/using the filesystem.
Ext4 contrarily makes provision for storing when the filesystem was created, in seconds since the epoch, s_mkfs_time, at offset 0x108 of an ext4 type superblock… that is precisely… 264 decimal.
For easing the coding of tools working more or less generally with all the ext family of filesystems, some utilities dedicated to filesystem creation might fill some of the unused 788 bytes of an ext2 superblock with ext4-like infos.
This being for example the case of the busybox mkfs_ext2 utility. cf line 522 :
STORE_LE(sb->s_mkfs_time, timestamp);
|
I am trying to find the creation date on an ext2 file system. I seem to get a current date using dumpe2fs.
The problem is that the original ext2 superblock specification does not contain such information, though it seems like there might be an extension to the original fields (something about after byte 264).In fact using hexdump on the superblock (hexdump -s 1024 -n 1024 -C /dev/vdb) I can find 4 bytes starting from byte 265 that containg a hex number which contain in little endian the unix time of the file system creation. Any information on how, why and under what circumstances that it there?
Thanks in advance
|
Unix ext2 superblock - file system creation date
|
Based on this example in the hexdump man page: # hex with preceding 'x'
% echo hello | hexdump -v -e '"x" 1/1 "%02X" " "' ; echo
x68 x65 x6C x6C x6F x0Ait seems you can use -e '"\\" 1/1 "%03o" '
Ex.
$ echo hello | hexdump -v -e '"\\" 1/1 "%03o" ' ; echo
\150\145\154\154\157\012
|
What I want to see:
$ printf "\U1F600\n"|hexdump -v -e '1/1 " %03o"'|tr ' ' '\\'
\360\237\230\200\012What I tried:
$ printf "\U1F600\n"|hexdump -v -e '1/1 "\\%03o"'
hexdump: bad conversion character %�$ printf "\U1F600\n"|hexdump -v -e '1/1 "\%03o"'
hexdump: bad conversion character %%$ printf "\U1F600\n"|hexdump -v -e '1/1 "\\\%03o"'
hexdump: bad conversion character %\$ printf "\U1F600\n"|hexdump -v -e '1/1 "\\\\%03o"'
\\\\360\\\\237\\\\230\\\\200\\\\12
|
How to include a backslash \ in the hexdump output format string?
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.