简体   繁体   中英

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

I am running linux - and I am new to it.

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?

btw: see here what is in my /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.

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:

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 . 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:

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 .

And I recommend using -a over -r as it doesn't dereference links and it preserves all properties.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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