LinuxQuestions.org
Review your favorite Linux distribution.
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 08-30-2004, 11:06 AM   #1
zaipher
LQ Newbie
 
Registered: Aug 2004
Location: Norway
Distribution: Xubuntu/Ubuntu, Trustix, WinXPpro
Posts: 6

Rep: Reputation: 0
Is it this simple to add more hd space?


Hi

I seem to be running out of space on my hd, and i'm sorta unsure about how to work my way around the problem. I have 2 hd's with lotta partitions:
1st hd has swap, mount point /, mount point /home, + 2 fat partitions (for file storage).
2nd hd has 2 nt partitions (i dualboot linux/win2000).

I've installed lotta progs on / and since i keep the source in /usr/local/src, the partition is full. I realise that i was too generous to /home.

What i plan to do is this: Free up 1 (or both) fat partitions, convert it to ext3 and edit fstab so it will be mounted at /usr. Is it that simple? Should i move the content of the existing /usr to the new partition before i mount it? Or will this wreck the system?

Last edited by zaipher; 08-30-2004 at 11:22 AM.
 
Old 08-30-2004, 12:31 PM   #2
tredegar
Guru
 
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,007

Rep: Reputation: 366Reputation: 366Reputation: 366Reputation: 366
I think you have the right idea:
Free up FAT partition(s), make a linux filesystem (ext3 if you like) there.
Mount the new (empty) partition at /mnt/newpart

To keep things from changing while you are copying, go to single user mode.

Copy [I would not recommend 'move'] over EVERYTHING from /usr to /mnt/newpart. You might like to search LQ for how to do this reliably, keeping permissions etc. The last time I did this, I did it like this:

Code:
#cd /usr
#tar cf - . | (cd /mnt/newpart && tar xBfp -)
Don't ask me how that code works, I think it was Tinkster who gave it to me. It worked a treat!

Check that everything has been copied over correctly.

Now you can delete all of /usr. Take great care with this as youl'll be doing a rm -Rf as root!!
Now unmount your partition from /mnt/newpart, and mount it at /usr.

Now you can safely leave single user mode

Don't forget to edit fstab to reflect the fact that your new partition has to be mounted at /usr, or
you may not survive a reboot.

Hope this helps.
 
Old 08-30-2004, 01:41 PM   #3
zaipher
LQ Newbie
 
Registered: Aug 2004
Location: Norway
Distribution: Xubuntu/Ubuntu, Trustix, WinXPpro
Posts: 6

Original Poster
Rep: Reputation: 0
Thanx a lot, that was very helpful
 
Old 09-15-2004, 04:02 PM   #4
zaipher
LQ Newbie
 
Registered: Aug 2004
Location: Norway
Distribution: Xubuntu/Ubuntu, Trustix, WinXPpro
Posts: 6

Original Poster
Rep: Reputation: 0
Mission: success :)

Now, this worked great! I've just added a lot more space...

I just wonder: Can i use this method to move the entire os to another (bigger) hd ?? Guess that's wishful thinking, but i really don't wanna install everything all over again (if i can avoid it).

How can i do this?

Code:
phr0zen9uy@phz01:~$ df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hda5              5819980   4587140    932428  84% /
/dev/hda8              3610172    503472   2920348  15% /usr/local
/dev/hda1             10239416   1224328   9015088  12% /mnt/fat-c
/dev/hda6             18295088    659520  16706212   4% /home
/dev/hdd1               194442      4127    180276   3% /mnt/boot
/dev/hdd5              4814936     32828   4537520   1% /mnt/base
/dev/hdd6             19236308     32828  18226328   1% /mnt/usr
/dev/hdd7             33633412     32828  31892076   1% /mnt/home
/dev/hdd4             95414348  19588572  70978968  22% /mnt/storage
This is how my system looks right now. I wish to move my os (slackware 10) from hda to hdd, and then remove hda from my pc. Thanks for any help.

Last edited by zaipher; 09-15-2004 at 04:10 PM.
 
Old 09-16-2004, 05:02 AM   #5
tredegar
Guru
 
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,007

Rep: Reputation: 366Reputation: 366Reputation: 366Reputation: 366
We need to know what is currently being mounted where, and where the free space is on hdb.

