0

This seems to be a newbie question but I can't seem to find any specific answers. I am (finally) getting rid of my Windows 7 machine but need to copy all the data files off it to my Ubuntu. I transferred all the files onto a 2TB USB external HD. However, only some of the files are copying, I think because the permissions are not correctly set on those files. The files are tif, jpg, and pdf and I can open the files fine with Ubuntu programs (so not a matter of corrupted files). I realize that I can manually change the permissions of each and every file but I am talking about thousands. Is there a reliable way to change the permissions en masse on the USB external so that I can copy all the files over?

This post didn't seem to answer my question: USB drive will not let me copy/paste files, "permission denied" And other posts seem to talk about servers, dual boots, or virtual machines, none of which apply to this issue.

Or perhaps there is another issue that I am not aware of (eg, the USB external is NFTS formatted?).
Thanks in advance for the help.

7
  • 3
    It should work if you use superuser permissions, with sudo using cp or rsync in a terminal window. Are you prepared for that? -- NTFS iw a good file system if you want to share data between Ubuntu and Windows. But if you 'only' want to extract files from your Windows, you can boot the computer from a USB drive (the same drive as you used for installing Ubuntu), and write to a Linux file system. The standard files system of Ubuntu is ext4, and such a file system works better with Ubuntu. You can manage ownership and permissions individually and it runs faster.
    – sudodus
    Commented Aug 10, 2021 at 20:50
  • I'd do it as sudodus has already mentioned (via CLI or command line), however GUI tools do allow you to tag (tag all, tag, add existing file to tagged group, or add from all between last-tag & current tagged-file) - however these vary on file-manager in use, and you provided no specifics on release/flavor etc so we don't even know what apps you have as default. If one file-manager doesn't do exactly what you want, you can opt for another (install one); some do what you want ~easily - but I'd still opt for CLI.
    – guiverc
    Commented Aug 10, 2021 at 22:31
  • Read man mount, the sections on NTFS options
    – waltinator
    Commented Aug 11, 2021 at 0:26
  • 1
    Hi, thanks for the help. The USB is NFTS and represents the D drive of my Windows 7 computer. I have 20.04.2 LTS with no real add ons. I just used the GUI to pull over the files to a folder that I created. So obviously the wrong way. I can't quite understand your explanations of how I can get the Windows 7 data files into ext4 format. Should I keep my USB in the ext4 format? Won't it not work on Windows 7? Guiverc, not sure what tagging means will have to look up. I will also look up "man mount" Thanks.
    – 216ann
    Commented Aug 11, 2021 at 3:49
  • You can keep the NTFS file system in the external drive. The file content will be the same, it is independent of the file system, but you have better control of ownership and permissions individually for files and directories in ext4. The ownership and permissions of NTFS (actually all Microsoft file systems) is decided for 'everything' in a partition, when it is mounted, because Linux does not quite understand this proprietary file system.
    – sudodus
    Commented Aug 11, 2021 at 7:01

1 Answer 1

1

Copying files from Windows to dedicated directories in your Ubuntu

When booted into Ubuntu (an installed system or a live system booted from USB) you have the Linux tools for mounting file systems and copying files.

First, Windows should not be hibernated or semi-hibernated alias 'Fast Startup'. So either turn that off or reboot from Windows (and boot directly into Ubuntu). Otherwise the Windows file system will be in a 'dirty' state which can cause problems to copy.

If not automatically mounted, you can check the device id for the Windows partition (usually the biggest partition with the NTFS file system). In a wide terminal window (pull a corner to make it big enough)

lsblk -f
lsblk -m

and then mount it

sudo mount -o rw,user,umask=0000 /dev/sdXN /mnt

where X is the device letter, for example a and N is the partition number for example 2

or if an nvme drive

sudo mount -o rw,user,umask=0000 /dev/nvmeMnpN /mnt

where M is the nvme card number, usually 0, and N is the partition number for example 2.

Then decide where to copy, You may want to create a dedicated directory, for example oldwin1 in your home directory

cd
mkdir oldwin1

First check that it seems to copy what you want to where you want it. Please notice the trailing slash of the source directory

# sudo rsync -Havn source/ target # for advanced backup of Linux file systems

You do not want all files the belong to the Windows operating system, but only your personal files, so identify each directory tree, path1-to-top-of-directory-tree-to-copy ..., that you want to copy

Here we use another set of options. First check with a 'dry run' that things seem to work correctly in your case

rsync -rtvn "/mnt/path1-to-top-of-directory-tree-to-copy/" ~/oldwin1

When things look good you are ready to copy. Remove the option n from the command line and start the process

rsync -rtv "/mnt/path1-to-top-of-directory-tree-to-copy/" ~/oldwin1

You may have more than one such path, path1 path2 etc to copy to ~/oldwin1 ~/oldwin2 etc. Use a separate rsync command for each of them, so if necessary

cd
mkdir oldwin2
rsync -rtv "/mnt/path2-to-top-of-directory-tree-to-copy/" ~/oldwin2

etc.

When the copying is finished, you can unmount the Windows partition

sudo umount /mnt

This copy process should preserve the directory structure and modification times of the files, and make your userID owner of the files.

The details about the options are explained in the manual

man rsync
    -r, --recursive             recurse into directories
    -t, --times                 preserve modification times
    -v, --verbose               increase verbosity
    -n, --dry-run               perform a trial run with no changes made

Edit: If problems to read

If there are problems, because your regular user is not allowed to read the files from Windows, you can use elevated permissions with sudo

Dry run:

sudo rsync -rtvn "/mnt/path1-to-top-of-directory-tree-to-copy/" ~/oldwin1

Copying:

sudo rsync -rtv "/mnt/path1-to-top-of-directory-tree-to-copy/" ~/oldwin1

This will make root owner of the files, and you may want to fix that

sudo chown -R "$USER":"$USER" ~/oldwin1
10
  • Hey thanks for your help. I think I must have miscommunicated with you. It appears your instructions presume that I am getting the entire old HD and linking it perhaps with a external SATA cable.
    – 216ann
    Commented Aug 13, 2021 at 2:43
  • I simply copied the data files from the Win 7 onto an external HD and now am trying to change permissions, erase the properties (such as author, etc), and then copy all of it onto my Ubuntu desktop. Not certain if these commands would allow for that. Please let me know. Thanks.
    – 216ann
    Commented Aug 13, 2021 at 3:18
  • @216ann, Yes, I misunderstood, but I think I understand now. Anyway, if your external HDD has a partition with an NTFS file system, the answer should still be relevant, but probably simplified. You probably need only one rsync command line and there need not be any intermediate path1-to-top-of-directory-tree-to-copy/; Do you want me to modify the answer to make things show this?
    – sudodus
    Commented Aug 13, 2021 at 11:37
  • The ownership and properties seen by Linux in NTFS (and FAT32 and exFAT) are set when mounting and not individual. If/when you copy the directories and files to a Linux file system, you can either let the properties be set automatically (to defaults) or use chown and chmod afterwards to get what you want. - Unfortunately Linux can not manage the ownership and permissions, 'attrib', of Windows file systems.
    – sudodus
    Commented Aug 13, 2021 at 12:00
  • If Ubuntu can't modify attrib like in Win, how can I make sure all files in Ubuntu are anonymized, such as when I try to post or upload something? Also, is there a way to bulk anonymize the files in Win 7 BEFORE I copy them to the external HD? So just to be clear, I would do the same commands but not use the quotation portion which discusses, the /mnt path part? Thanks again for all the help.
    – 216ann
    Commented Aug 13, 2021 at 19:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .