LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How do I mount External Hard Drive and what command to backup Home Folder to it ? (https://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-mount-external-hard-drive-and-what-command-to-backup-home-folder-to-it-905792/)

mansour 09-30-2011 11:21 AM

How do I mount External Hard Drive and what command to backup Home Folder to it ?
 
Hello:


On ubuntu 10.10 notebook edition, that won't boot due to /sbin/init being damaged, how would I mount the External Hard Drive and then what command would I use to backup my Home Folder to External Hard Drive , using live CD?
I am hoping to salvage my Home Folder and then do a Re-install of my ubuntu 10.10 notebook edition.

Using Live CD when I go to my home folder, I can see all the partitions on the old system and their size, but how would I back up the Home Folder to the external HD?



mansour

MedicalNerd 09-30-2011 01:18 PM

The external hard drive should be auto-mounted by the live cd.

To mount the partition in which resides your home folder, the command line is your friend:

1) first you have to create the directory that you'll use as mount point:
Code:

sudo mkdir /media/mypartition
2) then, mount the partition in which resides your home folder (let's say /dev/sda1)
Code:

sudo mount /dev/sda1 /media/mypartition
4) copy to the external hard drive.
For example:
Code:

cp -R /media/mypartition/home/yourusername /path/to/external/hard/drive
If you want to do things graphically, you can open nautilus in the home folder of the mounted partition:

Code:

$ cd /media/mypartition/home/yourusername
$ nautilus .

Hope these help.

mansour 09-30-2011 01:23 PM

Quote:

Originally Posted by MedicalNerd (Post 4486602)
The external hard drive should be auto-mounted by the live cd.

To mount the partition in which resides your home folder, the command line is your friend:

1) first you have to create the directory that you'll use as mount point:
Code:

sudo mkdir /media/mypartition
2) then, mount the partition in which resides your home folder (let's say /dev/sda1)
Code:

sudo mount /dev/sda1 /media/mypartition
4) copy to the external hard drive.
For example:
Code:

cp -R /media/mypartition/home/yourusername /path/to/external/hard/drive
If you want to do things graphically, you can open nautilus in the home folder of the mounted partition:

Code:

$ cd /media/mypartition/home/yourusername
$ nautilus .

Hope these help.



Ok, I performed all the above commnads in the terminal.
But it didn't work. I couldn't copy to mypartition directroy. I suspect has to do with the fact that my External Usb Drive is an NTFS file system?


mansour

MedicalNerd 09-30-2011 04:08 PM

Exactly, what happens? performing the commands results in error messages?

(ps don't forget to unmount with the umount command)

mansour 09-30-2011 04:31 PM

Quote:

Originally Posted by MedicalNerd (Post 4486713)
Exactly, what happens? performing the commands results in error messages?

(ps don't forget to unmount with the umount command)

Code:


ubuntu@ubuntu:~$ cp -R /media/mypartition  /dev/sdb1/mypartition
cp: accessing `/dev/sdb1/mypartition': Not a directory
ubuntu@ubuntu:~$ cp -R /media/mypartition  /dev/sdb1/
cp: accessing `/dev/sdb1/': Not a directory
ubuntu@ubuntu:~$ ^C
ubuntu@ubuntu:~$

I am soooo.... lost.




mansour

yancek 09-30-2011 06:27 PM

Quote:

But it didn't work. I couldn't copy to mypartition directroy. I suspect has to do with the fact that my External Usb Drive is an NTFS file system?
Probably not but it isn't a good idea to copy directories/files from a Linux filesystem to a windows filesystem. I wouldn't expect anything but trouble from it.

I would suggest that if you are doing this from an Ubuntu CD, you run the sudo fdisk -l(lower case Letter L in the command) and post that drive/partition information here. If your external is auto-mounted it probably is in the /media directory with a UUID number. You will need to create a mount point for your external partition if you are going to use a terminal to copy to it. Post the fdisk output.

ghoultek 09-30-2011 06:38 PM

Try doing the following:
- Boot your laptop with the LiveCD
- Once you are at the desktop, connect your external hard drive to your laptop
- Start a Terminal window

In the following order:
- Type lsusb
- Type su (this should get you root access)
- Type fdisk -l
- Type mount
- Type cat /etc/fstab

Post the results of those commands.

Update: I tried sudo on my fresh Slackware v13.37 install when logged in as a regular user (non-root and non-super user) and it gave me an error message stating that my regular user account is not in the sudoers file. However, su just asks for the root password if I boot into Slackware. If I boot a Knoppix v6.7.1 LiveCD su doesn't require a password for root. I suspect the Ubuntu LiveCD may not require a password for su. If sudo doesn't work try su.

Larry Webb 09-30-2011 08:10 PM

OP is using ubuntu and for root access he should be using 'sudo' to start his command lines. With the live cd he will not be asked for a password.

yancek is right and all we need is the uuid and the following should solve all.

Quote:

I would suggest that if you are doing this from an Ubuntu CD, you run the sudo fdisk -l(lower case Letter L in the command) and post that drive/partition information here

snooly 09-30-2011 08:45 PM

Quote:

Originally Posted by mansour (Post 4486728)
Code:


ubuntu@ubuntu:~$ cp -R /media/mypartition  /dev/sdb1/mypartition
cp: accessing `/dev/sdb1/mypartition': Not a directory
ubuntu@ubuntu:~$ cp -R /media/mypartition  /dev/sdb1/
cp: accessing `/dev/sdb1/': Not a directory
ubuntu@ubuntu:~$ ^C
ubuntu@ubuntu:~$

I am soooo.... lost.




mansour

Your commands are wrong. Something like this would be better:

mkdir /mnt/extdrive
mount /dev/sdb1 /mnt/extdrive
# check that /dev/sdb1 is mounted
mount
mkdir /mnt/tmphome
# you need to get the right partition to mount the home directories
mount /dev/sda???? /mnt/tmphome
# check that tmphome is mounted
mount
cp -a /mnt/tmphome /mnt/extdrive

This is for if /home is on its own partition. If it isn't, your cp command should be more like this:

cp -a /mnt/tmphome/home /mnt/extdrive

hf2046 09-30-2011 08:58 PM

Quote:

Originally Posted by snooly (Post 4486840)

This is for if /home is on its own partition. If it isn't, your cp command should be more like this:

cp -a /mnt/tmphome/home /mnt/extdrive

And your 'cp' command won't get all the hidden files and directories either. I recommend the OP use 'tar' in order to backup the contents of the home directory.

snooly 09-30-2011 09:18 PM

Quote:

Originally Posted by hf2046 (Post 4486849)
And your 'cp' command won't get all the hidden files and directories either. I recommend the OP use 'tar' in order to backup the contents of the home directory.

Sure use tar if you want. But cp -a does copy hidden files and directories. Test it if you don't believe it.

mansour 09-30-2011 09:40 PM

Quote:

Originally Posted by yancek (Post 4486777)
Probably not but it isn't a good idea to copy directories/files from a Linux filesystem to a windows filesystem. I wouldn't expect anything but trouble from it.

I would suggest that if you are doing this from an Ubuntu CD, you run the sudo fdisk -l(lower case Letter L in the command) and post that drive/partition information here. If your external is auto-mounted it probably is in the /media directory with a UUID number. You will need to create a mount point for your external partition if you are going to use a terminal to copy to it. Post the fdisk output.

Hi:


So this is the output of that command:

Code:


ubuntu@ubuntu:~$ sudo fdisk -l

Disk /dev/sda: 40.0 GB, 40007761920 bytes
255 heads, 63 sectors/track, 4864 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a129c

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          16      123904  83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              16        4864    38943745    5  Extended
/dev/sda5              16        989    7811072  83  Linux
/dev/sda6            989        1475    3905536  83  Linux
/dev/sda7            1475        1961    3905536  83  Linux
/dev/sda8            1961        2448    3905536  83  Linux
/dev/sda9            2448        3055    4881408  83  Linux
/dev/sda10          3056        3239    1475584  82  Linux swap / Solaris
/dev/sda11          3239        4864    13052928  83  Linux

Disk /dev/sdb: 1000.2 GB, 1000204885504 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa4b57300

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1      121601  976760000+  7  HPFS/NTFS
ubuntu@ubuntu:~$


mansour

mansour 09-30-2011 09:52 PM

Quote:

Originally Posted by ghoultek (Post 4486785)
Try doing the following:
- Boot your laptop with the LiveCD
- Once you are at the desktop, connect your external hard drive to your laptop
- Start a Terminal window

In the following order:
- Type lsusb
- Type su (this should get you root access)
- Type fdisk -l
- Type mount
- Type cat /etc/fstab

Post the results of those commands.

Update: I tried sudo on my fresh Slackware v13.37 install when logged in as a regular user (non-root and non-super user) and it gave me an error message stating that my regular user account is not in the sudoers file. However, su just asks for the root password if I boot into Slackware. If I boot a Knoppix v6.7.1 LiveCD su doesn't require a password for root. I suspect the Ubuntu LiveCD may not require a password for su. If sudo doesn't work try su.



Code:


ubuntu@ubuntu:~$ lsusb
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 003: ID 0bc2:2120 Seagate RSS LLC
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
ubuntu@ubuntu:~$ su
Password:
su: Authentication failure
ubuntu@ubuntu:~$ sudo -s
root@ubuntu:~# fdisk -l

Disk /dev/sda: 40.0 GB, 40007761920 bytes
255 heads, 63 sectors/track, 4864 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a129c

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          16      123904  83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              16        4864    38943745    5  Extended
/dev/sda5              16        989    7811072  83  Linux
/dev/sda6            989        1475    3905536  83  Linux
/dev/sda7            1475        1961    3905536  83  Linux
/dev/sda8            1961        2448    3905536  83  Linux
/dev/sda9            2448        3055    4881408  83  Linux
/dev/sda10          3056        3239    1475584  82  Linux swap / Solaris
/dev/sda11          3239        4864    13052928  83  Linux

Disk /dev/sdb: 1000.2 GB, 1000204885504 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa4b57300

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1      121601  976760000+  7  HPFS/NTFS
root@ubuntu:~# mount
aufs on / type aufs (rw)
none on /proc type proc (rw,noexec,nosuid,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
none on /dev type devtmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
/dev/sr0 on /cdrom type iso9660 (ro,noatime)
/dev/loop0 on /rofs type squashfs (ro,noatime)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
gvfs-fuse-daemon on /home/ubuntu/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=ubuntu)
root@ubuntu:~# cat /etc/fstab
aufs / aufs rw 0 0
tmpfs /tmp tmpfs nosuid,nodev 0 0
/dev/sda10 swap swap defaults 0 0
root@ubuntu:~#



mansour

yancek 09-30-2011 10:21 PM

The problem now is, which of the seven Linux partitions contains your home directory? You can eliminate sda1 as it is too small to be anything but a boot partition. sda2 is your Extended partition which contains no data and sda10 is swap. Do you have a separate /home partition or is it in your / partition? Why all these partitions if you only have Ubuntu? or do you?

The /etc/fstab file you posted is from the Live Cd and doesn't give any useful information.
Do you know where your /home directory is? on a separate partition? the / partition? do you know which partition that might be? If not you will probably have to try creating a mount point for each, mount each partition until you find your /home directory.

Repeat this process for each partition until you find it, partitions 5 - 11 (excepting 10 - swap) unless you know which partition it is??

sudo mkdir /mnt/sda5
sudo mount -t ext4 /dev/sda5 /mnt/sda5

After doing the above, you can navigate to the /mnt/sda5 partition to see if your /home is there: ls /mnt/sda5

You could also open nautilus file manager, sudo nautilus.

mansour 09-30-2011 10:53 PM

Quote:

Originally Posted by yancek (Post 4486879)
The problem now is, which of the seven Linux partitions contains your home directory? You can eliminate sda1 as it is too small to be anything but a boot partition. sda2 is your Extended partition which contains no data and sda10 is swap. Do you have a separate /home partition or is it in your / partition? Why all these partitions if you only have Ubuntu? or do you?

The /etc/fstab file you posted is from the Live Cd and doesn't give any useful information.
Do you know where your /home directory is? on a separate partition? the / partition? do you know which partition that might be? If not you will probably have to try creating a mount point for each, mount each partition until you find your /home directory.

Repeat this process for each partition until you find it, partitions 5 - 11 (excepting 10 - swap) unless you know which partition it is??

sudo mkdir /mnt/sda5
sudo mount -t ext4 /dev/sda5 /mnt/sda5

After doing the above, you can navigate to the /mnt/sda5 partition to see if your /home is there: ls /mnt/sda5

You could also open nautilus file manager, sudo nautilus.




This was our first school assignment, to create so many partitions manually, so to learn how manual partitioning works in Linux. I have two other Linux machine as part of a small network, which I let Linux do the partitioning for me. It was very simple. One is Ubuntu server 10.04 , the other is ubuntu 10.04 desktop.
So my /Home partition is the one which is 13 GB in size. (/dev/sda11 )

(It includes /root and /mansour )
When I go to Places ==> Home ==> I see all the partitions in the left pane. The 13 GB partition is /Home.

I can mount them all by right clicking on them and then choosing mount from the menu.



Code:


root@ubuntu:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
aufs                  244M  97M  148M  40% /
none                  239M  292K  238M  1% /dev
/dev/sr0              696M  696M    0 100% /cdrom
/dev/loop0            652M  652M    0 100% /rofs
none                  244M  112K  244M  1% /dev/shm
tmpfs                244M  24K  244M  1% /tmp
none                  244M  88K  244M  1% /var/run
none                  244M  4.0K  244M  1% /var/lock
/dev/sda11            13G  272M  12G  3% /media/dcfafdf7-abd7-4bd0-9fbd-94eac897da25
/dev/sda5            7.4G  659M  6.4G  10% /media/07c9d8a8-7822-4387-9c06-5fbf476716a8
/dev/sda6            3.7G  593M  3.0G  17% /media/0f01a0ed-78ad-4c75-8f00-b08126f56640
/dev/sda7            3.7G  72M  3.5G  3% /media/ac23e1a9-f23b-4455-969d-4aaadd61455a
/dev/sda8            3.7G  2.1G  1.5G  59% /media/5be965ac-feb2-4f0f-be42-d9f760573fe3
/dev/sda9            4.6G  504K  4.4G  1% /media/f20daefd-79f2-4ac3-a478-51bb3ff4c6f6
/dev/sda11            13G  272M  12G  3% /mnt/sda11
/dev/sdb1            932G  8.6G  923G  1% /media/FreeAgent Drive
root@ubuntu:~#

root@ubuntu:~#


Code:


root@ubuntu:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
aufs                  244M  96M  149M  40% /
none                  239M  292K  238M  1% /dev
/dev/sr0              696M  696M    0 100% /cdrom
/dev/loop0            652M  652M    0 100% /rofs
none                  244M  112K  244M  1% /dev/shm
tmpfs                244M  20K  244M  1% /tmp
none                  244M  88K  244M  1% /var/run
none                  244M  4.0K  244M  1% /var/lock
/dev/sda11            13G  272M  12G  3% /media/dcfafdf7-abd7-4bd0-9fbd-94eac897da25
root@ubuntu:~# df -T
Filesystem    Type  1K-blocks      Used Available Use% Mounted on
aufs          aufs      249848    98652    151196  40% /
none      devtmpfs      243936      292    243644  1% /dev
/dev/sr0  iso9660      712594    712594        0 100% /cdrom
/dev/loop0
          squashfs      667264    667264        0 100% /rofs
none        tmpfs      249848      112    249736  1% /dev/shm
tmpfs        tmpfs      249848        20    249828  1% /tmp
none        tmpfs      249848        88    249760  1% /var/run
none        tmpfs      249848        4    249844  1% /var/lock
/dev/sda11    ext3    12848048    277924  11917480  3% /media/dcfafdf7-abd7-4bd0-9fbd-94eac897da25
/dev/sda5    ext3    7688360    674448  6623360  10% /media/07c9d8a8-7822-4387-9c06-5fbf476716a8
/dev/sda6    ext2    3844152    606868  3042008  17% /media/0f01a0ed-78ad-4c75-8f00-b08126f56640
/dev/sda7    ext3    3844152    73244  3575632  3% /media/ac23e1a9-f23b-4455-969d-4aaadd61455a
/dev/sda8    ext2    3844152  2128852  1520024  59% /media/5be965ac-feb2-4f0f-be42-d9f760573fe3
/dev/sda9    ext2    4804736      504  4560164  1% /media/f20daefd-79f2-4ac3-a478-51bb3ff4c6f6
root@ubuntu:~# sudo mkdir /mnt/sda11
root@ubuntu:~# sudo mount -t ext3 /dev/sda11  /mnt/sda11
root@ubuntu:~# ls /mnt/sda11
Dir  for6.sh  Lab6copy  lost+found  mansour  root  test
root@ubuntu:~#


/dev/sdb1 is my USB Hard Drive.( 1 TB and is NTFS)
OK, I see a file was transfered to my USB HD called FreeAgentGoNext.ico
That's the name of my HD backup software.
I safely removed it from my notebook and put it on the ubuntu 10.04 desktop machine.
How would I be able to read them there though?
I mean FreeAgentGoNext.ico, what would I do to transfer this to the /home folder of ubuntu desktop machine?
Please help here.



Mansour


All times are GMT -5. The time now is 09:32 PM.