Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello everyone, I've painted myself into a corner here and I'm hoping you all can save me.
I'm running Fedora 7 on a machine w/ a 120 GB hard drive sectioned into 20 and 100 GB. The 20 GB is hda1 and used for the linux install. The 100 GB section is hda2 and mounted as /data. I'm using some high end computational programs (Fluent, IDL, AutoCAD, etc). Originally I had planned to install them to the 20 GB. However, some of these programs generate pretty large files and put them in their home directory. Therefore, I need to move my /usr file from the 20 GB hda1 to the 100 GB hda2. Basically, I want to change my current /data to /usr. I would normally re-install to do this, but the license files are tied to the machine name and other data that might change if I re-install. So, is it possible to move my /usr folder to the second partition without pooching my install? Thanks!
Try this (I hope you have backups of important data, but I doubt this will kill anything )
Stop any programs that might be writing to /usr Then:
Copy all of /usr to /data
("# " Means "As root", do not type the "#"):
Code:
# cd /usr
# cp -a * /data
# cd /
Now unmount your "data" partition ( /dev/hda2 )
Code:
# umount /dev/hda2
Now remount it "over" your /usr directory
I am assuming you have an ext3 filesystem on /dev/hda2. Modify "ext3" if not.
Code:
# mount -t ext3 /dev/hda2 /usr
Your old /usr data should still be there, but invisible, and replaced with the data from /dev/hda2
To get your old /usr back, just unmount dev/hda2 from the /usr directory:
Code:
# umount /dev/hda2
# mount -t ext3 /dev/hda2 /data
Edit: It might be safest to do this from a "live CD" - it depends on what programs / data you have in /usr - it is not a good idea to move things about whilst they are in use. Then you'll need to update your fstab to reflect the new mounting
# cd /usr
# tar -cvf - . | ( cd ../data ; tar -xvf - )
Check to make sure the two directories look the same and then edit your /etc/fstab file and change /data to /usr in the entry for /dev/hda2.
Now, the following steps may cause you to not be able to do anything, but they should be fine. The first one will certainly work. It is the second that may not work, but if it doesn't, all is not lost, you will just need to reboot from a rescue CD, so make sure you have one before you continue. What you will need to do in rescue mode is make the /usr directory and then reboot.
Code:
# mv /usr /usr-bak
# mkdir /usr
If that worked, try:
Code:
# mount /usr
Reboot to make sure everything is working, and then you can remove /usr-bak
Hello everyone, I've painted myself into a corner here and I'm hoping you all can save me.
I'm running Fedora 7 on a machine w/ a 120 GB hard drive sectioned into 20 and 100 GB. The 20 GB is hda1 and used for the linux install. The 100 GB section is hda2 and mounted as /data. I'm using some high end computational programs (Fluent, IDL, AutoCAD, etc). Originally I had planned to install them to the 20 GB. However, some of these programs generate pretty large files and put them in their home directory. Therefore, I need to move my /usr file from the 20 GB hda1 to the 100 GB hda2. Basically, I want to change my current /data to /usr. I would normally re-install to do this, but the license files are tied to the machine name and other data that might change if I re-install. So, is it possible to move my /usr folder to the second partition without pooching my install? Thanks!
Scott
Yes, you can move /usr to /dev/hda2. You have the added complication of what are you going to do with /data? Assuming that you have moved the /data tree someplace else then you can move /usr to /dev/hda2 this way:
Log in as root
umount /dev/hda2
Format /dev/hda2. Assuming that you want /dev/hda2 to be ext3 then you format with:
mkfs -t ext3 /dev/hda2
Then mount /dev/hda2 on a temporary directory.
mkdir /newusr
mount -t ext3 /dev/hda2 /newuser
Then copy /usr to /newusr
cp -pR /usr/* /newusr
Then add an entry to /etc/fstab to describe /dev/hda2 as being mounted on /usr.
Reboot and check that everything is OK. If it is then boot a rescue CD and delete the old copy of data on /usr so that /usr is an empty directory:
Boot the rescue CD.
mkdir /part1
mount -t ext3 /dev/hda1 /part1
rm /part1/usr/* -R
Yes. And it is trivially simple. Reinstalling is never necessary in *nix when you move something.
You have two choices. Being lazy, I usually do it the first way that I will describe.
First choice: Copy the entire /usr file to the other partition, so that that partition has a directory named usr at its top level. Then on your boot partition, just make a symlink to the new usr directory. Specifically, assuming the hard drive is hda with partitions hda1 and hda2 mounted at /mnt/hda1 and /mnt/hda2, do this:
Then test it. When you are satisfied it works, delete usrold from /.
The second way is to copy the contents of usr to /mnt/hda2, but copy all the contents and not the directory /usr itself. The result is that you will have, for instance, a bin directory on /mnt/hda2, but it won't be a /usr/bin directory on hda2.
Actually, except for my symlink suggestion, they are all functionally equivalent methods.
Yes. I had thought of using a link, but there's something in the back of my mind about links across different partitions: Hard links, soft links & different drives / partitions (Alarm Bells are ringing in my ears)
I need to read those man pages again
I mistakenly tried to do this from the GUI today. My computer hung up after issuing the copy command. Upon restarting, the computer wouldn't load the GUI. So, tomorrow I'm going to go rooting around with a live cd and hope that I can fix whatever I've messed up. I may end up re-installing anyway
I really appreciate everyone's help and am sorry that I managed to screw up anyway.
Yes. I had thought of using a link, but there's something in the back of my mind about links across different partitions: Hard links, soft links & different drives / partitions (Alarm Bells are ringing in my ears)
I need to read those man pages again
you can use soft links from pretty much anyplace to anyplace. Hard links can only be on the same filesystem.
I actually symlink /home from / to a different HD, and I also symlink the documents section of /usr to another HD.
I mistakenly tried to do this from the GUI today. My computer hung up after issuing the copy command. Upon restarting, the computer wouldn't load the GUI. So, tomorrow I'm going to go rooting around with a live cd and hope that I can fix whatever I've messed up. I may end up re-installing anyway
I really appreciate everyone's help and am sorry that I managed to screw up anyway.
I'm sorry, can you give me a little more information? I'm pretty new to Linux and only know what I've had to figure out for my research (I'm a grad student).
Just copying files to /data should not have done this!
There is a problem in your fstab where it is trying to fsck your data partition, but it cannot find it.
Quote:
Then it asks for the root password and dumps me to a shell.
Can you use this shell? (If not, you'll have to boot from a rescue CD)
Can you see or mount your root partition (/dev/hda1)?
The outputs from mount
fdisk -l
would be useful to know
Edit your /etc/fstab file on /dev/hda1 so the line referring to 'LABEL=/data' refers to /dev/hda2 instead of the LABEL=/data. Then reboot.
If this is difficult, instead of editing fstab post it here, along with the output of fdisk -l and we'll see what can be done.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.