So could you post the contents of /etc/fstab and the output of fdisk -l /dev/hdb (hope that is the right command, I'm at work now and using that other OS)
 
Old 09-16-2004, 05:57 AM   #6
amosf
Senior Member
 
Registered: Jun 2004
Location: Australia
Distribution: Mandriva/Slack - KDE
Posts: 1,672

Rep: Reputation: 46
I recently moved my OS to a bigger drive. I moved home first in root with cp -a but then I moved the / root partition using a knoppix bootable cd (still using cp -a) - Keep the original as you will need it.

Once copied across you have to edit the fstab on the new partition, then rig lilo on the original OS so you boot the new OS partition. Once you're booted you can edit and run lilo so you can boot the new partition.

There are a couple of ways to do all this, and you can make an emergancy rescue cd if you are worried, but it does work. Once the new part is up and running a while and you are sure all is well, you can then reclaim all the old space
 
Old 09-16-2004, 06:07 AM   #7
zaipher
LQ Newbie
 
Registered: Aug 2004
Location: Norway
Distribution: Xubuntu/Ubuntu, Trustix, WinXPpro
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks for the help tredegar. Your tip on how to solve my former "problem" worked great. Anyway, here's the info you wanted:

Code:
phr0zen9uy@phz01:~$ cat /etc/fstab
/dev/hda7        swap             swap        defaults         0   0
/dev/hda5        /                ext3        defaults         1   1
/dev/hda8        /usr/local       ext3        defaults         1   2
/dev/hda1        /mnt/fat-c       vfat        rw,user,exec     1   0
/dev/hda6        /home            ext3        defaults         1   2
# /dev/hdd1        /mnt/nt-h        ntfs        ro               1   0
# /dev/hdd5        /mnt/nt-j        ntfs        ro               1   0
/dev/hdd1        /mnt/boot        ext3        defaults         1   2
/dev/hdd5        /mnt/base        ext3        defaults         1   2
/dev/hdd6        /mnt/usr         ext3        defaults         1   2
/dev/hdd7        /mnt/home        ext3        rw,user,exec     1   2
/dev/hdd4        /mnt/storage     ext3        rw,user,exec     1   2
/dev/cdrom       /mnt/dvd         iso9660     ro,user,exec     0   0
/dev/writer      /mnt/hp          iso9660     rw,user,exec     0   0
/dev/fd0         /mnt/floppy      auto        noauto,owner     0   0
devpts           /dev/pts         devpts      gid=5,mode=620   0   0
proc             /proc            proc        defaults         0   0

---------------------------------------------

bash-2.05b# fdisk -l /dev/hda

Disk /dev/hda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1        1276    10249438+   c  W95 FAT32 (LBA)
/dev/hda2            1277        4865    28828642+   f  W95 Ext'd (LBA)
/dev/hda5            1277        2024     6008278+  83  Linux
/dev/hda6            2552        4865    18587173+  83  Linux
/dev/hda7            2025        2087      506016   82  Linux swap
/dev/hda8            2088        2551     3727048+  83  Linux

---------------------------------

bash-2.05b# fdisk -l /dev/hdd

Disk /dev/hdd: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdd1               1          25      200781   83  Linux
/dev/hdd2              26          93      546210   82  Linux swap
/dev/hdd3              94        7389    58605120    5  Extended
/dev/hdd4            7390       19457    96936210   83  Linux
/dev/hdd5              94         702     4891761   83  Linux
/dev/hdd6             703        1432     5863693+  83  Linux
/dev/hdd7            1433        7389    47849571   83  Linux
My current system is at /dev/hda, and i wanna move it to /dev/hdd (i just bought a new 160Gb hd). I have split the new drive into various partitions and mounted the new hd under /mnt like this:
  • /mnt/boot
  • /mnt/base (will be '/' on the new hd)
  • /mnt/usr
  • /mnt/home
  • /mnt/storage (just for backup and file storing)
... to prepare it for copying from my current system on hda. Btw... i plan to use ext3, but can i safely use ext2 on any of these partitions? Or is journaling generally a good thing for all of them?

As you can see from my fstab; to do this i have removed the original /dev/hdd which had two ntfs partitions (win2000). I want this back into my box when linux is running on my new hd. There are probably some important files on /dev/hda1 (the boot partition) that somehow needs to be copied to the new hd? LILO refer to /dev/hda1 as the boot partition for win2000, but the os is located on /dev/hdd1 (which i have removed for the moment).

Phew... this looks like a mess to me Over the last 5-6 years i've had DOS, w95, w98, w2000 and various flavors of linux installed on my system....

Thanks for any help.

Last edited by zaipher; 09-16-2004 at 06:11 AM.
 
Old 09-16-2004, 10:29 AM   #8
tredegar
Guru
 
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,007

Rep: Reputation: 366Reputation: 366Reputation: 366Reputation: 366
OK. We need to do this carefully!

Firstly, PRINT a copy of your lilo.conf file and make a boot disk in case you 'loose' linux as I once did. It took me ages to work out how to get it back. It has been recommended only to copy partitions that are not being used, so you might want to get hold of a copy of knoppix that can run from a cd and use knoppix to copy your data over. This also gives you the advantage that if you 'loose' your linux, you can have a version of linux (knoppix) to use to get it back!

I am not sure it is a good idea to have /boot as a separate partition. Why would you want to do that? I just have /boot as a directory in my / partition. Lilo goes on the MBR of the boot disk. [See later!]

So I would set up your hdd partitions like this:

hdd1 /
hdd2 /home
hdd3 swap
hdd4 /usr
hdd5 /storage


Now format each partition as whatever you like. Journalling seems to be "a good thing", so I am using ext3

Now mount /dev/hdd1 as /mnt/newroot, and create in /mnt/newroot/ all the directories you currently have listed in / (your old or current root) EXCEPT /proc and /mnt. /proc is virtual, so there is no point in copying it, and if you think about it, trying to copy over /mnt could lead to a recursive nightmare. Make sure your new (empty) directories in /mnt/newroot/ have the same perms as the old ones in /

Ideally you now run something like knoppix direct from the CD. This will allow you to mount your old root partition at /mnt/oldroot, and your new root partition at /mnt/newroot. If you cannot do this, go to single user mode, and I think you should be OK. The idea is that the filesystem should not be active or changing whilst you are copying it, otherwise you may end up with a whole load of inconsistencies!

Copy the contents of each directory (except /proc and /mnt) like this:
Code:
#cd /mnt/oldroot/bin 
#tar cf - . | (cd /mnt/newroot/bin && tar xBfp -)
#cd /mnt/oldroot/dev
#tar cf - . | (cd /mnt/newroot/dev && tar xBfp -)
.... Well you get the idea.

You might see an error like "tar: ./log: socket ignored", but this doesn't matter.

Don't forget to copy over any lonely files that might be lying around in /

Now do the same thing for /usr /home and /storage eg:
Code:
#mkdir /mnt/newhome
#mount -t ext3 /dev/hdd2/ /mnt/newhome
#mkdir /mnt/oldhome
#mount -t ext3 /dev/hda6/ /mnt/oldhome
#cd /mnt/oldhome
#tar cf - . | (cd /mnt/newhome && tar xBfp -)
So, that has copied everything over, but it is not ready to boot yet.
You need to edit /mnt/newroot/etc/fstab to reflect the fact that hdd1 is going to be your new / partition, and similar for the other partitions on hdd.

Now there is just one more problem: You can see from your fdisk output above that /dev/hda1 is your boot disk, and lilo is on that disk's MBR.
You need to reboot to your old linux on hda. Tell lilo about your new linux on hdd, and make a boot menu entry for linux-hdd.
Try booting your linux-hdd. Does it look ok and work ok?.

If so, you are almost ready to finish up. If not, go back and fix things up until you can boot and run linux-hdd from lilo.

Remember, lilo is still on the MBR of hda. If you remove hda you will not be able to boot hdd, even if you plug its cable into where hda was. You'll have to 'man lilo' to sort this out, as I am at work (and, er, not working it seems!). Maybe the thing to do is use fdisk to mark hdd as the boot disk, and then run /sbin/lilo to write its thing to the MBR of hdd, but I am not sure here.

Have fun, its an amusing exercise, and highly satisfying when you finally get it right.

Maybe you'd like to condense this thread into a HOWTO as this sort of problem seems to crop up fairly often.

Do not #rm -RF anything from hda until you are completely happy that all is well set up on hdd.

Good luck.
 
Old 09-21-2004, 11:11 AM   #9
zaipher
LQ Newbie
 
Registered: Aug 2004
Location: Norway
Distribution: Xubuntu/Ubuntu, Trustix, WinXPpro
Posts: 6

Original Poster
Rep: Reputation: 0
another success story (...in progress)

Hi again...

So far, so good - just a progress report:

Code:
bash-2.05b# fdisk -l /dev/hdd && echo "" && df

Disk /dev/hdd: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdd1   *           1         730     5863693+  83  Linux
/dev/hdd2             731        6202    43953840   83  Linux
/dev/hdd3            6203        7389     9534577+   5  Extended
/dev/hdd4            7390       19457    96936210   83  Linux
/dev/hdd5            6203        6270      546178+  82  Linux swap
/dev/hdd6            6271        7389     8988336   83  Linux

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hdd1              5771468   1630816   3847468  30% /
/dev/hdd2             43264176    676396  40390088   2% /home
/dev/hdd4             95414348  19588572  70978968  22% /mnt/storage
/dev/hdd6              8847228   3479572   4918240  42% /usr

bash-2.05b# cat /etc/fstab
/dev/hdd1        /                ext3        defaults         1   1
/dev/hdd2        /home            ext3        rw,user,exec     1   2
/dev/hdd4        /mnt/storage     ext3        defaults         1   2
/dev/hdd5        swap             swap        defaults         0   0
/dev/hdd6        /usr             ext3        defaults         1   2
#
# /dev/hda5        swap             swap        defaults         0   0
# /dev/hda1        /                ext3        defaults         1   1
# /dev/hda2        /home            ext3        rw,user,exec     1   2
# /dev/hda6        /usr             ext3        defaults         1   2
# /dev/hda4        /storage         ext3        defaults         1   2
#
# Win2000 disk
# /dev/hdd1        /mnt/nt-h        ntfs        ro               1   0
# /dev/hdd5        /mnt/nt-j        ntfs        ro               1   0
#
/dev/cdrom       /mnt/dvd         iso9660     ro,user,exec     0   0
/dev/writer      /mnt/hp          iso9660     rw,user,exec     0   0
/dev/fd0         /mnt/floppy      auto        noauto,owner     0   0
devpts           /dev/pts         devpts      gid=5,mode=620   0   0
proc             /proc            proc        defaults         0   0
When i finally started, it took me only about a couple of hours. I thought of running Knoppix from a cd, but decided i wanted to try without, and i had no problems.... Mounted the new disk, created the directories on hdd1, mounted the other partitions on hdd1, copy everything to it besides /mnt and /proc (i learned that also applied to /sys on my system - slackware 10), edited fstab on hdd & added a hdd1 entry in lilo.conf. Now i'm running from hdd

The only thing left for me to do is to install lilo on mbr on hdd & remove the old disk. (update: i just did that. installed lilo with: "lilo -b /dev/hdd1", edited fstab, removed hda, reboot - all ok) Thanks for all help.

Last edited by zaipher; 09-27-2004 at 05:11 AM.
 
Old 09-28-2004, 10:26 AM   #10
tredegar
Guru
 
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,007

Rep: Reputation: 366Reputation: 366Reputation: 366Reputation: 366
It looks as though you have cracked the problem, including how to sort out lilo. I didn't know about /sys on Slackware 10, so that is useful information too.

It is interesting that you did not need to run knoppix, but I am assuming that you remembered to go to single user mode when you were copying the files over.

Congratulations!
 
  


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
adding space - can it be 'spanned' danimalz Linux - Hardware 1 10-22-2005 06:45 PM
adding space kwickcut Mandriva 9 10-14-2005 04:44 PM
Adding space to a partition... zaxs Linux - General 1 04-07-2005 10:49 PM
Adding swap space sbrewer Linux - Distributions 4 12-19-2004 04:32 AM
adding swap space jamaso Slackware 6 06-20-2004 11:05 PM


All times are GMT -5. The time now is 08:46 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration