Link to home
Start Free TrialLog in
Avatar of toyboy61
toyboy61

asked on

Moving a directory to another physical harddisk

Under my root file system in Ubuntu I have a directory called "Download". Unfortunately the physical hard disk where this directory is placed is now full. I mounted a new hard drive and formatted it with ext4 file system.

On this new hard drive I created a new directory called "Download" and moved all the content from the old "Download" directory to it. But now I wonder how I can make the Ubuntu system understand that the new "Download" directory is the directory to use.

Anyone ?
ASKER CERTIFIED SOLUTION
Avatar of gplana
gplana
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Rindi and Garry-G: Thank you for extending my explanation.
It depends on how you are managing the second drive. You could do as suggested.
Another options is that you can overlay a new partition on top of the one where you need the space.

i.e. instead of formating the new drive as a single partition.
You can split the drive into several logical partions using LVM.
Then you would copy the data you have
mount /dev/mapper/VolGroup* /mnt #mount the new partition temporarily
cd /Download #change to the directory from which you want the data copied
find . | cpio -pdvmu /mnt #copy the data note that should you have hard links to these files, they will have duplicate files
mv /Download /Download.orig
mkdir /Download
umount /mnt
mount /dev/mapper/VolGroup* /Download #adjust the /etc/fstab to make sure it comes up when the system boots.
chmod xxx /Download #to match the security settings on the /Download.orig

You're done.  This is also the method used if you need to increase size of an existing partition.

IMHO sym links may eventually lead to a point that you are on a treasure map trying to figure out what and where something really is.
Avatar of toyboy61
toyboy61

ASKER

@arnold: I tried to follow your advice, but I ran into problems:

"mount /dev/mapper/VolGroup* /mnt"
Error message: special device /dev/mapper/VolGroup* does not exist.

I'm running Ubuntu version 11.04 (64-bit if that's a point..).



/dev/mapper/VolGroup* is supposed to represent the lvcreate <logical_volume_name> you created.

Could you post the commands you performed thus far.
i.e. you partitioned the new drive as a single linux partition without mkfs?
you then run pvcreate /dev/sdx where /dev/sdx is the new Volume presented to the system currently unallocated.
You then ran vgextend <an existing Volumegroup> /dev/sdx
or create a new VolumeGroup on the new drive
vgcreate Newvolgroup /dev/sdx
See
tldp.org/HOWTO/LVM-HOWTO/

Please post the output of the following commands

fdisk -l #display current storage devices and how they are partitioned

pvdisplay #display physical devices
vgdisplay #display Volume Groups
lvdisplay #display logical volumes
@arnold: Thanx.
I solved the problem by myself.

1) I copied the content of the "Download"-directory to the new physical hard-drive.
2) I removed the "Download"-directory from the old hard-drive.
3) I created a symlink to the new directory (quick and dirty..).
4) I updated the menu in Gnome 2 to point to the new "Download"-directory.

Then my problem is solved. But I will take your solution into account the next time I need to move a directory to a new physical hard-drive.

I did forget to mention that I also need to update Gnome 2 to point to the new directory. But I found out how to do that myself.. -)
Ubuntu doesn't use LVM as default normally (maybe the server version does, but I don't think so). So you wouldn't have LVM setup. You would have had to do that when setting up the system. Doing it later I'm not sure if that is easily possible.
@rindi: You're right. As far as I can see I have to download 'lvm' from the Ubuntu repository if I want it.. :-)
Downloading alone won't help, you have to setup the HD first using LVM, similar when using RAID, and then on top the VolumeGroups you create you put the file-system. Of course with a new HD you can use LVM to start with, but your original HD wouldn't be using that yet.

OS's like CentOS and others that are based on Red-Hat use LVM by default.