LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Moving /usr from '/' on sda1 to sda7 -- System is Debian Squeeze: sda7 doesn't mount (http://www.linuxquestions.org/questions/linux-general-1/moving-usr-from-on-sda1-to-sda7-system-is-debian-squeeze-sda7-doesnt-mount-872394/)

Learnix 04-01-2011 09:44 AM

Moving /usr from '/' on sda1 to sda7 -- System is Debian Squeeze: sda7 doesn't mount
 
First you are asking why do such a thing:
I am running a Postgres server and after I did the whole installation I realized the Postgres data was set in /usr/pgsql/data. Sda1 is just 10 Gig so I decided to re-organize the partitions to be able to move /usr to say /dev/sda7 with a mount point as /usr.
The / partition is on the only primary partition and the rest is on an extended partition.
When I tried to resize the primary partition GParted did not give me that possibilty so I decided to move /usr

Original partitions:
sda1 / 10 G on primary partition this includes /usr /var and all others
sda5 swap 2 G on extended partition
sda6 /home 140 G on extended partition

So I did create another partition using Knoppix and Gparted the disk:here is the new picture:

sda1 / 10 G on primary partition this includes /usr /var and all others
sda7 40 G new partition for /usr
sda5 swap 2 G on extended partition
sda6 /home 100 G on extended partition

Here is the fstab file:

proc /proc proc defaults 0 0

# / was on /dev/sda1 during installation
UUID=3c.........bla bla bla ....xxx / ext4 errors= remount -ro 0 1

# /home was on /dev/sda6 during installation
UUID=98.........bla bla bla ....xxx /home ext4 defaults 0 2

# I added this line
/dev/sda7 /usr ext4 defaults 0 3

# swap was on /dev/sda5 during installation
UUID=84..... bla bla bla ....xxx none sw 0 0

# I didn't touch the 2 next lines
/dev/scd0 /media/cdrom0 .............................
/dev/fd0 /media/floppy ............................

# And my backup disk device where I have a full system backup
/dev/sb1 /media/Image ext4 defaults 0 4

# End of the fstab file _________________________________________________

I did rsync to copy all the file to /dev/sda7/usr and then mv /dev/sda7/usr* /dev/sda7
I stop the postgres database and services then I mv /dev/sda1/usr to dev/sda1/poufusr .

When I rebooted it reports errors from kbd files on /etc File not found.
It brings me to a terminal (No GUI)
I did a check with :#mount: nothing is reported about sda7

What am I missing ?

business_kid 04-01-2011 11:15 AM

If you put the files in sda7/usr, and mounted sda7 on /usr, my friend, the files are actually in /usr/usr :-//.

Solution: as root
cd /usr/usr

check to see files are there, and do
mv * ../
mv .* ../ (Just in case)
cd ..
rmdir usr/ (not rmdir /usr).
Then reboot to stand things up normally.

bigrigdriver 04-01-2011 12:10 PM

Quote:

check to see files are there, and do
mv * ../
mv .* ../ (Just in case)
cd ..
rmdir usr/ (not rmdir /usr).
Then reboot to stand things up normally.
That will get the files where they belong in /usr under /. To move the files to /dev/sda7 mounted at /usr (as shown in /etc/fstab), do this as root (assuming you have formatted /dev/sda7 for ext4):
1) mkdir /mnt/usr
2) mount -t ext4 /dev/sda7 /mnt/usr
3) mv /usr/* /mnt/usr
At this point, the files under /usr have been moved to /dev/sda7. /etc/fstab lists /dev/sda7 with mount /usr. Leave empty /usr directory in place (it's now the mount point for /dev/sda7).

Now reboot, and /dev/sda7 should mount normally.

Learnix 04-04-2011 10:23 AM

Thanks Business Kid but I knew it and I took care of it before going further. This was indeed an easy one to miss , good advice !

Thanks BigRigDriver: your post was more than clear and I got it done like it is suppose to be.

Last question:

Should I remove the folder /mnt/sda7/ (Just the sda7 portion of it :))

Thanks a lot to both of you , that was much appreciated.

Cheers,

bigrigdriver 04-04-2011 01:32 PM

Sure, you can remove it. It was just a temporary mount point to use in mounting the new partition so that you could move the files into it. The new partition is now mounted via fstab. I suppose it would have helped if I had given a few comments in re the reasons for the commands along with the commands themselves.

If future, when you have a Linux/Unix related question, try www.google.com/linux first. It's a google search filter that filters 99.9% of unrelated hits. There are similar filters for microsoft and macos systems. You may find your answer sooner that you would by waiting for an answer here.

If you still can't resolve a problem, then post it here.

Good Luck and enjoy Linux.

Learnix 04-11-2011 08:32 AM

Thanks for the google idea. I often use it and try to post the key words in the search line. I will defenitely try www.google.com/linux next time.

End of the story I succeeded to move /usr like expected as you may know. I have to say at some point I dropped the whole /usr folder by accident. Wasn't I happy that I have done a backup on a hard drive of my system before. That was a life saver.

Thanks again, very much appreciated !


All times are GMT -5. The time now is 09:10 AM.