linuxnewbie.org.gif
Tuesday, 12-Dec-2000 10:32:58 EST
Newbized Help Files articles discussion board bookshelf sensei's log advertising info

How to create a multiple partition system

(cont'd)

You're back, huh? You better be ready, because here we go... First of all, I'm now going to diverge this NHF into two parts. One is for the people with nothing on their hard drive (or at least nothing they don't mind getting rid of). The other is for those of you who are tweaking an existing installation to accomodate a new Multi-Partition style setup.

Creating a Multi-Partition System with a clean (or soon to be clean) hard drive

You guys have it relatively easy. Basically all you have to do is:

  • remove all of the partitions on the hard drive (somehow - if you can get it to mount under Linux, then I have a using fdisk NHF that you will need later anyway)
  • create new partitions of the proper size according to your newly created strategy (I have the using fdisk NHF to help you on this)
-- now, at this point, if you are going to install a distro --
-- onto your hard drive, go ahead. It will do the rest for --
-- you, pretty much. Just make sure you specify the mount --
-- points according to your strategy and all should go fine --
  • create filesystems on those partitions (again, I have an NHF on this as well)
  • mess around with /etc/fstab however necessary

And then you are done! You will then be running a multi- partition Linux system. Enjoy it!

Creating a Multi-Partition System with an existing Linux installation already

This is actually not as hard as it sounds. You simply have to learn one new skill and you'll be well on your way - archiving. We use archiving to shrink the data down so that we can create new partitions accordingly, and then we expand the archive onto the new partition and delete it off of the old one.

It's hard to explain in words, and it's easier to explain in an example, so let's do an example.

Well, I already use a multi-partition setup and am happy with it. But, for the sake of this NHF, i'll make it a little more multi-partitioned.

Let's say that one of my partitions was supposed to be mounted at /usr/src (this is an awfully weird and excessively control-freakish choice, so it shouldn't be one of your choices). Let's also say that I wanted to give this a 1GB partition (also a bit high, unless you are a kernel fan).

The first thing I want to do is create a 1GB partition so that I can move all my stuff from /usr/src over there. Let's explore two scenarios:


I have enough space free for a 1GB partition

This actually isn't that likely unless you intentionally left space for that 1GB, because most people just fill up their hard drives. That's understandable, but I tend to leave that space unused now in case something like this happens, because having that free space is a LOT easier to deal with than not.

So, assuming you do have 1GB of unpartitioned space on your drive, all you have to do is this:

1. Make a 1GB partition (my using fdisk NHF will show you how to do this)
2. Create a filesystem on that partition (my filesystem creation NHF will show you how to do that)
3. Mount the drive (I'll explain how)
4. Copy the data over
5. Edit /etc/fstab to reflect the changes

The very VERY last step in this is to delete all of the old data to free up that space. This should only be done after at LEAST one reboot. I've lost partitions as a result of this, so I recommend doing this stuff one partition at a time, not deleting data until it's certain that the new partition "takes".

So, if you don't know how to do 1 and 2, go read the NHFs I mentioned and come back here, because I'm going to cover step 3 assuming 1 and 2 are done.

3 - Mounting the drive
By now you should have a 1GB ext2fs partition ready for use. The next thing to do is to mount it. In order to do so, we need a mount point. Just for consistencies sake, I like to name the mount point /mnt/ where is the last subdirectory of the partition we plan on creating. In this case, that's just /src. So, as root, I do:


mkdir /mnt/src

Now I'm ready to mount our new partition. The one for my example is /dev/hdb14, though yours may be different. The mount command is:


mount <partition> /mnt/

so, for me that would be:


mount /dev/hdb14 /mnt/src 

There are no real messages indicating success here, so I like to check and make sure that the partition mounted right by doing a df:


[root@half-life ddipaolo]# df
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/hdb8              1052256    165140    834504  17% /
/dev/hda1              1023312    790016    233296  77% /dos/C
/dev/hda5              4511512   3381464   1130048  75% /dos/D
/dev/hda6              4408896   3674860    734036  83% /dos/E
/dev/hdb5              2038504   1364400    568880  71% /home
/dev/hdb7               202225       247    191536   0% /tmp
/dev/hdb11             2071384   1504896    461264  77% /usr
/dev/hdb12             2071384    125472   1840688   6% /usr/local
/dev/hdb6               248894     12295    223748   5% /var
/dev/hdb14             1035660         4    983048   0% /mnt/src

That last line shows me what I want to see. A (virtually) empty filesystem mounted right where I told it to go. So, I'm convinced the mounting went fine.

4 - Copying data to new partition
Next, it's time for step 4 - copying the data over. Here's where you'll see why I named the mount point the way I did. To do this copying, you need to do a recursive copy so that you get all of the subdirectories and their data (since we want all of that). The format for this (with my scheme) is:


cp -R  /mnt

Where is the full path (and not just the deepeest subdirectory) of the partition you wanted to create. In my example, I would issue:


cp -R /usr/src /mnt

I do this because it automatically copies it into /mnt/src. I'm not exactly sure why it does, but as long as I'm consistent then this works wonderfully.

This copy can take a long time, depending upon how much data you are transferring and how fast your hard drive and system are.

Try not to do too much while the copy is happening, otherwise it might just end up taking longer. But once that is done, you can check that the copy went okay by using the du command again:


[root@half-life src]# cp -Rf /usr/src /mnt
[root@half-life src]# du -s -H /usr/src
316M    /usr/src
[root@half-life src]# du -s -H /mnt/src
316M    /mnt/src

Pretty convincing for me, at least. Let's move on to /etc/fstab so that we can mount this correctly at startup - here we go to on to step 5.

5 - Editing /etc/fstab
If you've never edited /etc/fstab before, there's not much to it. Let's take a look at it first. Use cat:


[ddipaolo@half-life ddipaolo]$ cat /etc/fstab
/dev/hdb8              /                       ext2    defaults        1 1
/dev/hda1               /dos/C                  auto    defaults        0
0
/dev/hda5               /dos/D                  auto    defaults        0
0
/dev/hda6               /dos/E                  auto    defaults        0
0
/dev/hdb5               /home                   ext2    defaults        1
2
/dev/cdrom              /mnt/cdrom              iso9660 noauto,owner,ro 0
0
/dev/hdb7               /tmp                    ext2    defaults        1
2
/dev/hdb11              /usr                    ext2    defaults        1
2
/dev/hdb12              /usr/local              ext2    defaults        1
2
/dev/hdb6               /var                    ext2    defaults        1
2
/dev/hdb2               swap                    swap    defaults        0
0
/dev/fd0                /mnt/floppy             ext2    noauto,owner    0
0
none                    /proc                   proc    defaults        0
0
none                    /dev/pts                devpts  gid=5,mode=620  0
0

Looks kinda hairy, huh? Well, it's not too bad, really. Just notice that a lot of the things are the same from column to column. Basically, you've got these five (well, six) columns:

Partition - this first one describes what partition is being mounted (or is to be mounted at boot, more precisely)

Mount point - this shows where on the Linux filesystem this partition will be mounted

Filesystem type - specifies what filesystem has been created on that partition or 'auto' to use auto-detection

Options - I've had no use to use anything but defaults, though I've heard of people having issues writing to their mounted Windows partitions as normal users when using "defaults" for their options. I simply never write to my Windows partition except as root, and defaults works fine.

Dumps/Fscks (last two columns) - This has to do with filesystem dumps, fscks, and priorities. For the most part, you can just use the values "1 2" and you'll be fine.

So, like I said, nothing to it. It's basically a cut and paste job. So, to put our new partition with filesystem at /usr/src, let's run down what should go in each column:

Partition - /dev/hdb14 (in my case)
Mount point - /usr/src (again, my case)
Filesystem - ext2
Options - defaults
Dumps - 1 2

So, if you string them all together you get:


/dev/hdb14         /usr/src        ext2    defaults        1 2 

Heck you don't even have to use a text editor to add this one. You can use echo:


echo "/dev/hdb14 /usr/src ext2 defaults 1 2" >> /etc/fstab

Make sure you use >> and not > though. Otherwise you are in serious trouble unless you made a backup.

Now, you know how to do this when you have space to make the partition. Let's look at what's different for when you DON'T have the space to make the partition you want.

[- next page: don't have 1GB free -]


Would you like to have your article published online? Send them in to newfiles@linuxnewbie.org

The Linux Channel at internet.com
Linux Planet
Linux Today
Linux Central
Linuxnewbie.org
PHPBuilder
Just Linux
Linux Programming
Linux Start
BSD Today
Apache Today
Enterprise Linux Today
BSD Central
All Linux Devices
SITE DESCRIPTIONS
[-What's New-]
Order a Linuxnewbie T-Shirt
Easy Webcam NHF
Directory Navigation NHF
Installing Snort 1.6.3 on SuSE 6.x-7.x
Customizing vim
The SysVinit NHF
Installing ALSA for the VT82C686 integrated sound
USB Creative Video Blaster II for Linux
Configuring the Intellimouse Explorer in XFree86 V4+
The beginnings of a distro NHF
Getting Past Carnivore?
Getting and Installing PGP
Getting your ATI Rage 128 Working
How to create a multiple partition system
Using Fdisk
Introduction to Programming in C/C++ with Vim
Adding a Hard drive in Linux -- In five steps
Installing ALSA for the Yamaha DS-XG Sound Card
Getting your Diamond Rio Mp3 Player to work with Linux
Bash Programming Cheat Sheet
Installing NVIDIA Drivers for Mandrake
Setting up Portsentry
Hard Drive Speed Tweak for Linux
Sensei's Log
Chat room
Join: Linuxnewbie.org SETI Black Belts!
Send in your news
Click the image to add Linuxnewbie.org to your MyNetscape Page
[-LNO Newsletter-]

[-Archive-]
The beginnings of a distro NHF
Connecting to the Internet using KPPP
Getting your SBLive to work
Unreal Tournament NHF
LWE Day 2 Pictures
LWE Day 1 Pictures
The LNO FAQ!
WoW (Words of Wisdom)
Other sites news
What is Linux?
What is Linux? part deux (ups & downs)
Search newsgroups
The List
ALS Report
Feedback Form
jobs.linuxtoday.com.gif
Match: Format: Sort by:
Search:
[-Quick Links-]

Copyright 2000 internet.com Corp. All Rights Reserved. Legal Notices Privacy Policy

internet.com.gif