LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Create a Softlink to Move some Library Folder (https://www.linuxquestions.org/questions/linux-newbie-8/create-a-softlink-to-move-some-library-folder-847858/)

ethereal1m 12-02-2010 02:27 AM

Create a Softlink to Move some Library Folder
 
Dear all,
I'm running out of disk space in root, so I decide to move /usr/lib64 directory to other partition by creating moving the whole directory to new location and create a softlink in the old location. What I'm planning to do is:
1. Copy the whole directory to new location
2. Make sure if there's no problem in the copy process
3. Create a softlink in the old location pointing to the new location.

However, when I'm comparing the old location and the new location using du command, there's some discrepancies between those two where the new location contain bigger size than the old one. How is this possible?

Is this the proper way to save disk space by creating a softlink?

Regards,
ethereal1m

Snark1994 12-02-2010 08:52 AM

Wouldn't it make more sense just to resize partitions? Or are you worried about data loss?

i92guboj 12-02-2010 10:40 AM

Quote:

Originally Posted by ethereal1m (Post 4177921)
Dear all,
I'm running out of disk space in root, so I decide to move /usr/lib64 directory to other partition by creating moving the whole directory to new location and create a softlink in the old location. What I'm planning to do is:
1. Copy the whole directory to new location
2. Make sure if there's no problem in the copy process
3. Create a softlink in the old location pointing to the new location.

Your approach sounds mostly OK, but:
  1. What fs are you using on the destination? You need to make sure that the destination fs is compatible with the posix permissions scheme (i.e. not vfat, ntfs or something like that)
  2. How are you copying the file? Make sure you preserve permissions and ownerships. If you use "mv" there shouldn't be any problem, though I advise you to use "cp -a" instead. Don't delete the original copy until you make sure everything is working ok.

Quote:

However, when I'm comparing the old location and the new location using du command, there's some discrepancies between those two where the new location contain bigger size than the old one. How is this possible?
I don't know how "du" measures the space. But if it relies on the fs then that could be the cause. The block size can differ from one volume to another depending on the fs-type, the size and the options you used to format (and even to mount) them.

Quote:

Is this the proper way to save disk space by creating a softlink?
You could also mount the partition directly at /usr/lib64, or if it's a subdirectory in an already mounted volume, you could use "mount -o bind". To automate that you can use /etc/fstab, of course.

ethereal1m 12-03-2010 01:45 AM

@snark, hmm I'm considering the option...

@i92guboj,
1. I move files from ext4 to xfs file system not sure if this a problem
2. I'm using "cp -R". Is this ok?

hmm,the discrepancy df output is probably because the different file system types (ext4 and XFS) maybe?

Let me take a look at mount and fstab option...

i92guboj 12-03-2010 03:31 AM

Quote:

Originally Posted by ethereal1m (Post 4179195)
@snark, hmm I'm considering the option...

@i92guboj,
1. I move files from ext4 to xfs file system not sure if this a problem

xfs is ok.

Quote:

2. I'm using "cp -R". Is this ok?
Nope. -R copies recursively, but it doesn't preserve permissions nor ownerships, that can seriously screw up everything. You should use "cp -dR --preserve=all" or just "cp -a", which is equivalent.

Quote:

hmm,the discrepancy df output is probably because the different file system types (ext4 and XFS) maybe?
I can't be sure, but it's a possibility. If you want to copy with error checking use "rsync -a" instead.

ethereal1m 12-15-2010 01:16 AM

Thanks for all, you guys are awesome!
This works great!

sorry for the late reply...

regards,
ethereal1m


All times are GMT -5. The time now is 10:52 PM.