LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Adding partition (https://www.linuxquestions.org/questions/linux-general-1/adding-partition-25541/)

tommygunner 07-11-2002 05:20 AM

Adding partition
 
I already have Linux installed and running and want to add a partion for /var because I store lots of files there. Does anyone know how to do this without re-installing?

My other options are to store large files in /home directory and point Apache there.

Another option that I think is possible is creating symbolic link from /var directory to /home.

I only know how to do second thing. The rest I don't know how to do. Can someone help me? I am using Mandrake Linux 8.2

Mara 07-11-2002 05:51 AM

You can use parted to resize a partition. From the free space create a new partion - for /var. Mount it, copy all data. Then you need to modify fstab to add your /var partition there. When it's done delete old /var and test it.
NOTE: It's a good idea to make backup copies.

Mik 07-11-2002 05:52 AM

Well if you've got the partition already created all you have to do is change a few things to get it to mount.

Add a line something like this to the file /etc/fstab:
/dev/hda7 /var ext2 defaults 1 1

Make sure it's formated for the particular filesystem, ex. 'mke2fs /dev/hda7'

Then you should create a new entry for /var:
mv /var /oldvar
mkdir /var

Then mount it:
mount /var

Then copy all the old stuff to the new var directory:
cp -a /oldvar/* /var


If you want to have the files on the /home partition then you would do something like this:

mkdir /home/othervar
cp -a /var/* /home/othervar
rm -rf /var
ln -sf /home/othervar /var

JaseP 07-11-2002 06:05 AM

parted,... huh?!?!? Never used it. Mandrake 8.2 has a nice utility to move partitions around.

If you are using Mandrake 8.2, I would use diskdrake. It has a nice, easy-to-use GUI front end.

If the partition is already created, you simply make it's mount point as /var and copy all of your /var directory files there. Diskdrake might do it for you automatically, but have a back-up.

If you don't have the partition created,...

Copy all the files to a partition that is not going to be volitile. For instance, if you have a large /home partition,but not much there now, you can back up all the files to some other partition (either the root partition if large enough or a windoze FAT partition if large enough). Then unmount and resize the partitions using diskdrake. format them and create their appropriate mount points (i.e.: /var, /usr). Then copy your data back to the appropriate partitions. If you are doing this for the /home partition, make sure you reset the permissions to the users who's accounts they are. Moving them will often change them to ownership by root. You have to make their owners and groups back what they were.

JaseP 07-11-2002 06:14 AM

By the way, tommygunner, are you aware of the Mandrake User Forum boards???

Check here, you can post the same request there for different/better answers:
http://www.club-nihil.net/mub/

Mik 07-11-2002 06:20 AM

Moving the files will not change the owner. This only happens when you do a copy. Buy you can prevent that by using the -p switch which will preserve the owner and group (-a is equivalent to -dpR so you don't have to add a -p to that).

JaseP 07-11-2002 08:38 AM

Trying to copy large segments of files complete with parsing over subdirectories with the command line is a pain. I just use konqueror.

Whe I do it often resets the ownership. So I just use it to set it back. It's still faster than moving them over with the command line interface.

Command line is great for some things, but just not for moving things around quickly. GUI is more intuitive and faster for that.

acid_kewpie 07-11-2002 08:43 AM

no, you should always use command line for moving large amoutns of files aruond for partitions etc. if you know whow to use it it will be a much more reliable and safer option, free from risking breaking symlinks or changing ownershpis and such. using konqueror seems very dangerous to me.

normallly i use a combination of find and cpio..

find -xdev /some/where/ | cpio -pvd /destination

preserves everything perfectly. no risk.

RefriedBean 07-11-2002 09:58 AM

Quote:

Originally posted by JaseP
[B(either the root partition if large enough or a windoze FAT partition if large enough).[/B]
It might not be such a good idea to copy them over to a FAT partition. The reason being that FAT has no concept of the things like file ownership etc. that unix has. If you do that, all the files will lose their permissions etc, and you might be in for a nasty suprise.

Correct me if I'm wrong :)

GoodLuck!
RefriedBean

tommygunner 07-11-2002 02:36 PM

If I want to copy my entire hard drive to backup drive, what command would I need to issue?

tommygunner 07-11-2002 02:41 PM

When adding /var partition, where is it picking up space from? It has to take space from another partition. My /home partition is largest.

JaseP 07-11-2002 04:06 PM

tommygunner,

You should copy one partition at a time.

Diskdrake will allow you to reformat one partition at a time, even breaking it into smaller partitions, but it is a destructive process, so you need to have that data backed up somewhere.

As for backing up to a FAT drive, that's why I mentioned that a FAT drive may over-write your permission settings. However, konqueror allows you to re-set them once the data is back in it's own partition by (a) enable hidden file view, and (b) right click on the directory and change its permissions, making sure to check the box indicating that you want the changes to be globally applied to all subdirectories and their contents.

It's not a real problem when moving user data around.

Once you create a /home and a /var out of the present /home partition,...
diskdrake will ask if you want to transfer the data from the /var directory into the newly created /var partition. You say yes and it begins the format procedure followed by the file transfer.

Then you reset the /home partition the same way, and move the data from wherever you backed up the /home data to back to the newly resized /home partition. Make sure permissions are right, and whalla,... your system is now the way you want it.

If you prefer, back up the /home directory with the command line references the others indicated and do it to a Linux partition rather than a FAT one. I suggested using a FAT partition because most people have a spare FAT partition mounted on their Linux systems (either as their duel boot partition or as a secondary hard drive within both Linux and Windoze).


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