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

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
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