LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-18-2005, 04:24 PM   #1
patrickdepingui
Member
 
Registered: Mar 2003
Distribution: Slackware
Posts: 53

Rep: Reputation: 15
partitioning questions with reiserfs


I started with linux on a small partition. I had an extra hard disk which I plugged in, and now my configuration is:

/dev/hda6: root (/) (reiserfs)
/dev/hda5 : swap partition
/dev/hdb1: /usr (reiserfs)
/dev/hdb5: swap

Below is the output of fdisk
Code:
Disk /dev/hda: 41.1 GB, 41174138880 bytes
255 heads, 63 sectors/track, 5005 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1         519     4168836    7  HPFS/NTFS
/dev/hda2             520        5005    36033795    f  W95 Ext'd (LBA)
/dev/hda5             520         532      104391   82  Linux swap
/dev/hda6             533         665     1068291   83  Linux
/dev/hda7            1054        1346     2353491    7  HPFS/NTFS
/dev/hda8            1347        3475    17101161    7  HPFS/NTFS
/dev/hda9            3476        5005    12289693+   7  HPFS/NTFS

Disk /dev/hdb: 1281 MB, 1281181696 bytes
64 heads, 63 sectors/track, 620 cylinders
Units = cylinders of 4032 * 512 = 2064384 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdb1   *           1         533     1074496+  83  Linux
/dev/hdb2             534         620      175392    5  Extended
/dev/hdb5             534         620      175360+  82  Linux swap
The problem is that my disk space is running out, especially in /usr (hdb).
I've freed disk space from my windows partitions, and this free space is located after hda6 (start 666 end 1053)

The hdb harddisk is an older, slower one, while hda is faster (7200rpm against 5400). Therefore I'd prefer the system files being on hda, while my personal files (/home) being on hdb.

What is the best thing I can do, without losing my current installation?
Can I extend hda6 to the free space, and what is the best way?
Is it then possible to just move the contents of hdb (which is mounted as /usr) to the faster hda? (and where do I change the mounting point, fstab?)

Thanks for pointing me out!
 
Old 01-18-2005, 09:16 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,334

Rep: Reputation: 547Reputation: 547Reputation: 547Reputation: 547Reputation: 547Reputation: 547
"Is it then possible to just move the contents of hdb (which is mounted as /usr) to the faster hda? (and where do I change the mounting point, fstab?)"

Yes and yes. Create a new partition in your empty space on /dev/hda. Format the new partition. Mount your new partition on a temporary directory and copy /usr to the temporary directory. Change the entry in /etc/fstab to point to the new partition and boot. Once you are sure the new /usr is OK then you format /dev/hdb1.

Moving /home to /dev/hdb1 is a similar operation. One difference is that the copy will set ownership of the new /home tree to root root. While the new /home partition is still mounted on the temporary directory use the chown command to change ownership to the proper user and group:
chown user:groupx /newhome/* -R
Create an entry for /home is /etc/fstab and reboot.
The second difference is in the last step where you wipe out the old /home tree. You will have to do that from a rescue CD system. Boot the rescue CD. Mount /dev/hda6 on a temporary directory and delete the files from the /home directory:
mkdir /oldhome
mount -t reiserfs /dev/hda6 /oldhome
rm /oldhome/home/* -R

------------------------
Steve Stites
 
Old 01-18-2005, 11:00 PM   #3
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Rep: Reputation: 58
I think qtparted could easily and safely extend your /dev/hda6 partition to the subsequent free space.

The way of transferring files and directories to their new locations is described below, but the description is based on the presumption that the home directory in slackware is /home (I know some unixes where it is /usr/home), and that slackware uses /etc/fstab for holding information on mounted partitions (I have seen distros where it does not seem to contain that). I do not really know slackware, so check these before you proceed.

Transferring /usr from /dev/hdb1 to /dev/hda6:
1. boot up in single user mode
2. unmount /dev/hdb1 (your old /usr)
3. create directory /mnt/usr.old, and (re-)mount /dev/hdb1 to /mnt/usr.old
4. create directory /usr with the same permissions as those of your old /usr directory
5. copy all files from /mnt/usr.old to /usr using cpio. Note: you MUST use cpio to copy the files from your old /usr; the copy command is not appropriate to correctly copy system files and directories. You will find several threads at this forum on how to use the cpio command; just see how it works before you use it for critical tasks
6. backup your /etc/fstab file
7. edit your /etc/fstab file; remove the line that mounts /dev/hdb1 to /usr
8. Reboot
Now your system should use the new /usr directory located on /dev/hda6.

If your system is not happy with the new /usr directory, then just restore your old /etc/fstab file, and your system will use your old /usr directory on /dev/hdb1, again, after reboot.
However, if the new /usr is OK, then you can proceed with tranferring your /home directory to /dev/hdb1:
1. Boot up in single user mode
2. Create directory /mnt/home.new
3. Mount /dev/hdb1 to /mnt/home.new
4. Remove all files on /mnt/home.new (those are files of your old /usr directory)
5. Copy all files from /home to /mnt/home.new using cpio
6. Backup /etc/fstab again
7. Edit /etc/fstab so that /dev/hdb1 be mounted to /home
8. Reboot

If your system is happy with the new setup, then you can safely remove the contents of your old /home directory:
1. Boot up in single user mode
2. Unmount /dev/hdb1 (your new /home directory); and now your old /home directory should show up. Doublecheck that it is really your old home directory (i.e. /dev/hdb1 has been actually unmounted), and delete all files in /home, but keep /home itself.
3. Reboot

Just a last note: you might consider not to add all free space to /dev/hda6, but keep some free space for later use for separate /tmp and /var partitions. Some say it is theoretically better to keep these directories on their own partitions; though you may easily run out of diskspace if you underestimate the required size of these partitions.
Another drawback: if you create new partitions on /dev/hda, then those will possibly get partition IDs /dev/hda10 and /dev/hda11, and your system might complain of the partition numbers not being in the order of their physical locations on the hard disk. I do not know if this involves any serious drawback because I completely re-partitioned my hdds the last time when I got that message.

Last edited by J_Szucs; 01-18-2005 at 11:22 PM.
 
Old 01-26-2005, 07:06 AM   #4
patrickdepingui
Member
 
Registered: Mar 2003
Distribution: Slackware
Posts: 53

Original Poster
Rep: Reputation: 15
just for the record:
I succesfully completed above steps.

I used Knoppix live cd for most actions.

Using QTParted I extended hda6 into the free space.

Then I used cpio for the transfers.
The way to use cpio is (so others with the same problem shouldn't searc for it)

1) cd to the directory you want to copy, for example /mnt/user.old
2) type
find . -xdev | cpio -pm /mnt/hda6/usr

the last dir is of course the destination dir.
find . -xdev returns a list of files in the current directory and in subdirs, and the option -xdev tells find that it should only look on this device, and shouldn't follow links to other devices

the options -pm tells cpio to preserve permissions (m) and p tells to work in pass-through mode (instead of making an archive, just copy all the files directly from one place to the other)

Thanks to J_Szucs and jailbait for helping me on this

PS J_Szucs: the directories and files you mentioned for slackware are correct
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Partitioning questions Hampster Mandriva 2 01-12-2005 04:19 AM
reiserFS questions sqn Slackware 1 11-14-2004 07:16 PM
Couple questions about xfs and reiser4/reiserfs Nikon01 Slackware 8 09-20-2004 04:29 AM
mdk 9.1 partitioning questions KernelPayne Linux - General 5 10-05-2003 01:47 PM
partitioning is necessary/okay, but I have a few questions beginnerx Linux - Newbie 2 09-26-2003 06:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration