Mombu the GNU Linux Forum sponsored links

Go Back   Mombu the GNU Linux Forum > GNU_Linux > Partition Splitting
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 23rd September 19:33
john williams
External User
 
Posts: 1
Default Partition Splitting



Mandriva 2008.0.

I have separate partitions on my hard-drive for "/", /backups, /home,
and /tmp. The '/' partition is now full, and I cant extend its size
due to the fact that there are other partitions following it. The '/'
sub-directory that seems to be the biggest is /usr, and I have plenty of
unused space on the drive after the Linux directories.

What is the procedure for removing /usr from the '/' partition, and
putting the content in a separate (new, 10GB) partition? I have Googled
without success ...

Should I use a live CD (Knoppix?) to create the new partition, and then
the live CD command line to cp the old /usr to the new and then delete
the old? If so, how do I edit the fstab? Or can the whole exercise be
done under mcc?

--
John Williams
Nelson, New Zealand
  Reply With Quote


  sponsored links


2 23rd September 19:33
jim beard
External User
 
Posts: 1
Default Partition Splitting



I would suggest first backing up the system.
Make sure you have a copy of tar at /bin/tar.
mv /usr /oldusr (as root, of course)

Launch mcc (you may have to use full path name /oldusr/bin/mcc), to
local disks, to manage local disks. Create a new partition and name
it usr, mount it on /usr. Quit mcc and cd /usr. Make sure you are
in an empty directory of correct size, i.e. that your changes took
effect. cd /usr ; df -k . (period is part of the command)
Then, as root (to keep ownership/group/permissions/etc)

(cd /oldusr ; tar -cf - . ) | (cd /usr ; tar -xf - )
dd and rsync should also be usable for this,
as is cp -pR /oldusr/* /usr. I am not sure if cp with -pR
handles symbolic links correctly, so man cp. Note that rsync
is normally /usr/bin/rsync, so you may need to use the complete
pathname /oldusr/bin/rsync if you go that route.

Do an ls -laR /usr |less to examine owner/group/permissions of
at least some of the executables in /usr/bin, to make sure all
transferred properly.

cd /etc and using vi or any other ASCII editor create a line
in fstab that matches the way in which you created/named the
partition. It might look something like one of the three
lines here:

/dev/sda6 /usr ext3 defaults,noatime 1 2
LABEL=usr /usr ext3 defaults,noatime 1 2
UUID=f3ca97a8-cbd9-4599-bf65-041b209b7ba7 /usr ext3 noatime 1 2

blkid /dev/sda6
will show you the attributes of /dev/sda6 above, to make sure the
system thinks you have named things as you intended to name them.

As an alternative on naming the partition, you could name the
new partition nusr and mount it as /nusr. Then, after moving all
the stuff under /usr under /nusr, rm =rf /usr followed by
ln -s /nusr /usr.

In closing, I would watch for better directions from BitTwister,
Dave Hodgins, or some of the other sysadmin folk who actually do
this sort of thing now and then. I do it so rarely that I might
overlook or leave out something. But, the above says what you want
to do is possible, and offers a few ways to do it.

Cheers!

jim b.


--
UNIX is not user unfriendly; it merely
expects users to be computer-friendly.
  Reply With Quote


  sponsored links


3 23rd September 19:33
david w. hodgins
External User
 
Posts: 1
Default Partition Splitting


Use mcc/diskdrake to create the new partition, assign a label, format it,
set the mountpoint as /newusr, mount it, and update fstab.

Make a copy of /etc/fstab and edit the copy to change /newusr to /usr.

Then, as root switch to run level 1, to ensure no files are being updated,
or are locked. Copy the data from /usr to /newusr. Verify the copy looks ok.
Rename /usr to /oldusr. Unmount /newusr. Rename the directory /newusr to /usr.
Copy the edited /etc/fstab over the regular one. mount /usr. Switch back to
run level 3.

In more detail ...

Use "telinit 1" (as root), to switch to run level 1.

For copying the data, I'd use "rsync -avx /usr/ /newusr". Don't forget the
trailing slash on the source directory.

I'd verify the copy had worked by browsing a few of the directories with mc,
and by comparing the output of "du -cs /usr" with "du -cs /newusr"

Note that once you rename /usr, you will not have any utilities like mc, which
are normally in /usr/bin available.

Rename /usr using "mv /usr /oldusr".

"umount /newusr".
Rename /newusr to /usr use "mv /newusr /usr".

Copy the edited fstab over top of the regular fstab, mount the /usr, and then
use "telinit 3", to get back to run level 3.

Once you've confirmed everything is ok, remove /oldusr with "rm -rm /oldusr".

Regards, Dave Hodgins

--
Change nomail.afraid.org to ody.ca to reply by email.
(nomail.afraid.org has been set up specifically for
use in usenet. Feel free to use it yourself.)
  Reply With Quote
4 23rd September 19:33
david w. hodgins
External User
 
Posts: 1
Default Partition Splitting


That would fail as diskdrake and other things called by mcc must be in /usr/bin, /usr/lib/libDrakx, etc.

Heh, heh. Thanks

Basically, my advice boils down to, create the new partition, copy the
data, change the system to use the new data, make sure it works, then
delete the old data.

Best to keep the old data around until you know the new copy is good.

Regards, Dave Hodgins

--
Change nomail.afraid.org to ody.ca to reply by email.
(nomail.afraid.org has been set up specifically for
use in usenet. Feel free to use it yourself.)
  Reply With Quote
5 23rd September 19:33
david w. hodgins
External User
 
Posts: 1
Default Partition Splitting


Of course I'd make a typo here. Should be "rm -rf /oldusr".

Regards, Dave Hodgins

--
Change nomail.afraid.org to ody.ca to reply by email.
(nomail.afraid.org has been set up specifically for
use in usenet. Feel free to use it yourself.)
  Reply With Quote
6 23rd September 19:33
aragorn
External User
 
Posts: 1
Default Partition Splitting


Forget about the Mandrive Control Center or anything GUI-related under those
conditions. The job you're about to undertake is so incisive that it can't
even be done from normal multiuser mode, since libraries in */usr/lib*
might then be in use. The first step can however be performed
using /DiskDrake/ from the GUI environment - read on.

Considering that you've got */home* and */tmp* split off already, I would
rather think that */var* is the culprit for the root filesystem filling up
as */usr* is normally static, and so it would be better in my opinion to
split that off than to split off */usr.*

Either way, if you have plenty of free space behind the other GNU/Linux
partitions, I would recommend that you first use /Diskdrake/ to create a
partition in the available space and have a filesystem created on it, but
leave it unmounted, save the changes and then drop to single user mode
using the command...

init 1

.... as root - save all your open files first because this will kill the GUI.

Next, you must mount the newly created partition somewhere. I'm going to
assign a randomly chosen device special file to this partition because I
don't know how your partitions are organized on your hard disk, and whether
it's an IDE/SATA/USB/SCSI/SAS device. I'm also going to assume that you'll
use /ext3/ as the filesystem - not that this is necessarily the best
choice, but you are of course advised to substitute both the filesystem
type and the device special file for what applies to your choices and
system. So let's say you've chosen */dev/sda8* as the partition's device
special file and that you're using /ext3/ on it.

mount -t ext3 /dev/sda8 /mnt

Now, you must copy the contents of */var* - let's assume you'll move that
one instead of */usr* but what applies to */var* will also apply to */usr*
should you choose to split off that one as well.

cd /var
cp -pPR * /mnt

The above copy command will copy files, directories and symbolic links
without following the symbolic links - which is what you want - and while
preserving timestamps, ownerships and permissions.

Next, verify that everything is there...

ls -lr /mnt | less

.... and then remove the contents of */var* on the root filesystem...

rm -rf
ls -l
cd /

Now, you must mount the new filesystem to */var* and make sure that the
system will recognize this new set-up automatically from here on...

umount /mnt
mount -t ext3 /dev/sda8 /var

As an editor, I will use /mcedit/ - part of the Midnight Commander package -
but you can use /nano,/ /pico,/ /vi/ or whatever other editor you've
installed and that you are comfortable with.

mcedit /etc/fstab

Add a line for your new filesystem, like so...

/dev/sda8 /var/ ext3 auto,defaults,nodev,noatime 0 0

If you want to use the partition label or UUID, you'll have to check for
those using /blkid/ command before using the editor to retrieve that
information. Having a pen and paper handy is recommended. ;-)

Next, edit the editor and you're done...

init 5

.... will take you back to your GUI login screen. Substitute "5" by "3" if
you normally use /startx/ to bring up the GUI.

