简体   繁体   English

如何将主目录中的文件夹复制到外部硬盘驱动器

[英]how to copy the folder in my home directory to the external hard drive

I am running linux - and I am new to it. 我正在运行linux-我是新手。

I want to copy a folder to the external hard drive. 我想将文件夹复制到外部硬盘驱动器。

How to copy the folder, called martin , which resides in my /home directory to an external hard drive? 如何将位于/home目录中的名为martin的文件夹复制到外部硬盘驱动器?

btw: see here what is in my /home : 顺便说一句:在这里看到我的/home

martin@linux-70ce:/home> ls -l
insgesamt 32
drwx------  2 root   root  16384 12. Mai 2013  lost+found
drwxr-xr-x 54 martin users 16384 26. Jul 04:42 martin
martin@linux-70ce:/home> 

I want to copy the folder called martin. 我想复制一个名为Martin的文件夹。

I guess the external hard drive has the following path: 我猜外部硬盘驱动器具有以下路径:

/var/run/media/martin/32_00_00/a_backup_martin_samsung

To make sure I ran the mount command....see below the results: 为了确保我运行了mount命令...。请参见以下结果:

martin@linux-70ce:~> mount
devtmpfs on /dev type devtmpfs (rw,relatime,size=1535300k,nr_inodes=208289,mode=755)
tmpfs on /dev/shm type tmpfs (rw,relatime)
tmpfs on /run type tmpfs (rw,nosuid,nodev,relatime,mode=755)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000)
/dev/sda6 on / type ext4 (rw,relatime,data=ordered)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=27,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
tmpfs on /var/run type tmpfs (rw,nosuid,nodev,relatime,mode=755)
tmpfs on /var/lock type tmpfs (rw,nosuid,nodev,relatime,mode=755)
/dev/sda7 on /home type ext4 (rw,relatime,data=ordered)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=100)
gvfsd-fuse on /var/run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=100)
/dev/sdb1 on /run/media/martin/32_00_00 type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
/dev/sdb1 on /var/run/media/martin/32_00_00 type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
martin@linux-70ce:~> 

Please advice. 请指教。

Many thanks in advance. 提前谢谢了。

update: 更新:

By the way: what if I get some errors during the process - due to permission-issues (cannot read the file); 顺便说一句:如果在处理过程中遇到一些错误-由于权限问题(无法读取文件),该怎么办; question: does the program keep runnning and does all the rest of the copying!? 问题:程序是否保持运行状态,是否进行其余所有复制!?

As reported by mount , your drive is mounted in /var/run/media/martin/32_00_00 not /var/run/media/martin/32_00_00/a_backup_martin_samsung . 根据mount报告,您的驱动器安装在/var/run/media/martin/32_00_00而不是/var/run/media/martin/32_00_00/a_backup_martin_samsung You can copy your whole directory to that mounted directory with 您可以使用以下命令将整个目录复制到该挂载目录:

cp -a martin /var/run/media/martin/32_00_00/

Or if you want it copied as a renamed folder granting that /var/run/media/martin/32_00_00/a_backup_martin_samsung does not exist: 或者,如果您希望将其复制为重命名文件夹,则授予/var/run/media/martin/32_00_00/a_backup_martin_samsung不存在:

cp -a martin /var/run/media/martin/32_00_00/a_backup_martin_samsung

Or you can rename it to another more meaningful name: 或者,您可以将其重命名为另一个更有意义的名称:

cp -a martin "/var/run/media/martin/32_00_00/martin-backup-$(date +%F)"

Which would copy /home/martin as something like /var/run/media/martin/32_00_00/martin-backup-2014-07-26 . 它将/home/martin复制为/var/run/media/martin/32_00_00/martin-backup-2014-07-26

And I recommend using -a over -r as it doesn't dereference links and it preserves all properties. 我建议使用-a over -r因为它不会取消引用链接,并且会保留所有属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM