Mint 18.1 Cinnamon cpio command help

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
deepakdeshp
Level 20
Level 20
Posts: 12337
Joined: Sun Aug 09, 2015 10:00 am

Mint 18.1 Cinnamon cpio command help

Post by deepakdeshp »

Hello,
I am having 2 ext hdds and I want to copy 1000s of files and 100s of folders from first one to the 2nd external Hdd. This is because the first HDD is showing signs of failure.
A lot of data is involved, to the tune of 400GBs , The 2nd HDD size is different than the first one, It is 8 times the capacity.
I was looking for a method to efficiently copy the files. One way is to use cpio to duplicate the file structure with a big block size ,something like

Code: Select all

find . -depth -print0 | cpio --null -pvd new-dir
. But here I dont know how to use block size. I haave 8 GB memory,

I will be thankful for any suggestions.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help.
Regards,
Deepak

Mint 21.1 Cinnamon 64 bit with AMD A6 / 8GB
Mint 21.1 Cinnamon AMD Ryzen3500U/8gb
BrianD

Re: Mint 18.1 Cinnamon cpio command help

Post by BrianD »

are you married to the idea of using cpio? I prefer dd, as it 'seems' more straightforward to me.

let's say your aging disk (with the thousands of files and hundreds of folders) is on /dev/sdb, and your new disk is on /dev/sdc -- the dd command line to copy *everything* from /dev/sdb to /dev/sdc would be:

dd if=/dev/sdb of=/dev/sdc bs=4M

-- that sets the "in-file" (if=) to /dev/sdb, sets the "out-file" (of=) to /dev/sdc and sets the block size for the copy operation to 4 megabytes.

NOTE:

dd does not "understand" file types, partition formatting, etc. it reads the raw device specified in the if= parameter and writes to the raw device specified in the of= parameter. As such, at the completion of the operation, your new (8x bigger!) hard drive may appear to be only the size of the old hard drive; fear not - simply open GParted and correct the partition size (you can leave it as it copied, and create an additional new partition(s) in the available space on your new drive, or you can expand (grow) the existing partition to whatever size you'd like, up to and including the entire drive capacity.

Incidentally - I used this very method when I installed a newer (bigger) hard drive in my Aspire One netbook. Using dd, I cloned the 160G drive over to my new 750G drive. The new drive (temporarily) looked like a 160G drive, but GParted showed me the rest of the drive and allowed me to make several partitions on it. I still had the Windows 7 Starter OS in the first partition (from the dd copy of the original hard drive), and was able to create a Linux Mint (13 Maya) partition, a Fedora partition, a shared DATA partition (formatted as NTFS, so as to work across all the OSes on the netbook), and (of course!) the Linux swap partition.

5 years later: I hardly ever use the Windows partition (I still need it to update the maps on my [can you believe it??] Linux-based TomTom GPS unit, but otherwise never used it); the Fedora partition was used one evening (while bored) just to check out Fedora 17. Just this past weekend, the Fedora 17 partition was deleted and a new Mint 18.2 partition was created in its place. I see, upon logging into these forums for the first time in several years, that I wasted no time getting Mint 18 installed -- it appears support is going away for my Mint 13 installation in just a few days.

Anyway, good luck with your data recovery operation. Let us know how it turns out.
deepakdeshp
Level 20
Level 20
Posts: 12337
Joined: Sun Aug 09, 2015 10:00 am

Re: Mint 18.1 Cinnamon cpio command help

Post by deepakdeshp »

Thank you Brian for your reply.
I have already have 260 GB of data on sdc. If I use the dd command as suggested by you,it will over write the old contents of sdc.
I had used cpio in the past but have forgotten
how to use block size. cpio is a pretty elegant solution,believe me.
Tar should work too but again I forgot the flags for tar too.
If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help.
Regards,
Deepak

Mint 21.1 Cinnamon 64 bit with AMD A6 / 8GB
Mint 21.1 Cinnamon AMD Ryzen3500U/8gb
User avatar
karlchen
Level 23
Level 23
Posts: 18211
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: Mint 18.1 Cinnamon cpio command help

Post by karlchen »

The command

Code: Select all

info cpio
will give you a lot of entertaining pages to read about how to use cpio. :)
The command

Code: Select all

info tar
will be better suited in case your time to read is a bit limited. :wink:
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 771 days now.
Lifeline
deepakdeshp
Level 20
Level 20
Posts: 12337
Joined: Sun Aug 09, 2015 10:00 am

Re: Mint 18.1 Cinnamon cpio command help

Post by deepakdeshp »

karlchen wrote:The command

Code: Select all

info cpio
will give you a lot of entertaining pages to read about how to use cpio. :)
The command

Code: Select all

info tar
will be better suited in case your time to read is a bit limited. :wink:
For the cpio command I used above -p flag, and with p there is no block size flag. So looks like I need to examine and experiment again.
If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help.
Regards,
Deepak

Mint 21.1 Cinnamon 64 bit with AMD A6 / 8GB
Mint 21.1 Cinnamon AMD Ryzen3500U/8gb
BrianD

Re: Mint 18.1 Cinnamon cpio command help

Post by BrianD »

deepakdeshp wrote:Thank you Brian for your reply.
I have already have 260 GB of data on sdc. If I use the dd command as suggested by you,it will over write the old contents of sdc.
I had used cpio in the past but have forgotten
how to use block size. cpio is a pretty elegant solution,believe me.
Tar should work too but again I forgot the flags for tar too.
Ah.. sorry. I assumed you had bought a new (much bigger) disk to replace the one on the brink of failure.

cpio should be fairly straightforward (or tar, if you want)... something like

log into the terminal as root (admin) user, then:

Code: Select all

cd /drive_1_mountpoint
find . -print -depth | cpio -pdm /drive_2_mountpoint

# eventually, the above command will produce an output line indicating how many blocks were copied, like this:
# XXXXXX blocks
# then, simply verify that the files copied to the output directory and remove the originals (or just unplug the drive and toss it in the closet.   :wink: 

cd /drive_2_mountpoint
ls
rm -rf /drive_1_mountpoint

find and cpio switches used above, explained:
  • . starts in the current working directory.
    -print prints the file names.
    -depth descends the directory hierarchy and prints file names from the bottom up.

    -p creates a list of files.
    -d creates directories as needed.
    -m sets the correct modification times on directories.

Locked

Return to “Software & Applications”