--
*Aragorn*
(registered GNU/Linux user #223157)
  Reply With Quote
7 23rd September 19:33
antonio perez
External User
 
Posts: 1
Default Partition Splitting


There are ways around this, read on.


Steps:
1.- Make a partition, let's asume it's /dev/sda8.
2.- Format it: mkfs.ext3 /dev/sda8
3.- Mount it: mount /dev/sda8 /mnt/newusr ( crete newusr before)
4.- copy: rsync -axH /usr/ /mnt/newusr/
5.- edit fstab to reflect the change
6.- reboot

Others have provided details on blkid and using "init 1" etc so you don't
have to reboot. Feel free to ask if unsure!!!

A Live CD would be the best/simpler way as a partition should not be copied
while in use. The Mandriva CD could well serve the purpouse. If you so
choose to use this path there are two possible scenarios:

1.- Use gparted to move partitions around and make "/" bigger. Quite long
(time wise) process.

2.- Do the procedure stated above while working from the Live CD. It is a
lot safer.
  Reply With Quote
8 23rd September 19:34
john williams
External User
 
Posts: 1
Default Partition Splitting


Thank you Jim, David, Aragorn, Antonio. We are so lucky in the
Mandriva world to have knowledgeable people like you so ready and
willing to help.

I intend to use a live CD to create the extra partition(s) - /usr *AND*
/var - using Aragorn's recent posting re optimal sizes as a guide as well.

I still a bit confused w.r.t. fstab, though. My current one reads:

dev/hde5 / ext3 relatime 1 1
/dev/hde9 /backups ext3 user,relatime,exec 1 2
/dev/hde10 /freevo ext3 user,relatime 1 2
/dev/hde7 /home ext3 relatime 1 2
/dev/cdrom /media/cdrom auto
umask=0022,users,iocharset=utf8,noauto,ro,exec 0 0
/dev/cdrom2 /media/cdrom2 auto
umask=0022,users,iocharset=utf8,noauto,ro,exec 0 0
/dev/fd0 /media/floppy auto
umask=0022,users,iocharset=utf8,noauto,exec,flush 0 0
/dev/hde1 /mnt/win_c vfat umask=0022,iocharset=utf8 0 0
/dev/hdf1 /mnt/win_c2 ntfs umask=0022,nls=utf8,ro 0 0
none /proc proc defaults 0 0
/dev/hde11 /shared vfat umask=0 0 0
/dev/hde8 /tmp ext3 relatime 1 2
/dev/hde6 swap swap defaults 0 0

- but I confess I don't understand what each entry means (ignore the
hde1, hd11 and hdf entries, they're for a heritage Window$ system!).
Anything I need to change? 'relatime' doesn't appear to be do***ented
in the man.

A thought. Could I use /usr/bin/drakupdate_fstab to rebuild fstab
(assuming it works in the same way as during a new install ...)?

Again, thanks for your help and ideas.

--
John Williams
Nelson, New Zealand
  Reply With Quote
9 23rd September 19:34
bit twister
External User
 
Posts: 1
Default Partition Splitting


If me, I would go ahead and create the partitions and format them.
That would automagically put them in your current fstab.

I would then copy fstab to fstab_new.
I would then change the mount point label to what it will be
upon completion of the task.

Example for /usr: you would /create/new_usr, and format it.
In fstab_new, you change /new_usr to /usr.
You could then boot your rescue cd, copy over files from /usr to /new_usr.
then copy current fstab to fstab_old.
then copy fstab_new fstab

reboot and you should have no problems.

If everything feels good, and you know all is good,
boot rescue cd
mount your / partition
and /bin/rm -r /usr/*

For myself, I would write every instruction into a file just like you
were writing a script to do all the work.
I would then print hard copy, and hand check every command.
I would sleep on it, then go over the hard copy again.

Once I was satisfied, I would boot the rescue cd
bring up the script, and cut/paste each command.
before hitting the carriage return, be really satisfied I know I know
what I am doing.

Would not hurt to have a separate backup of data, know it is readable,
contains all the backed up data, and have the tested restore procedure
on hand.
  Reply With Quote
10 23rd September 19:34
john williams
External User
 
Posts: 1
Default Partition Splitting


Bit Twister:

Thanks! Excellent advice.

--
John Williams
Nelson, New Zealand
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666