I have an odroid (raspberry-like) machine with an arch linux system installed. Now I want to move the system from one microsd (A) to another microsd (B). When I tried this, the system became corrupted, information about files attributes were lost:
Copy files from A to osx-host cp -R /Volume/microsd_a/* ~/Desktop/backup
Copy files from osx-host to B cp -R ~/Desktop/backup/* /Volume/microsd_b
Is it real to copy linux-system using osx-host with preserving integrity?
Update:
dd. I tried this way, but there is a problem. My sd cards have different sizes, 64 Gb and 16 Gb, but system installed on 64 Gb disk has no more than 8 Gb. So when I launched the copying process, output image file exceed 16 Gb and I killed the process. By the way, the MBR contains information about partition table which should be different (one partition 64Gb / one partition 16 gb). And notice, I do not need to copy bootloader from MBR, I have an ability to flash disk bootloader by other ways.
cp. What I wanted to listen as the answer is the list of flags I need to make this operation. Reading man cp didn't help me. cp -a does not copy all files because of Cannot allocate memory error. Tried cp -aX, no attributes were restored after copying data to second sdcard.
tar. I tried multiple times with flags, last one was tar -cvpf; tar --same-owner -xpf. But file attributes were still corrupted.
Again:
- Are you sure, it is possible to preserve file attributes through copying ext4 -> APFS -> ext4?
- If this is possisble, how does it work and which command with which flags should I use?
cp -R results in change of permissions, time stamps and missing of hidden files, you can't use that command to create a disk image.
what you need is a disk copy/clone. The command to use is dd.
Check out this webpage:
https://pbxbook.com/other/dd_clone.html
Related
Context:
I am transferring a backup dir from Server A to Server B.(RHEL)
Directory size (to be transferred) on Server A: 48GB
Available space on Server B: 154GB
Command I'm using on Server A(user: root):
scp -r -C <nameof-backup-dir> user#severB:/path
Unexpected Behaviour:
The backup directory appears on the target server B #/path occupying all available 154GB of space.
Meanwhile the SCP run on the source server A terminates with an "Insufficent space message" for the remaining files.
Question/Help needed:
What am I doing wrong here?
What changes do I need to make to the SCP command to achieve the result?
One thing I can think of is that block sizes are different.
If block size on the destination machine is bigger, small files will occupy more space.
To find out block size :
sudo tune2fs -l /dev/sda1 | grep -i 'block size'
# Replace /dev/sda1 with your device (found out with command [df])
If it's indeed the case, you can recreate destination file system with the same block size as the source file system.
I am using opensuse, specific the variant on mono's website when you click vmware
I get this error. Does anyone know how i might fix it?
make[4]: Entering directory `/home/rupert/Desktop/llvm/tools/clang/tools/driver'
llvm[4]: Linking Debug+Asserts executable clang
collect2: ld terminated with signal 9 [Killed]
make[4]: *** [/home/rupert/Desktop/llvm/Debug+Asserts/bin/clang] Error 1
The full text can be found here
Your virtual machine does not have enough memory to perform the linking phase. Linking is typical the most memory intensive part of a build since it's where all the object code comes together and is operated on as a whole.
If you can allocate more RAM to the VM then do that. Alternatively you could increase the amount of swap space. I am not that familiar with VMs but I imagine the virtual hard drive you set-up will have a swap partition. If you can make that bigger or allocate a second swap partition that would help.
Increasing the RAM, if only for the duration of your build, is the easiest thing to do though.
Also got the same issue and solved by doing following steps (It is memory issue only) -
Checks current swap space by running free command (It must be around 10GB.).
Checks the swap partition
sudo fdisk -l
/dev/hda8 none swap sw 0 0
Make swap space and enable it.
sudo swapoff -a
sudo /sbin/mkswap /dev/hda8
sudo swapon -a
If your swap disk size is not enough you would like to create swap file and use it.
Create swap file.
sudo fallocate -l 10g /mnt/10GB.swap
sudo chmod 600 /mnt/10GB.swap
OR
sudo dd if=/dev/zero of=/mnt/10GB.swap bs=1024 count=10485760
sudo chmod 600 /mnt/10GB.swap
Mount swap file.
sudo mkswap /mnt/10GB.swap
Enable swap file.
sudo swapon /mnt/10GB.swap
I tried with make -j1 and it works!. But it takes long time to build.
I had the same problem building on a VirtualBox system. FWIW I was building on a laptop with XP and 2GB RAM. I had to bump the virtual RAM up to 1462MB to get a successful build. Also note the recommended disk size of 8GB is not sufficient to build and install both LLVM and Clang under Ubuntu. I'd recommend at least 16GB.
I would suggest using of -l (--max-load) option instead of limiting -j in this case. Possibly helpful
answer.
I created an image of debian 7 on an SSD disk and later restored it on another computer with excatly same type of SSD disk. however I'm getting the error message No bootable device -- insert boot disk and press key
The image was created using a live OS with the command: dd if=/dev/sda conv=sync,noerror bs=64K | gzip -c > backup.img.gz
And later restored to disk with:
gunzip -c backup.img.gz | dd of=/dev/sda
I've done this plenty of times before on older computers and it usually works fine. These computers has EFI, could this be the issue? Any ideas, or workarounds?
Thanks
Do you use MBR or GPT on SSD?
Possibly you will need to switch between UEFI/LEgacy boot mode as shown here:
https://phoenixts.com/blog/uefi-vs-legacy-bios/
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
You can find plenty of info online about using dd to clone OS drives.
Don't listen! It's MUCH faster to use dump and restore because you only copy the data, rather than copying all the blocks (empty or not).
Part 1: Know where your source and destination drives are in the device list
lsscsi | grep sd*
will show you a list of scsi devices and their associated letters. If you are lucky enough to be working with a hot-swapable box, then you can simply run that command before and then after you insert the drive--the newest device to show up is, of course, the drive you just inserted.
Part 2: Prepare to dump
Safety tip: assign variables for the destination and source devices. (Also, if you are doing this more than once, variablization allows you to reuse the commands.)
SOURCE=/dev/sdx DEST=/dev/sdy
A note on the source drive (the one you are copying from). If you are copying the current OS drive, it will (duh) already be mounted. If you are copying a different drive, it actually doesn't need to be mounted.
Copy the partition table of your source drive out to a file:
sfdisk -d $SOURCE > part_table
Copy the part_table already stored in a file
sfdisk --force $DEST < part_table
Zero out the boot sector: dd if=/dev/zero of=${DEST}1 bs=512 count=1
Make your filesystem (one partition at a time):
mkfs -t ext4 ${DEST}1
mkswap ${DEST}2
Take a look: parted $DEST --script print
Copy the label of all non-swap partitions. Example: tune2fs -L "/" /${DEST}1
Part 3: The dump | restore moment
Make a directory to mount the destination device of the dump | restore. (As mentioned above, source device need not be mounted.)
mkdir -p /mnt/${DEST}1
Mount the destination device:mount -t ext4 ${DEST}1 /mnt/${DEST}1
cd into the mount point:cd /mnt/${DEST}1
Dump and restore: dump -a0f - /dev/${SOURCE}1 | restore -rf -
(dump flags: a=autosize; 0 (zero)=start at block 0; f = file, - = stdout; restore flags: r=rebuild; f=file; - = stdout)
The dump | restore should take just a few minutes.
Part 4: use grub to install a boot loader onto the cloned drive
Assuming you are copying an OS drive (i.e., a drive off which you boot a box), you need to install a boot loader.
Grub identifies disks as hd#, starting from 0 (NOT 1). The correspondence is easy: /dev/sda = hd0, /dev/sdb = hd1, etc.
[root#drive-toaster /]# grub
grub> root (hd1,0) # use correct number for your disk!
root (hd1,0)
Filesystem type is ext2fs, partition type 0x83
grub> setup (hd1) # use correct number for your disk!
setup (hd1)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd1)"... 27 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd1) (hd1)1+27 p
(hd1,0)/boot/grub/stage2 /boot/grub/grub.conf"... succeeded
Done.
grub> quit
I have mounted a xen guest partition on /dev/mapper/vg01.
I also create a file let say in /home/user/a.txt
then I also ssh to the guest server and create file in /home/user/b.txt
in the terminal i did not see a.txt, b.txt
also the same in the mounted partition. i only see a.txt not b.txt
how can i fix this ? or maybe there is some other way for me to change the file ?
You can't mount a non distributed local filesystem from multiple locations at the same time, you'll end up corrupting it.