date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,599,039,485,000
I just bought a ssd to change with current hdd. So, I decided to copy whole 750 gb partiton (of course used part of it which is approximetly 76 GBs) using "dd" utility. However, I entered this command: sudo dd if=/dev/sda5 of=/dev/sdb1 (since partition I mentioned was defined as "sda5"...) I was expecting it to copy...
If you don't specify the bs and count options, dd will copy the whole partition /dev/sda5. This is because dd is a very low level tool and it has no means of distinguishing between files and empty space. So, to copy only the full part of the partition, dd isn't the tool you need because even you specify the size, ther...
"dd" Utillity Copied More Than Expected
1,599,039,485,000
I have a USB hard drive of 32 GB, I want to know the time it takes to copy 1 GB of data from the USB drive. I tried using dd if=/dev/sdb1 of=/dev/null The output is this dd if=/dev/sdb1 of=/dev/null bs=1G 28+1 records in 28+1 records out 30751983616 bytes (31 GB) copied, 331.297 s, 92.8 MB/s is the approach used ...
Your command is incorrect, you tell dd to read by 1 GB chunks, but an unlimited number of times. To only measure the time spent to read 1 GB, you need to tell dd to read only one block: dd if=/dev/sdb1 of=/dev/null bs=1G count=1 Note that buffering will make that command run faster if the device has previously be rea...
Reading only 1GB using dd command
1,599,039,485,000
I am looking for a way to put zeros and burn myiso.iso in parallel. The command dd if=/dev/zero of=/dev/sdb && (sleep 1; dd if=myiso.iso of=/dev/sdb) should be ok since the speed at which zeros are written is inferior to the speed at which the iso is written. How would you verify that the iso is written only after ze...
If you're trying to ensure the USB key only contains the image and the remaining space is all zeros, you could do this instead: cat myiso.iso /dev/zero > /dev/sdb There doesn't seem to be much point in writing all zeros and then the image on top...
How can I run 2 dd in parallel writing on the same device
1,599,039,485,000
I had an ext3 partition. I ran a dd command like this: dd if=/dev/urandom of=/dev/part2 bs=1024 count=15000 seek="various values" Where various values are basically 0, 15000K, 30000K etc. The point is I ran the dd command on the entire partition. Now the partition won't mount. I get an error "Can't find ext3 partitio...
You overwrote and/or corrupted superblock(s), and likely other data, with the data from /dev/urandom. Superblocks are important; they contain filesystem metadata. You can format it back to ext3 by issuing mkfs.ext3 /dev/part2.
What happened to my ext3 partition
1,599,039,485,000
I have Debian 10 with the latest Proxmox installed. 2 SSD with: sda1: EFI sda2: raid1 (/dev/md0) sda3: swap sdb1: EFI (clone of sda1) sdb2: raid1 (/dev/md0) sdb3: swap After an update, I wanted to clone /dev/sda1 to /dev/sdb1 with dd, but I made an error and typed dd if=/dev/sda of=/dev/sdb. I cancelled it with Ctrl+...
Explaining The Error: That error does not indicate a problem with a physical disk; loop0 is a loopback device. Which is a block storage device that uses a file on disk as a backing store. A disk within a disk you might say. These loopback disks have their own filesystems and sometimes their own partition tables. So r...
EXT4-fs error on loop0
1,599,039,485,000
I am using a Mac, booting in efi mode a Debian 10 live usb that I created. In live mode, I am attempting to create a FreeBSD install usb by downloading it and dd’ing it to another usb stick. Before doing so, I want to make sure my usb stick is zeroed. While zeroing my usb stick I noticed a difference in output from dd...
dd doesn't care about case, that's up to the filesystem and kernel. And on Debian that'd be case-sensitive. So where /dev/sdc might have been a device node, /dev/sdC probably didn't exist until dd created it, as a regular file sdC inside /dev. /dev is probably a tempfs: % df -hT /dev Filesystem Type Size Use...
Difference between of=/dev/sdx and of=/dev/sdX when using dd command on Debian 10 Live USB
1,599,039,485,000
If for example I clear the contents of my SD card with command dd if=/dev/zero of=/dev/sdX , I'm guessing this completely wipes (sets to zero) every single content on the card? partitions, file system, data etc. Now what I can't understand is, when I will plug this device into a computer again afterwards, Linux or Win...
Your SD card is not just passive memory, like a DVD (or a CD, or a floppy disk). SD cards include a controller: [ [flash memory] <=> [controller] ] <=> [your computer] There are different types of flash memory, and I'm guessing they need specific drivers ... The controller inside the SD card handles the details. T...
How does the OS know which type of flash memory we are using
1,599,039,485,000
I'm copying an image file (size: 2GB) to an USB disk on /dev/sda (size: 2TB) using dd: sudo dd if=2023-05-03-raspios-bullseye-arm64-lite.img of=/dev/sda bs=4M status=progress conv=fdatasync After dd, the USB disk has the same "size" as the image (2GB), at least that is what fdisk says: $ sudo fdisk -l /dev/sda Disk /d...
If /dev/sda was a block device, then fdisk -l /dev/sda would show its full size. There would be no need to "regain the full disk space". Hypothesis: your /dev/sda is not the USB disk. It's a regular file dd created because /dev/sda did not exist at all when you run dd. The regular file is just a copy of the source ima...
Regain full disk space after copying a small image file to a large USB device
1,599,039,485,000
sfill -Illv makes a file with data from /dev/urandom until it fills the partition. Making a large file like this takes a lot of time. iotop tells me it is writing about 1 MB/s. Though dd if=/dev/urandom >> ./randomfile, which would do the same thing, does this at about 12 MB/s. Why is sfill so much slower? Edit: I am ...
Comparative Benchmark I wondered how slow sfill really was; so I benchmarked it: Since I don't trust sfill (having read its source code, it feels more like an entry to the international obfuscated C code contest than well-written systems software that I'd trust to do something securely), I at least isolated it by runn...
What makes sfill so slow?
1,599,039,485,000
When typing the command: dd if=/dev/urandom of=outputfile bs=1G count=1 I should receive a file at the size of 1GB if I understand correctly. Yet, I receive a file of the following values: 33554431 bytes (34 MB, 32 MiB) copied, 0.27126 s, 124 MB/s Why is that? On the system where it works I receive: 1+0 Records in ...
The device /dev/urandom temporarily returned zero bytes (no more data). The dd utility treated that as EOF and stopped. Since you know that /dev/urandom will generate more random data you need to tell dd to reattempt reading input: dd if=/dev/urandom iflag=fullblock bs=1G count=1 The iflag=fullblock flag is also need...
Why does dd create a 34MB file with bs=1G? [duplicate]
1,599,039,485,000
When I run the command dd if=/dev/zero of=tmp.dat bs=1M count=1024 status=progress on a 500G HDD I get 833617920 bytes (834 MB, 795 MiB) copied, 1 s, 829 MB/s 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 1.41974 s, 756 MB/s which seems bogus (756MB/s !), as I understand mechanical d...
What you're observing is called "Dirty Pages" and is a feature of most modern Operating Systems. The kernel doesn't physically write data to the disk as soon as a file is written to - this allows to more intelligently write data to the disk in order e.g. to avoid fragmentation. To disable this behaviour run dd with co...
dd faster than it should be
1,599,039,485,000
I'm creating a bootable USB in order to install NixOS. Given a USB at /dev/sda this could be done by running: # download the ISO wget https://channels.nixos.org/nixos-21.11/latest-nixos-minimal-x86_64-linux.iso # erase the disk sudo dd if=/dev/zero of=/dev/sda bs=4M # write the image sudo dd if=latest-nixos-minimal-...
When you use of=/dev/sda, dd will overwrite everything starting from physical block #0, including any partition tables and filesystem metadata. Erasing the disk before writing the ISO is an unnecessary step, unless you need to give the bootable USB to someone else and/or otherwise need to ensure that any data that use...
Creating bootable USB: does `dd` overwrite partition table, formatting, filesystem?
1,599,039,485,000
When I write random data on the disk with the dd tool, I can access the old data again. To test it, I first added a "text.txt" file to the disk and wrote "this is text" in it. My disk is mounted to the /mnt/backup directory. $ cat /mnt/backup/text.txt this is text $ The i used dd: $ dd if=/dev/urandom of=/dev/sdb1 #t...
The data probably is overwritten, but some of it is still cached in memory. When you write directly to the device like this, it bypasses the linux filesystem caching mechanism and goes directly to the device. What is in cache at the time is at least temporarily unaffected. If the filesystem is still mounted, the ope...
Why dd does not overwrite existing data?
1,599,039,485,000
I got a softbricked/hardbricked 1TB WD Passport HDD which happened when transfering a suspected 11GB PS3 game file from my mac.As for repairing, My mac cannot do anything with the HDD, so I'm trying to solve it using linux machine. by running : sudo badblocks -v /dev/sdb > badsectors.txt I got an unlimited number of l...
You have the highest possible read error rate: 1 Raw_Read_Error_Rate 0x002f 001 001 051 Pre-fail Always FAILING_NOW 72289 which means there's some hardware defect somewhere. This drive is dead.
If dd zero does not "format" my disk what should i do?
1,599,039,485,000
This is the command that I ran in a sudoed terminal: dd if=/dev/zero of=/dev/sd* bs=512 count=32 These are the sd* using lsblk: sda 8:0 0 238.5G 0 disk ├─sda1 8:1 0 600M 0 part /boot/efi ├─sda2 8:2 0 3G 0 part ├─sda3 8:3 0 227.2G 0 part / └─sda4 8:4 0 7.8G 0 part [SWA...
I have not restarted the system yet. Is there a way I can recover the lost/corrupted data? I doubt that you have lost any data. It looks like you got lucky. Do ls -l /dev/sd* to see what you did. There should be a file there that you did not expect.
Accidentally filled /dev/sd* with 16000 bytes from /dev/zero, using dd command
1,599,039,485,000
First of all, this question is NOT the duplicate of this one, which compares lower-case "sdx" with mixed-case "sdX". Back to the question. If I have a formatted memory stick which is composed of only a single partition and I use the following dd if=input_file of=/dev/sdXY bs=ZZ ... How will it be different from using...
Most ISOs nowadays are "hybrid ISO" images containing CD/DVD boot code (El Torito standard, an extension to the ISO 9660 CD-ROM standard) and an MBR (including boot code). This makes them bootable from CD/DVDs or USB storage devices. By copying the ISO to the device (and not a partition), you create a USB bootable v...
What is the difference between using "of=/dev/sdX" and "of=/dev/sdXY" in dd
1,599,039,485,000
I read this in "RH413 Red Hat Server Hardening" course that we mount the filesystems with nodev which then does not allow the special files/devices to be mounted from it. However, it did not show an example. I, however, did the following thing on my RHEL machine and I found that we cannot associate the special charact...
Firstly... I found that we cannot associate the special character device with any file created by dd command The experiment you have shown does not create a file with dd, it tries to write to a special character device using dd. 1) What are device files? Device files can be thought of as a link to a device in your ...
What is the default behaviour when we mount filesystem with `nodev` option?
1,599,039,485,000
Im using linux debian and tried to use this command sudo dd if=/dev/zero of=/dev/sdb on a usb drive, but I accidentally typed /devsdb whithout / char, and suddenly the OS turned of. As I turn it on it just shows a black screen with some startup text. How can I correct this, or at least access drives from somewhere li...
Summarising what has been said in comments, with additional info: When you ran sudo dd if=/dev/zero of=/devsdb you created a file in your / partition called devsdb. The command, if not terminated in time, would continue to run until the partition is totally filled up. Since the command was run as root, it would add...
dd has damaged the root drive
1,599,039,485,000
dd if=/dev/sdb of=/dev/sdc bs=10M /dev/sdb is a HDD with installed CentOS7 and able to boot. if /dev/sdc is another HDD, the dd copy works OK, /dev/sdc can boot without problem. if /dev/sdc is a USB disk, it can't boot after dd copy. failed log ( when using USB disk as /dev/sdc ) dracut-initqueue[704]: calling: set...
I guess the initramfs file does not include the usb-storage driver or one of its dependencies. You could fix this before the dd copy by doing something like: # dracut -–add-drivers usb-storage <your initramfs file>
dd copy a HDD to USB but fail to boot? [closed]
1,599,039,485,000
I've booted up arch live cd, with the idea of creating a disk image. There are 2 hdds (/dev/sda - i want this image, and /dev/sdb - the image will be copied here, but as a backup file (not rewrite), so i can use it later) So I mounted the /dev/sdb1 as: mount -t auto /dev/sdb1 /mnt/hdd And then i tried ddrescue if=...
According to its man page, ddrescue should be called like this: SYNOPSIS ddrescue [options] infile outfile [logfile] So, in your specific case, ddrescue /dev/sda /mnt/hdd/backup.hdd; no if= or of=.
dd no such file or directory
1,599,039,485,000
Sometimes when I use dd then sync or use dd with conv=fsync, the syncing process gets stuck, but sometimes not, with exactly the same input and output targets and configuration. dd if=2016-03-18-raspbian-jessie-lite.img of=/dev/sdg conv=fsyn sync # freeze here or dd if=2016-03-18-raspbian-jessie-lite.img of=/dev/sdg ...
I find myself quite often in a situation when pv image_file | dd of=/dev/slow_usb_stick shows that first few hundred megabytes just fly (to the buffer), then the transfer slows down badly. When dd exits there is entire buffer to flush. I then sync in order to remove the stick and I have to wait few more minutes becaus...
Sometimes syncing gets stuck with dd
1,599,039,485,000
I intend to mount locally an image obtained as a clone through dd. The image is corresponds to a mSATA disk of 512GB of storage, with a minimum version of Ubuntu barely configured. So usefully, really the content with data should not be larger than 3GB. However, for resource and space efficiency I have compressed with...
The image was compressed very well, so probably it contains many null bytes (a SSD after fstrim usually returns null bytes for sectors temporarily unused by the filesystem). If it's the case, you should try to decompress your .gz archive to a sparse file. The target filesystem must support sparse files for this to wor...
Mount compressed disk image or clone with dd respecting free space
1,599,039,485,000
So I wanted to do some performance test with encrypted and normal data storage on my embedded device. That is not what I was expected to see at all! Can you please explain it to me what just happend. Why dd comand output was 1843200+0 records but df -h show file system disk space usage as 13TB? Maybe I explain what I ...
You mounted a filesystem existing in /dev/mapper/enc_per_test (the device) to /mnt/enc_per_test/ (the mountpoint). Then with dd you chose to write to the device, not to a regular file inside the filesystem (i.e. under the mountpoint, e.g. of=/mnt/enc_per_test/blob). Your dd overwrote the majority of the filesystem wit...
Performance test went wrong and the dd command created 13TB of data on /dev/mapper/device. Why system didn't crash? HDD-250GB
1,599,039,485,000
In various tutorials I see the following command: mount -o ro,loop,offset=123 harddrive.img /mnt/loop but from reading the documentation I can't understand what are loop devices. Why would harddrive.img require different options than /dev/sba? From my own testing mount -o ro,offset=123 harddrive.img /mnt/loop seems t...
You need a loop device (which is basically a "fake" block device backed by a regular file) because mount needs a block device. And you don't need to specify -o loop because if you don't, a loop device will be created automatically if you try to mount a file. From mount man page: The mount command automatically cr...
Why do we need to set loop devices when mounting ddrescue images?
1,599,039,485,000
I have more than 30 qemu-kvm process open with different images. Their images where accidentally deleted. I searched and i found out that as the file is still open in a process. It can be still recovered. So i have followed this https://unix.stackexchange.com/questions/297475/accidentally-removed-a-libvirt-image-file-...
It could be the original was a sparse file, that is, it is marked as taking up X space when in reality, it's less than X. But when you copy it from the fd, the sparseness is gone and you copy the full X size.
dd command took alot of disk space when just coping open file from file descriptor
1,599,039,485,000
Newbie here. I tried to install arch linux to my laptop which has 2 partitions and windows 10 installation. I could not delete and merge partitions with fdisk, so googled and ran the following command. dd if=/dev/zero of=/dev/sda bs=512 count=1 conv=notrunc as per the this question. Now I don't see my partitions, all...
That's normal, since you deleted everything on sda. It has no partitions to be shown. Do: fdisk /dev/sda You'll enter fdisk interactively. If something got wrong and sda is really missing from the system, you'll get an error on this step. I'd suggest executing partx or partprobe or a reboot; probably the kernel needs ...
Delete and merge all windows partition from arch linux installation
1,609,953,018,000
I want to rewrite a specific area in an output file with an input file using dd utility, I need to skip the first 732618 bytes in the output file and write 708800 bytes starting from there, I found only how to skip bytes in the input file, but cant finds info how to skip it in the output file, is it possible to do wi...
The man page says: seek=N skip N obs-sized blocks at start of output You probably want conv=notrunc too, to not truncate the output. $ echo abcdefghijkl > foo.txt $ echo -n XYZ | dd bs=1 seek=3 of=foo.txt conv=notrunc 3+0 records in [...] $ cat foo.txt abcXYZghijkl Note that if you use bs=1 as above, it will issue ...
How to skip the needed amount of bytes in output file using dd utility?
1,609,953,018,000
I have a bootable USB-drive with one partiton. The drive is 16GB and the partition is 32 MB. I'd like to create an ISO of the drive (including the boot sector). Using dd, I can either create an image of the partition (which would be 32MB large, but is not what I want, because it won't be bootable) or I can create an i...
What you want to do is copy the partition table along with the partition. You can achieve that by copying the drive only up to the end of the partition (the table resides in the first sectors). First, check the exact geometry of your drive. For instance with parted: # parted /dev/sdb GNU Parted 3.3 Using /dev/sdb Welc...
Create image of drive with small partition using dd
1,609,953,018,000
Lets assume I have a virtual machine and no access to the hypervisor in any way. Also I cannot change any system parameters like setting up password protected booting with LUKS or anything. I can however install whatever tools I'd like and have full root access. Using dd to write zeros or random on the device will eve...
Basic Idea Make a ram disk -- or tmpfs Install busybox, static linked, on the ram disk. Make dev nodes for your disks and /dev/null and the like on the ram disk. pivot_root to the ram disk. exec a busybox shell. kill anything else running on the machine that prevents the next step. You might need to also put an s...
Self destruct a Linux VM with SSH access only
1,609,953,018,000
I work on the encoding of a file, from unknown-8bit to UTF-8. but I got an error message. iconv: illegal input sequence at position 136828 So I did a search in the file with the position like this : cat file | dd bs=1 skip=136828 count=1 2>/dev/null And I found the character that poses the problem. Now I want to rep...
To replace the byte at offset 136828 with ?, you can do: printf '?' | dd bs=1 seek=136828 conv=notrunc of=thefile
Replace character in file based on position
1,609,953,018,000
I had a corrupted file that I suspected to be caused by rsync to and from my aging external mechanical portable HDD. I made a backup and decided to write zeroes to see if there are writing errors. Sure enough, I got a few but not a lot. See below. I want to know if this is safe to use for daily rsync between my linux ...
You've already had one corrupted file, and there is a known problem with the disk. The problem can either stay the same, or get worse: it is extremely unlikely to "heal". So, no, it's not safe. However, a known-unreliable backup is still (marginally) better than no backup at all: it may allow you to recover at least s...
Copied zeros to my external drive, errors reported, is it still safe for daily rsync and which filesystems are safer?
1,609,953,018,000
I'm using this to wipe a USB flash drive and recreate a FAT filesystem: dd if=/dev/zero of=/dev/sdb bs=1M #I don't need more advanced wiping fdisk /dev/sdb (a few keystrokes to select partition type, etc.) mkfs.fat /dev/sdb1 The fact that I have to manually do a few keystrokes is annoying. How could I do all of th...
Here-document syntax allows you to use fdisk non-interactively: fdisk /dev/sdb <<EOF n p t b p q EOF Because this is just an example, I used p and q so no changes are written. Use w after your verified sequence. Note a blank line corresponds to sole Enter. The point is you can pass your keystrokes this way. Altern...
Wipe a USB flash drive and recreate a filesystem
1,609,953,018,000
We currently have two servers with SATA disks. The box load on the box every so often jumps. We see a direct correlation between the IO wait and the system usage going up. When ever the IO is high the system CPU usage jumps as well. The server has hardware raid with the drive showing as /dev/sda. We re running CentOS....
As you have the LVM partition I would recommend you the following steps: First switch the fstab and grub configuration to use UUIDs for /boot volume the system uses. Next, attach the SSD device, boot the system from the RAID and partition the SSD to have two partitions: for a new /boot volume and a new LVM PV. Then ad...
Switching disks
1,609,953,018,000
I have a Raspberry Pi (RPi) with a 128 GB SD card. This SD card contains the full OS and settings for the RPi and I would like to back it up. The total size of all files on the SD card are around 350 MB. I put the SD card into my laptop which runs a Linux distro and used dd to make a copy of the contents of the SD car...
Am I correct in assuming that the dd command backs up the whole device and so makes a file size that is equal to the whole SD card size? Yes, dd does a block-by-block copy If so, are there any ways to backup, and be able to restore to an SD card, if needed, only the 350 MB of contents of the SD card? You can use P...
Using dd to back up only contents an image on an SD card
1,609,953,018,000
I have this SD Card that has three read-only filesystems on it. I am using a Linux computer to try to erase via dd or another command tool. I am currently trying to write an image to the SD Card. Nothing I found so far states that a locked SD Card because of it being read-only should stop me from proceeding with an im...
Because of the Yocto build I ported to the hardware, the board was rendered useless because of the type of .dtb and booting mechanisms. The Yocto build was for an evm from TI while the hardware just had a TI chip on it, i.e. the same as the evm. For future reference, the TDA4VM is not the same as the evm from TI. The ...
Research and Folleys/Three RO Filesystems and No Way to Get the SD Card Back Operating
1,609,953,018,000
I have to update some outdated embedded systems. But the RAUC Update contains four partitions, while the old systems have only three partitions. The additional Partition is at the start of the disk and I cannot flash the devices with an external Adapter. What I have, is SSH access to the existing Linux on the device. ...
I did something similar on an embedded system. What saved me was that the compressed image of the new disk (with all its partitions) was small enough to keep in memory. What I did was to patch the initramfs to include a custom script. At boot, before mounting anything, it copied the (compressed) disk image into a ramf...
Handle Partition Changes Embedded System
1,609,953,018,000
I have a drive that is about 1TB big. It is mostly free space. When you add up the size of all the partitions, it is less than 256GB. I have another drive that is 256GB. I would like to clone the data from the 1TB drive to the 256GB drive. Is this possible? Obviously the source is bigger than the destination, but I'm ...
Thank you for adding the details. As you have Windows installed, be sure you have a current Windows Recovery Media. This USB stick can be created by your Windows. Search for Recovery media in the Windows start menu or just run C:\Windows\System32\RecoveryDrive.exe This will help if your Windows should not boot anymo...
dd not enough space
1,609,953,018,000
I have a block device that I'm trying to erase using dd. Seems like all my portion has been deleted. However, dd command is returning No space left on device. Block device information is as follows, fdisk -l /dev/xxxx Disk /dev/xxxx: 7876 MB, 7876902912 bytes 4 heads, 16 sectors/track, 240384 cylinders Units = cylind...
Yep. Also, if this is an SSD, a quick blkdiscard /dev/xxxx would have had the same effect of making the device return all zeros when you read anything from it, as writing zeros. (I'd recommend you still run blkdiscard on your device, to let the wear leveling know all your blocks can be put into the pool of blocks to b...
How to properly erase entire block device /dev/xxxx?
1,609,953,018,000
I have like 5GB of data and a very slow USB-Drive. Should I use dd, cp or rsync? Should I compress them first into for example 7z / tar or not? In short: What is the best way and the best practices to copy all those files to the USB-Drive? Thanks for your help :)
One good way is to compress them (on the same media where they are) and the transfer the archive to USB drive. Using this way you will have much less updates on USB for filesystem and less operations create/open/close (related to files). About copy operation for me cp will be OK.
How to Tranfser huge amount of Files to slow USB Drive (dd, cp, rsync, 7z, tar)
1,609,953,018,000
I have a .tar.gz as input and want to extract the first 128 MiB of it and output as a .tar.gz in a single command. I tried: sudo tar xzOf input.tar.gz | sudo dd of=output bs=1M count=128 iflag=fullblock | sudo tar -cfz final.tar.gz -T - which is obviously not working. How can I achieve this.
Instead of trying to extract the archive’s contents (which can’t work here — there’s no way to track the individual files’ metadata), decompress it, truncate it and recompress it. If you have a version of head capable of this: gzip -dc input.tar.gz | head -c128M | gzip -c > final.tar.gz or you can use dd as in your c...
Extract first n bytes from .tar.gz and output as a .tar.gz in a single command
1,609,953,018,000
I have an Intenso external 1TB 2,5" HDD here. It is somehow faulty (disconnects randomly on Windows) so I decided to run this command to check it: dd if=/dev/sdb of=/dev/null bs=4M status=progress The output when running looks like this: 715099471872 Bytes (715 GB, 666 GiB) kopiert, 16115 s, 44,4 MB/s Besides that 4...
dd can only update its display between individual copy operations; when you real GNU coreutils' dd.c, you'll find the main while loop simplifying to: int dd_copy() { // some setup while(true) { if(progress_reporting_enabled && minimum_time_passed) { print_xfer_stats(); } copy_a_block; } } If c...
What does it mean if the dd clock is ticking very slowly (every 12s only)?
1,609,953,018,000
I have a disk which is perhaps broken. I want to write random data to the disk and later verify the md5 checksum. I write to the disk like this: dd if=/dev/urandom of=/dev/sda bs=4M status=progress How to create the md5 checksum while writing to the disk at the same time? I want to see the md5 checksum of the written...
Rather than write your own solution you can use a standard scan utility. badblocks -w -s /dev/sda will scan the entire disk, writing patterns to each individual block then reading the block back and comparing the results. Progress is displayed during the scan. You can also specify a number of passes if the default si...
How to calculate the checksum while writing random data to a disk?
1,609,953,018,000
I work on an ext4 filesystem. I have doubts about the accuracy of a directory entry regarding the description of a file that I have copied from an NTFS filesystem and that might have spanned some bad sectors (but I am not sure). I now believe the file might have been truncated when copied from its source but that the ...
So first of all, the untrustworthy filesystem involved here seems to be the originating, not the target file system. If the origin read nonsense, that nonsense gets "correctly" written to the target file, and there's nothing you could do about afterwards – for all that there is in information, that's how the original ...
Is there a way to be sure a file is not truncated compared to the file size stored in the inode table? (Does a dd command do?)
1,609,953,018,000
For major version upgrades, Tails recommends this convoluted upgrade path where you write an image on a fresh USB drive, then clone the OS partition onto your original USB drive. I'm trying to figure out a better way to do it: I have a .img file that contains a partition table and a single partition: $ sudo kpartx -av...
You almost provided your own answer. You are already using kpartx but aren't taking advantage of its results: $ sudo kpartx -av tails-amd64-5.2.img add map loop12p1 (253:0): 0 2553856 linear 7:12 2048 Note the response add map loop12p1. This command has just created a /dev/mapper/loop12p1 device for you, which will ...
Restore from Full Disk Image to Single Partition
1,609,953,018,000
I have a 32 Gb SD card with my OS on it (Raspberry Pi OS Buster) and I wish to make a backup using standard dd, using sudo dd if=/dev/sdb of=/mnt/toshiba2tb/pi20211217.img bs=1M The source SD card seems perfectly fine under lsblk --fs db ├─sdb1 vfat RECOVERY 796F-5014 ├─sdb2 ├─sdb5 ext4 SETTINGS 3b129a7c...
The fdisk -l output on your image shows that your image is bad; you can write it to however many SD cards you want, using any card reader, and you’ll always get a bad result. You need to re-read the image, preferably with a tool which will tell you explicitly when the card can’t be read properly; e.g. ddrescue /dev/sd...
Why dd is giving me a different SD card than its source?
1,609,953,018,000
hello i am very new at linux and was reading a internal documentation on creating space. i came across this command can some one please explain what this command means dd if=/dev/zero bs=1G count=20 >> /OVS/Repositories/repo/.ACFS/snaps/vm_name/VirtualMachines/vm_name/System.img what i understand from this command is...
Let's break this into pieces: dd if=/dev/zero bs=1G count=20 The dd command copies data. The input data is from the device that generates an infinite number of zeros. The dd parameters say to use a block size of 1G and copy 20 blocks, so that would be 20G of zeros. >> /OVS/Repositories/repo/.ACFS/snaps/vm_name/Vir...
what does the dd command do
1,609,953,018,000
I made an image of /dev/sdc. The free space before the first partition isn't reporting the same byte sizes, but why? The start position is reported as 1024B on the drive and 16384B on the image? # parted /dev/sdc u b p free Model: ASMT 2105 (scsi) Disk /dev/sdc: 500107862016B Sector size (logical/physical): 512B/512B ...
This is nothing to worry about, this is just parted not being able to get the "disk" geometry because it's not a disk but a file. If you create a loop file from the image, the free space start should be the same. With the disk image file: (parted) p free Model...
Why does drive image show different start partition free size?
1,609,953,018,000
I encountered an issue with a disk drive which I already posted on. (For the curious: Issue with device after formatting) In short, one of my disks stopped allowing me to copy files by drag and drop using Dolphin (Debian), and allowed me only if I was doing it from the terminal using sudo. I researched about my issue ...
When a drive (or partition, or other block device, or a disk image file, etc) is formatted, the top-level directory of the filesystem is owned by the user running the mkfs command. Usually, that is root unless you're formatting a disk image file (or a block device you happen to have RW perms on) as a non-root uid. If ...
Ownership, disk drives and permissions
1,609,953,018,000
Why can't use oflag=direct on the 4k blocksize iSCSI disk? Could other applications also have a problem with the cause? root@testvm02:~# dd if=/root/speedtest of=/mnt/8k_512/speedtest oflag=direct 51200+0 records in 51200+0 records out 26214400 bytes (26 MB, 25 MiB) copied, 59,4312 s, 441 kB/s root@testvm02:~# dd if=...
Why can't use oflag=direct on the 4k blocksize iSCSI disk? You can use direct I/O, but bypassing kernel caches induces limitations that are mentioned in the open(2) manpage: The O_DIRECT flag may impose alignment restrictions on the length and address of user-space buffers and the file offset of I/Os.In Linux align...
dd: writing to Invalid argument with 4k blocksize on iSCSI LUN
1,609,953,018,000
I'm trying to make a script to select into which disk I should dd to. A simple bash script to select options works like this: #!/bin/bash # Bash Menu Script Example PS3='Please enter your choice: ' options=("Option 1" "Option 2" "Option 3" "Quit") select opt in "${options[@]}" do case $opt in "Option 1") ...
try lsblk -d -d, --nodeps Don't print device holders or slaves. (...) How could I parse the table generated by this command? lsblk -d | tail -n+2 | cut -d" " -f1 Would be good if I had a way to collect a name and the size so I can put in the option lsblk -d | tail -n+2 | awk '{print $1" "$4}' Should I assume it's si...
bash script to select a disk for dd (lsblk?)
1,609,953,018,000
Is it possible to write an image larger than the partition using dd? Supposing I had: blah.img: 8GB /dev/sda1: 3GB /dev/sda2: 4GB /dev/sda3: 4GB ... Are consecutive partitions guaranteed to be laid out adjacently and without padding, such that I could expect this to precisely overwrite both /dev/sda2 and /dev/sda3? ...
Partition block devices (/dev/sda2 etc.) won’t allow you to write beyond their limits, so you can’t write past the end of /dev/sda2 through /dev/sda2. You could overwrite multiple partitions by writing to the appropriate offset of the containing device (/dev/sda); however partitions are not guaranteed to be laid out o...
Writing single image to consecutive partitions using dd
1,609,953,018,000
Dear technical experts, For a number of weeks now I've been trying to extract data from an LTO6 tape without having too much success on the speed department. I'm using 'dd' to dump the tape content into one big binary file, as I do not know what format the tape has been written in (it is definitely not TAR). Basically...
Alright, I finally managed to get a decent speed dumping the tape. The procedure I'm using now basically relies on using different block sizes for different parts of the tape. Currently I read the first 2KB of the tape with a blocksize of 64KB, then switch to 65KB (weird I know) for a couple of blocks (tested with 400...
Very low read speed from LTO6 tape in Linux CentOS
1,609,953,018,000
Purpose: wipe entire sd card, not just 'delete' Command:(umounted) "sudo dd if=/dev/urandom of=/dev/sda bs=8192" dd: error writing '/dev/sda': No space left on device 118139+0 records in 118138+0 records out There are files on the sd. First, I opened a terminal where the sd card was, and ran the command, and then ...
The terminal was opening in "media" and for some reason, even after closing all terminals, and opening one from the file manager, it kept opening in 'media'. I restarted the computer and that fixed it. I was able to wipe the card then. Thanks for the help.
Why am I getting an error message when trying to "wipe" my micro-sd card using dd command? [closed]
1,550,498,460,000
It so happens that I need to install Win7 on a PC with a brand new blank HDD (the old one failed). I have the needed .iso file (on my Android tablet) and the only place I can stuff a USB flash into is my ASUS router ;) I presumed that if I simply telnet into my router (the .iso is on another flash) and perform umount...
1> make your thumb-drive a linux-live drive (same procedure you said before) 2> boot your computer from that live linux 3> use your PC disk drive to burn 'windows' ISO onto a DVD 4> restart your pc with DVD in Or easier: 1> Call a friend and ask to use his pc to burn your 'windows' dvd 2> start your pc with new dvd ...
Why can't I create a bootable Win7 flash by simply dd'ing the .iso to /dev/sd*?
1,550,498,460,000
I am trying to copy the x.file data into virtual volume of size 32 KB and trying to read again 32 KB from the same volume to y.file. It shows expected output when using cat y.file but whenever I am using vim/vi to see the content it shows appended character "^@". Command to write data in virtual volume. dd if=/tmp/x...
From comments, it is clear that the file x.file is less than 32768 bytes (32 KiB). This means that when dd is asked to write 32 KiB to /dev/vv/<vv_id>, it won't be able to copy it all from the file and the last bit of the 32 KiB will remain unwritten. This uninitialized data will then be copied to y.file with the sec...
Garbage char "^@" shows using vim but using cat it shows proper data
1,550,498,460,000
I'm going to create a bootable USB drive using dd, e.g. dd bs=1M if=myiso.iso of=/dev/sdc But I thought maybe beforehand I should fill the device with zeroes: dd bs=1M if=/dev/zero of=/dev/sdc Is this step necessary? What would be the advantages of filling the device with zeroes before writing, and the repercussions...
When you dd you are writing whatever file system your myiso.iso is to the device. Whatever partition table myiso.iso has (and it would have to have one if the iso is of a bootable image) then that partition table if it is valid is going to represent just the size and contents of myiso.iso. So if you have a 32GB usb s...
Is it necessary to fill a device with zeroes before writing an ISO to it?
1,550,498,460,000
We use a USB key system that are contain license files and are provided to unlock proprietary software that we used. The USB drives are small however and get lost easily, so I thought I'd clone them with dd for the next time we need to replace one. Unfortunately, I do not see them in /dev as I'd expect. Similarly lsb...
A SafeNet USB UltraPro is not a USB thumb drive. It's a specialized hardware dongle that provides the correct response when interrogated by software that uses it. It's specifically designed to be uncloneable; if you could copy them, it would defeat their entire purpose. Your only solution is to stop losing them. So...
USB key does not show up in /dev
1,550,498,460,000
I tried Qubes OS and found out that it is too heavy and complicated for me. So I tried to install Debian from a flashed USB. However, the installer gives the following error: the logical volume vm-sys-net-private on qubes_dom0 could not be deleted I have a Bodhi Linux installer on another flashed USB and that gives th...
After all, it was the dd if=/dev/zero of=/dev/sda bs=1M command that worked. I booted from a Debian live USB to get a view of the actual hard drive instead of viewing the virtual machines on Qubes OS and replaced sda with the one found from my system containing all the Qubes files.
Debian installation from USB: "the logical volume vm-sys-net-private on qubes_dom0 could not be deleted"
1,550,498,460,000
I have an external SSD which I need completely wiped. I had Mint installed on it, with SWAP and some root dir. Those I somehow cannot get rid off. I tried sudo dd but that just wipes sdc and those other two entries seem to be separate from sdc, so my question is how to get rid off those (sr0 and zram0), wiped? Here im...
You should mention the device from which Linux has booted. sr0 is a CDROM or DVD and is not what you really want to erase. With an erasable disc (CD-RW) if you really want to erase it, you can try cdrecord -v blank=fast dev=/dev/sr0. Of course, you will have some trouble if you erase a device from which you have boote...
Erase external SSD completely, including SWAP
1,550,498,460,000
so I want to backup my system drive (full drive not just partition) every month using dd, in an external hard drive. So I have something like this in my crontab 0 9 1 * * dd if=/dev/sda | gzip -c > /mnt/5E13119070E2D202/Backups/system_drive.backup.img.gz And that works fine. But I am trying to figure out how to rep...
But I am trying to figure out how to replace /dev/sda (system drive) with something which is persistent between reboots. So, you need a "world wide unique name" for your whole disk. Luckily, Linux has you covered. Find out the unique name for your drive by finding the right wwn-* entry in /dev/disk/by-id. You could...
using a cron job to automatically backup the same drive using dd
1,550,498,460,000
I need to remove all data from an hard disk where lubuntu 22.04 is installed. I was thinking to boot from an Ubuntu liveUSB image and, from a terminal, use the command: # the Hard Disk is the device file /dev/sda > sudo dd if=/dev/zero of=/dev/sda But this link says: Be advised this will remove all partition informa...
I think dd from /dev/zero or /dev/urandom may be sufficient, as @roaima said in his comment. But to make sure you're safe, I would use one of the following dedicated tools: shred (From GNU) scrub (From RedHat) These are tools made especially for securely wiping hard disks using multiple passes, writing random data, ...
Is the dd command enough to delete all data from a hard disk?
1,550,498,460,000
I am trying to flash an image on a ssd, but have to start multiple attempts until it finally succeeds. The image is 3 GB in size, the ssd has 1.8 TB. I've seen other people have problems with inodes, but that does not seem to be the cause here. All the information should be in these logs: $ ls -lah raspios_out.img -r...
Given sdb is correct and your image is for a full disk, this will work: sudo -s # Enter your password if prompted cat raspios_out.img >/dev/sdb sync What I'm seeing from my interpretation of your logs, though, is that sdb is the wrong device as it only has around 2GB space available
Why is dd randomly throwing a "No space left on device" error even though there is plenty?
1,550,498,460,000
I have built a custom image of Armbian with a partition size of 3.1 GB, and I am now finished working with it. It is currently written to a bootable 64 GB SD card which is using a GUID partition table (GPT). My problem is, is that when I want to make an image of the card using Ubuntu, I get an image file 63 GB in size...
truncate is a good tool. You need to shrink the image, so it contains every partition defined in the partition table. In other words, if the end sector of the partition closest to the end is N (note it doesn't have to be the partition with the highest number), you need N+1 sectors of the image (+1 because numbering st...
Problem creating a disk image of an SD card
1,643,325,291,000
I recently was trying to flash from an IMG file with dd, and it took a lot shorter than normal, and when I checked the drive, it had names like \u2584\u00bc\u2591+\u03c6\u256bv\u2559.| I don't know if I'm being stupid, or if it's a drive error. This is the code I used: sudo dd if=~/Downloads/tails-amd64-4.20.img of=...
Thanks, Toby, I had switched up two files when downloading multiple files, so I accidentally renamed a zip into it. Thanks! Yeah, I was just being stupid.
dd command ruining files [closed]
1,643,325,291,000
I want to print output of below command to file, can you help me I tried 2>&1 even 2>> also dd if=/dev/random bs=1 count=1000 status=progress |split -b 10 -a 10 I have other dd command that works for me like below dd if=/dev/zero of=/home/sl/workspace/test bs=1024 count=2097152 status=progress 2>&1 | awk 'NR==4' ...
$ dd if=/dev/random bs=1 count=1000 status=progress 2> speed.test |split -b 10 -a 10 $ cat speed.test 1000+0 records in 1000+0 records out 1000 bytes (1.0 kB) copied, 0.00176463 s, 567 kB/s There's nothing wrong with your command. You just need to look for the created files as in xaa, etc. in the current directory. ...
how to get split commands output to file
1,643,325,291,000
I am using dd to return a stream of data from tape. I want to send this via a pipe that will extract the byte range I require. I need to check for the presence of a string in the initial bytes, and based on that value the byte range will differ. Something like this... dd if=/dev/tape/st0 bs=512K | { var=1; if [[ $(hea...
Consider the following untested code: dd if=/dev/tape/st0 bs=512K | { skip=512 if [[ $( head -c 13 ) == "././@LongLink" ]]; then skip=$(( skip*3 )) fi dd of=extracted_file.bin skip="$skip" iflag=skip_bytes } This passes the data from the initial dd into a compound command. The compound comman...
Conditional logic and variables in pipe to determine value for dd skip
1,643,325,291,000
i installed new debian 9.8 server for DB application.it has two disk and running on vCenter 6.0. First write disk write speed 100-120 Mb/sec suddenly after for while disk write speed decrease drastically to 1-5 Mb/sec. i change datastore totaly different storage- same problem continued i updated kernel to new one(5....
Long time research and digging on google's deep depth finally find the problem.But i'm do not what is root cause. The problem was CPU.Firstly we create the VM 2*4 vCPU then today i read about Debian bug forum archive about Intel(R) Xeon(R) CPU E5-2xxx family then the holy moment dunk my head. Reduce the vCPU 1x1. Pr...
Slow disk write speed
1,643,325,291,000
A source HDA (2TB mechanical HDD) has 5 partitions on it (GPT) that used to occupy the entire capacity of the 2TB HDA. The Operating System resident on the source drive is Windows 10. Since the majority of the 'data' partition was unused storage space, and occupied 1.5TB of the drive capacity, it was shrunk, using gpa...
OK....following Kusalananda's recommendation, I've shared what worked for me, in this situation, as an update to my original post, and will refrain from duplicating what I typed, up there, in this space. Seemingly, the method, detailed above, will not be easily implemented if ready access to, or the means of creating,...
In LINUX: Using dd to transfer shrunk partitions on a 2TB HDD to a 500GB SSD
1,643,325,291,000
Let's say that I set the block size of dd or ddrescue to 256K. A sector of flash drives usually has 512 bytes, a sector on optical data discs has 2048 bytes. Let's assume that in the next 256 KB, just one sector is unreadable. Every other sector is readable. What happens to the multiblock transfer? Does it transfer a...
Example command without abbreviating options/switches: sudo ddrescue --direct --sector-size=20480 --verbose --verbose --retry-passes="-1" /dev/sr5 If one out of the ten sectors in the 20480 next bytes is damaged, the entire 20480 bytes will not be saved. Finer grain: sudo ddrescue --direct --sector-size=2048 --verbose...
Unreadable block in multiblock reading on dd / ddrescue: How does it handle it?
1,643,325,291,000
I need to clone a bootable disk to multiple disks (of different sizes) on different computers and it needs to be scriptable, but I can't find a way to do it. I'm using Ubuntu 16.04 on everything. First I tried dd, I ran (with the disk unmounted): $ dd if=/dev/sda bs=1K count=10000000 status=progress | gzip -c > os.img...
The problem is that the size of the source disk is larger than (some of the) destination disk(s). Which means the partition table doesn't work, because it's made for a disk of different size. In your place, I'd write a script that uses fdisk etc. to first delete all partitions on the disk, then makes a partition of fi...
Scriptable way to clone source disk to multiple destination disks?
1,524,738,532,000
Taking from here, there is a steganography part in an image file called moon.png. It led me thinking, how would I extract a say Zlib that is between 944 and 411781 using something like dd. $> binwalk moon.png DECIMAL HEXADECIMAL DESCRIPTION ------------------------------------------------------------------...
The author actually extracted the ZIP part from the file. That begins at 411781. By default the rest of the file from there is copied. skip moves over the specified number of blocks (since bs=1, 1 block is 1 byte) from the beginning before copying. So to get the 'zlib' part you would want: dd if=./moon.png of=./moon.z...
How to extract content from a single file by using two specified points with dd?
1,524,738,532,000
Know that my chances are small (if even there are :(). I have a HDD of 500G with 1 logical volume (ext4). By accident I overwrote it with an ISO of 1,5G: dd if=linuxmint-18-xfce-32bit.iso of=/dev/sdb Now I lost all data. Is there some way to re-create the logical volume to get some data back? I have the LVM backup fi...
I did not succeed to restore the partition since it missed the start of it. What I did was recovering most of my data with the tool photorec that is from the same author as testdisk. Before I could use it I had to create a partition that started after the ISO partition until the end of the disk. photorec searched this...
Recover LVM after overwrite with dd
1,524,738,532,000
I am running Fedora 22 on a Dell Laptop. I plan on migrating to a desktop soon which will also run Fedora 22. What is the best way to go about backing up and restoring my laptop configuration to the new system? I do not have any 3rd party backup/restore software on this system. Would dd be able to work for me? Would ...
There are several different options here, each with different effects and tradeoffs. Firstly, you probably don't want to do anything with dd. dd runs a block-level copy; it mirrors a disk image precisely, without caring about files. This will carry files in their associated filesystem along, but there are problems her...
How to backup and restore to different hardware in Linux? [duplicate]
1,524,738,532,000
As a domestic user wishing to get best value for it's money on external storage and a well encrypted and resilient backup discipline (having all time in the world). Please, is this a good use of dd? cp /Volumes/bkp/d1.img.dd.gz /Volumes/bkp/$(date +"%Y-%m-%d")-d1-bkp.img.dd.gz sudo dd bs=16M if=/Volumes/d1 | gzip -c ...
dd is the worst way to create backups: Enormous file sizes Near impossible to deduplicate data Near impossible to create incremental backups Doesn't allow to compress efficiently If your filesystem gets corrupted, you will backup inconsistent data In your examples above, why would you use it at all? cp /Volumes/bkp/...
dd (data/disk dump, copy and convert) best practices for backups in local external drives
1,524,738,532,000
List the file type on sdb: debian@debian:~$ sudo blkid |grep sdb /dev/sdb1: UUID="19a2c9fa-f793-415d-9e25-082fa3bbbb3d" TYPE="ext4" PARTUUID="eb3ae1bb-01" /dev/sdb2: UUID="11d2d221-e53e-4828-8e3e-50e63ffb01ce" TYPE="ext4" PARTUUID="eb3ae1bb-02" DD a image file into sdb1. debian@debian:~$ sudo dd if=openwrt-19.07.7-x...
I'm not sure what you're trying to do but by using dd you are taking the image and replacing the partition content (so the existing ext4 filesystem) with the image, which is a disk image -- it has a partition table, so you are creating a partition table on top of a partition (and this isn't supported so kernel won't t...
Keep the partition type unchange when to dd a file into it
1,524,738,532,000
I'm trying to figure out why my disk image is so much larger. Here is the source server's disks: root # df -h Filesystem Size Used Avail Use% Mounted on udev 1.9G 0 1.9G 0% /dev tmpfs 395M 7.1M 388M 2% /run /dev/sda 79G 43G 32G 58% / tmpfs 2.0G 0 2.0G ...
Using dd with no parameters is desperately inefficient - it will use 512 byte blocks for every read. You could adjust the dd blocksize (bs=32M, for example), but here are some easier and far faster alternatives # Compressed image ssh [email protected] "gzip --rsyncable </dev/sda" >/backup/server-images/west.img.gz # ...
Why is .img file so much larger than the actual disk?
1,524,738,532,000
I have a dd disk image. How can I check if it is consistent? (It doesn't have to be an exact copy.) I am trying to run extundelete, but I don't know if it's failing because the underlying filesystem is xfs, or because the image is corrupt.
Running fsck.xfs on the partition image would be a good way to know if the file is corrupted or not. Since it is a disk image rather than a partition image, you'll need to extract the partition from the disk. You can get its size and position from sfdisk -l -uS diskImageFile and then extract it with dd if=diskImag...
How can I check if a dd disk image is consistent (i.e. not corrupt)
1,341,916,713,000
I typed help while I was in the GDB but didn't find anything about step-into, step-over and step-out. I put a breakpoint in an Assembly program in _start (break _start). Afterwards I typed next and it finished the debugging. I guess it was because it finished _start and didn't step-into as I wanted.
help running provides some hints: There are step and next instuctions (and also nexti and stepi). (gdb) help next Step program, proceeding through subroutine calls. Usage: next [N] Unlike "step", if the current source line calls a subroutine, this command does not enter the subroutine, but instead steps over the call,...
How to step-into, step-over and step-out with GDB?
1,341,916,713,000
I am running the following command on my ubuntu server root@slot13:~# lxc-stop --name pavan --logfile=test1.txt --logpriority=trace It seems to hang indefinitely. Whenever this happened on AIX, I simply used to get the PID of the offending process and say $ procstack <pid_of_stuck_process> and it used to show the wh...
My first step would be to run strace on the process, best strace -s 99 -ffp 12345 if your process ID is 12345. This will show you all syscalls the program is doing. How to strace a process tells you more. If you insist on getting a stacktrace, google tells me the equivalent is pstack. But as I do not have it install...
How to know where a program is stuck in linux?
1,341,916,713,000
I feel like a kid in the principal's office explaining that the dog ate my homework the night before it was due, but I'm staring some crazy data loss bug in the face and I can't figure out how it happened. I would like to know how git could eat my repository whole! I've put git through the wringer many times and it's ...
Yes, git ate my homework. All of it. I made a dd image of this disk after the incident and messed around with it later. Reconstructing the series of events from system logs, I deduce what happened was something like this: A system update command (pacman -Syu) had been issued days before this incident. An extended net...
How did `git pull` eat my homework?
1,341,916,713,000
I have a command line application that when run does not do what it is supposed to do and at a certain point leaves the message: Segmentation fault What does this mean? What should I do?
A segmentation fault is the result of a memory access violation. The program has referred to a memory address outside of what was allocated to it, and the OS kernel responds by killing the program with SIGSEGV. This is a mistake, since there is no point in trying to access inaccessible memory (it cannot be done). Mi...
Running application ends with "Segmentation Fault"
1,341,916,713,000
I have a long running bash instance (inside a screen session) that is executing a complex set of commands inside a loop (with each loop doing pipes, redirects, etc). The long command line was written inside the terminal - it's not inside any script. Now, I know the bash process ID, and I have root access - how can I ...
I knew I was grasping at straws, but UNIX never fails! Here's how I managed it: bash$ gdb --pid 8909 ... Loaded symbols for /lib/i386-linux-gnu/i686/cmov/libnss_files.so.2 0xb76e7424 in __kernel_vsyscall () Then at the (gdb) prompt I ran the command, call write_history("/tmp/foo") which will write this history to the...
How can I see the exact command line being executed inside some bash instance?
1,341,916,713,000
Is there a tool that debugs routing tables on a Linux machine? I mean one that I can use by inputting an ip address into it, it'll take the existing routing table into account and output the matches from the table, so I can get an idea where the packets will go?
Use ip route get. From Configuring Network Routing : The ip route get command is a useful feature that allows you to query the route on which the system will send packets to reach a specified IP address, for example: # ip route get 23.6.118.140 23.6.118.140 via 10.0.2.2 dev eth0 src 10.0.2.15 cache mtu 1500 advms...
Tools for Debugging Routing Tables on a Linux Machine?
1,341,916,713,000
Is there a way to make gnu sed be verbose about what is run and what is done ? I'd like to have something like a "debug mode" so that I can see - for each line of input - the content of the hold space and pattern space before and after the script is run etc.
As fra-san mentioned, GNU sed introduced a --debug option which does pretty much what you’re looking for, in version 4.6; so e.g if you run: printf '%s\n' one two | sed --debug 'H;1h;$x;$s/\n/_/g' the output is SED PROGRAM: H 1 h $ x $ s/\n/_/g INPUT: 'STDIN' line 1 PATTERN: one COMMAND: H HOLD: \none C...
Any way to have a "verbose mode" or "debug mode" with sed?
1,341,916,713,000
The main way I know to debug scripts is adding -x to the shabang (#!/bin/bash -x). I recently came across a new way, adding set -euxo pipefail right under the shabang, as in: #!/bin/bash set -euxo pipefail What is the main difference between the two ways of debugging? Are there times you would prefer one above the ot...
First, I'm afraid that explanation of -o option served by http://explainshell.com is not entirely correct. Given that set is a bulit-in command, we can see its documentation with help by executing help set: -o option-name Set the variable corresponding to option-name: allexport same as -a ...
Debugging scripts, what is the difference between -x to set -euxo pipefail?
1,341,916,713,000
I'm getting these error messages every single time I reboot my desktop (and a couple of more I don't know how to retain when it's shutting down, but those are not relevant to this question so far): [gorre@uplink ~]$ journalctl -p err..alert ... -- Reboot -- May 11 21:47:03 uplink kernel: ACPI BIOS Error (bug): Failure...
Your hardware is too new sort of speak. The bugs you are seeing are harmless and may persist for some time. You could try upgrading your BIOS, that is utmost priority. Then, you could try installing intel-microcode non-free package. See if these two options work for you first. Today, I have assembled a computer with ...
ACPI BIOS Error / AE_NOT_FOUND
1,341,916,713,000
When I use GDB command add-symbol-file to load the symbol, GDB always asks me 'y or n', like this: gdb> add-symbol-file mydrv.ko 0xa0070000 add symbol table from file "mydrv.ko" at .text_addr = 0xa0070000 (y or n) How to make it not ask and execute quietly?
gdb will ask you to confirm certain commands, if the value of the confirm setting is on. From Optional Warnings and Messages: set confirm off Disables confirmation requests. Note that running GDB with the --batch option (see -batch) also automatically disables confirmation requests. set confirm on Enables confir...
How to make gdb not ask me "y or n"?
1,341,916,713,000
I have been working in embedded OS like uCOS, ThreadX. While I have coded apps in Linux, now I’m planning to start learning Linux Kernel. I have few questions regarding the environment. Which is best distro, which has easy to use tools for kernel development? (so far I had used RHEL and Fedora. While I am comfortable...
My personal flavor for Linux Kernel development is Debian. Now for your points: As you probably guessed Ubuntu doesn't bring anything new to the kernel to ease development afaik, apart from what's already available in Debian. For e.g. make_kpkg is a Debian feature and not Ubuntu. Here are some links to get you starte...
Kernel Hacking Environment
1,341,916,713,000
I know this question isn't very new but it seems as if I didn't be able to fix my problem on myself. ldd generate the following output u123@PC-Ubuntu:~$ ldd /home/u123/Programme/TestPr/Debug/TestPr linux-vdso.so.1 => (0x00007ffcb6d99000) libcsfml-window.so.2.2 => not found libcsfml-graphics.so.2.2 => not ...
if your libraries are not on standard path then either you need to add them to the path or add non-standard path to LD_LIBRARY_PATH export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<Your_non-Standard_path> Once you done any one of above things then you need to update the dynamic linker run-time binding by executing below comm...
ldd does not find path, How to add
1,341,916,713,000
I have two instances of a process running. One of them is "frEAkIng oUT!" and printing errors non stop to STDOUT. I want to kill the broken process but I have to make sure I don't terminate the wrong one. They were both started about at the same time and using top I can see they both use about the same amount of memor...
On Linux, assuming you want to know what is writing to the same resource as your shell's stdout is connected to, you could do: strace -fe write $(lsof -t "/proc/$$/fd/1" | sed 's/^/-p/') That would report the write() system calls (on any file descriptor) of every process that have at least one file descriptor open on...
How to find out what process is writing to STDOUT?
1,341,916,713,000
In bash, when running with the -x option, is it possible to exempt individual commands from echoing? I'm trying to make the output as neat as possible, so I am running certain parts of my script in a subshell with set +x. However, the row set +x itself is still echoed and adds no valuable information to the output. I ...
xtrace output goes to stderr, so you could redirect stderr to /dev/null: i_know_what_this_does() { echo do stuff } 2> /dev/null If you still want to see the errors from the commands run inside the functions, you could do i_know_what_this_does() ( { set +x; } 2> /dev/null # silently disable xtrace echo do stuff ...
bash: escape individual lines from `-x` echoing
1,341,916,713,000
I used to have Fedora 14 installed on this HP Compaq 610, and the suspend feature worked fine. Now that I've installed Scientific Linux 6.1 suspend doesn't work anymore. How do I debug/fix it?
There are many ways to handle suspend and hibernate capabilities, many of the old methods are deprecated. This has made searching for solutions difficult, as it seems every solution is completely unrelated to the next. With that said... The method currently recommended, advocated from http://pm-utils.freedesktop.org...
How to debug a suspend problem?
1,341,916,713,000
I got an USB gamepad and I would like to see and inspect the signals and commands that this peripherals is actually sending to my PC/kernel: how I can do that ? I was assuming that something like cat /dev/bus/usb/006/003 Was enough, but apparently this command returns immediately and prints some unreadable encoded c...
You can capture USB traffic with Wireshark. From its wiki: To dump USB traffic on Linux, you need the usbmon module, which has existed since Linux 2.6.11. Information on that module is available in /usr/src/linux/Documentation/usb/usbmon.txt in the Linux source tree. Depending on the distribution you're using, and th...
How to dump USB traffic?
1,341,916,713,000
I wrote a program that calls setuid(0) and execve("/bin/bash",NULL,NULL). Then I did chown root:root a.out && chmod +s a.out When I execute ./a.out I get a root shell. However when I do gdb a.out it starts the process as normal user, and launches a user shell. So... can I debug a setuid root program?
You can only debug a setuid or setgid program if the debugger is running as root. The kernel won't let you call ptrace on a program running with extra privileges. If it did, you would be able to make the program execute anything, which would effectively mean you could e.g. run a root shell by calling a debugger on /bi...
Can gdb debug suid root programs?
1,341,916,713,000
I know of strace, which is super handy for watching system calls. Is there an equivalent that can trace calls to external libraries? For example, I'm trying to debug some SSLeay misbehavior with a third-party binary that I cannot access the code for (and who's developer is unresponsive). I believe I have nailed down t...
ltrace -- A library call tracer. It only works on Linux and in a small subset of architectures. Calls to dlopen()ed libraries will not be traced. Further pointers from man page and /etc/ltrace.conf
strace for library calls
1,341,916,713,000
In *nix world, is there a way for shell script to have information about which program has executed it? Example: /path/to/script1 /path/to/script_xyz in this imaginary scenario, script_xyz would have path information (/path/to/script1) or process PID of entity that have executed it. Note: I'm curious about different ...
There's often confusion between process forking and execution. When you do at the prompt of a bash shell. $ sh -c 'exec env ps' The process P1 issuing that $ prompt is currently running bash code. That bash code forks a new process P2 that executes /bin/sh which then executes /usr/bin/env, which then executes /bin/ps...
Is there a way for shell script to know which program has executed it?
1,341,916,713,000
Inspired by this question, titled: When are the built-in commands loaded to memory, while attempting to answer this I tried the following command and was a bit surprised that I couldn't run it: $ strace cd $HOME Is there a method I can make use of to run strace for the builtin commands to Bash?
If you think about how strace works then it makes total sense that none of the builtins to Bash would be traceable. strace can only trace actual executables, whereas the builtins are not. For example, my cd command: $ type cd cd is a function cd () { builtin cd "$@"; local result=$?; __rvm_project_rvmrc...
Is it possible to strace the builtin commands to Bash?
1,341,916,713,000
If an application crashes in Windows we can check the Event Viewer in the Administration tools to see what has crashed. Sometimes it has useful information others not, but it is a start. In linux if an application (any) crashes how one starts to trace what happened? Is there e.g. some central log or something similar?...
Is there e.g. some central log or something similar? The normal place for system logs is /var/log/. What gets put in each log depends on the syslog configuration, but commonly everything except logins goes to /var/log/syslog. This is no guarantee that individual applications will have left any clue there in the eve...
How can we trace problems of crashing programs in Linux?
1,341,916,713,000
When I run a command through strace utility I can see access errors such as access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) Now I've read somewhere that what's happening on the above line is that a linker is looking for optimized version of the command that I'm running but can't find ...
You probably don’t want to “solve” this problem; according to the Debian glibc manpage for ld.so, /etc/ld.so.nohwcap When this file is present the dynamic linker will load the non-optimized version of a library, even if the CPU supports the optimized version. It’s not installed by a package, it can be create...
Where to get "/etc/ld.so.nohwcap" file from? [duplicate]
1,341,916,713,000
I'm hoping to get experience-based suggestions on how to go about debugging suspend-to-RAM issue. Advice specific to my situation(detailed below) would be great, but I am also interested in general advice about how to debug such issues. The problem: Often, when I attempt to suspend my machine, it gets stuck in a "not...
Do you have an Intel graphics chipset? I was getting what sounds like the same problem on my ThinkPad X200s running Ubuntu 10.10, and this workaround (from 2008!) fixed it for me: http://ubuntuforums.org/showpost.php?p=6105510&postcount=12
How can I debug a Suspend-to-RAM issue on Linux?