Score:0

How do I copy my Windows 7 derived files off my USB to Ubuntu?

in flag

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.

sudodus avatar
jp flag
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.
guiverc avatar
cn flag
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.
waltinator avatar
it flag
Read `man mount`, the sections on NTFS options
216ann avatar
in flag
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.
sudodus avatar
jp flag
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 avatar
jp flag
I am a little confused because you can copy some but not all files; 1. Is there free space in the target drive or is it full? 2. Are you prepared to start using the command line (commands in a terminal window)? In that case I can try to help you get started.
216ann avatar
in flag
Thanks. I have a nearly empty Ubuntu desktop HD. I would be thrilled to get some terminal commands. I have been researching cp and rsync but want to get it right. Another issue is that I know how to go to a file's properties in windows and then make a copy which erases all the properties which are allowed to be erased, but how do I do that in bulk (such as for the entire D drive folder and its subfolders/contents)? Is there a way to do that in Ubuntu? I want to remove my ex-BF's laptop's properties from the files. Thanks for understanding.
Score:1
jp flag

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
216ann avatar
in flag
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 avatar
in flag
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.
sudodus avatar
jp flag
@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 avatar
jp flag
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.
216ann avatar
in flag
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.
sudodus avatar
jp flag
What do you mean by anonymized? Are you talking about file content or file attributes (in file systems)? How do you intend to upload the files (individually or in tarballs or some other containers and via what kind of tool (ssh, or some web service via your web browser))?
sudodus avatar
jp flag
If you everything from the external drive, it should be `rsync -rtvn /mnt/ ~/oldwin1` dry run, and then remove the option `n` and do the real copying.
216ann avatar
in flag
Thanks again. I mean remove identifying attributes like who the author is, when/where it was created, owner/computer, etc. I want to avoid having to R click > properties > details > Remove properties and personal info > etc for each and every file. I was hoping there might be some FOSS or some other process where I can just erase all the properties that I can erase before I copy on to an external HD.
216ann avatar
in flag
I am referring to personal metadata. I found these two links but am not sure if either of these would work. https://superuser.com/questions/767544/how-to-remove-title-and-other-metadata-from-video-files https://www.ghacks.net/2011/09/25/how-to-remove-file-properties-in-windows/ I was unsuccessful at either. I just want to make sure that the metadata is erased for all the files I am copying over so that I don't have my ex's fingerprints on any of them. Thanks.
sudodus avatar
jp flag
@216ann, I don't think that you need to worry about file system attributes (ownership and permissions) after moving the files to Ubuntu and a Linux file system. But in some file types: pictures, documents, spreadsheets etc there are metadata ***in*** the files, and you need a tool to remove those metadata. I don't know how to do it, at least not well enough to be sure that everything will be wiped. -- **You should ask *new questions about removing metadata*. Ask here, and also at some Windows forum, or some forum for the particular tool that was used to create the files you worry about!**
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.