Creating Filesystems
by Danny "Strike" DiPaolo
The two types of filesystems you will need to learn how to make in order
to get your Linux multi-partition system up and running are: swap and
ext2, like the ones we just made with fdisk.
--Creating a swap filesystem--
The command for this is mkswap. You have to be root to run this, of
course. If you get a "command not found" error, then you need to enter
the full path, which is:
/sbin/mkswap
The options for mkswap are (ripped from man page):
-c Check the device (if it is a block device) for bad
blocks before creating the swap area. If any are
found, the count is printed.
-f Force - go ahead even if the command is stupid.
This allows the creation of a swap area larger than
the file or partition it resides on. On SPARC,
force creation of the swap area. Without this
option mkswap will refuse to create a v0 swap on a
device with a valid SPARC superblock, as that prob
ably means one is going to erase the partition
table.
-v0 Create an old style swap area.
-v1 Create a new style swap area.
The "-c" option is probably a good idea, just to be safe. The "-f" option
should probably be avoided, unless of course you know what you are doing
(but if you are reading this NHF, the chances that you do are not real
high). The "-v0" and "-v1" options are not really necessary. Look at the
man page if you want an explanation of the differences between the two.
We will use a new style swap area.
So, if you don't remember what partition you created your swap partition
on, now is the time to go look it up in fdisk, because we will need it.
Once you've got it, you should issue this command:
/sbin/mkswap -c -v1
So, mine on /dev/hdb13 would be:
/sbin/mkswap -c -v1 /dev/hdb13
When I enter this in, it takes a while (took me about 40 seconds on a
decently fast hard drive and overall decently fast system). Eventually it
came back with this sort of "confirmation message" though:
Setting up swapspace version 1, size = 271396864 bytes
And then another command-line prompt. And... that's it! We're done. Now
we can turn it on right away using swapon, or we can simply stick it in
/etc/fstab and let it turn on the next time we reboot. But, since I tend
to go at least a few days at a time without rebooting (and never because
of a crash, mind you), let's do both.
Turning it on with swapon
The syntax is simple and straight-forward:
/sbin/swapon
The only flags/options here that are available aren't incredibly useful
right now, so we'll just stick with that. So, in my case, I issue:
/sbin/swapon /dev/hdb13
And when I do so, it seems like nothing happened. Let's examine what the
difference is though. Here's what free says before the change (note, I'm
cutting out the last three columns for space considerations):
[root@half-life ddipaolo]# free
total used free
Mem: 255644 252756 2888
-/+ buffers/cache: 109248 146396
Swap: 136544 1244 135300
And here's after the change:
[root@half-life ddipaolo]# free
total used free
Mem: 255644 253792 1852
-/+ buffers/cache: 110284 145360
Swap: 401576 1244 400332
The key number is the "total" in the "Swap:" row. See how much bigger it
got? All right! Now to put it in /etc/fstab so we can always enjoy the
swap goodness without having to turn it on each and every time.
Adding it to /etc/fstab
If you've messed with /etc/fstab before, this step ought to be easy. Hey,
even if you HAVEN'T messed with /etc/fstab before this step ought to be
easy, because it's pretty much copy-and-paste.
Sometimes I forget the format of /etc/fstab, but thankfully, I have enough
partitions in there that I can just look at it and figure it out. Also, I
have a swap partition in there I can use as a guide to adding this new one
in there. The line with my first swap partition says:
/dev/hdb2 swap swap defaults 0 0
So, you know what I do? Add another copy of that line with exactly the
same stuff, except changing the first part to the partition on which we
just created our filesystem. So, I add this:
/dev/hdb13 swap swap defaults 0 0
Told you it was easy...
[- next page -]
Would you like to have your article published online? Send them in to newfiles@linuxnewbie.org
|