Menu

Results for category "Fdisk"

2 Articles

The QND Guide to Starting Programs at Boot

Many programs, such as CUPS, samba, Canna and the like are programs that you wish to start running when the machine boots. Most operating systems have their own way of doing this. This QND guide covers how to do it in various Linux distributions, as well as FreeBSD and NetBSD.

In a pinch, one can always add a line to their /etc/rc.d/rc.local file (sometimes /usr/local/etc/rc.d, and sometimes /etc/rc.local) giving the full path to the program. For instance, if you install cannaserver from the vanilla version we provide, (see the QND Guide to Using Japanese in *nix) you could simply add the following line to ArchLinux’s /etc/rc.local

/usr/sbin/cannaserver

However, as most distributions provide a way to more gracefully do this, it is worth learning.

RedHat

RedHat (and we are including Fedora in this) has a simple ncurses program called ntsysv. If you type

ntsysv

at a command prompt, a dialog comes up with various services. Hitting the space bar while a particular service is hightlighted will add or remove an asterisk from it, determining whether or not it should be started at boot.

They also have a little program called chkconfig. The syntax is as follows, using sendmail as an example

chkconfig --level 35 sendmail on

To stop it from running at startup simply change the on to off. The level part of the command refers to run levels–in RH level 3 is multiuser non-graphic and level 5 is graphic.

Slackware

Slackware has an /etc/rc.d/rc.M file. A sample from it goes

if [ -x /etc/rc.d/rc.sendmail]; then
. /etc/rc.d/rc.sendmail start
fi

So, one can add a program to this. Again, going back to our cannaserver program, one can simply add the lines

if [ -x /usr/sbin/cannaserver]; then
. /usr/sbin/cannaserver
fi

If one looks at the file, they can see other examples. There are other ways to do it, including echoing “Starting the cannaserver” before starting it, etc.

Gentoo

When a package is emerged in Gentoo, one can usually simply add it with the rc-update command. Canna is one of those that can be added. In this case

rc-update add canna default

ArchLinux

ArchLinux has an /etc/rc.conf file. In there is the line

DAEMONS=(!pcmcia network crond inetd)

One simply adds the daemons they want run at boot to that line. For example, if you want the sshd daemon to run at boot, change that line to read

DAEMONS=(!pcmcia network crond inetd sshd)

(Note that putting ! in front a daemon’s name disables it–for example, in the default the pcmcia daemon is prefixed with a !, meaning it will not start at boot).

FreeBSD

FreeBSD puts most programs that don’t come with the base system into either /usr/local/bin or /usr/X11R6/bin. In almost all cases, a FreeBSD port also installs a script in /usr/local/etc/rc.d. One will usually, after installing canna for example, find that a little shell script starting the daemon is in /usr/local/etc/rc.d. Continuing with our canna example, one finds that as long as it was installed from ports, there is a script in there called canna.sh.sample. If you wish canna to run at boot, simply remove the “sample” from it.

cd /usr/local/etc/rc.d
mv canna.sh.sample canna.sh

Recently, many of the /usr/local/etc/rc.d script will have commented instructions that one should add a line to /etc/rc.conf. For example, with samba, one adds

samba_enable="YES"

so one should take a quick look at the .sh script to see if this is necessary.

NetBSD

NetBSD is quite similar to FreeBSD in this respect, however the startup script is usually found in
/usr/pkg/local/rc.d

It is hoped the above will enable you to get a program to run at boot without problems.

The Quick-N-Dirty Guide to fdisk

The aim of this QND guide is to get you up and running quickly with fdisk. There will be far more how than why here.

Although most distros usually have their own graphical partitioning tools, it is good to be familiar with fdisk. One never knows when they may have to use it–sometimes graphical tools don’t work properly.

Many, if not most, distributions also now have cfdisk which is somewhat easier to use. However, there are times when cfdisk too, won’t work and fdisk will.

1.) Do you have fdisk?

You should definitely have fdisk available. If not, something is probably wrong with your system. However it is one of those commands that is run by root or with root privilege. Therefore, it might not be visible (depending upon distribution) as normal user. You may have to either log in as root or do

su –

instead of using sudo or a simple su.

2.) Using fdisk

In this case, the easiest way to explain fdisk’s use is by example. We will assume that you have a 10 gig hard drive. 3 gigs are devoted to Windows and now you wish to install Linux on the other 7 gigs. For purposes of this example, we will create an extended partition and inside of it create 3 logical partitions. One will be swap, one will be a small /boot partition and the last will use up the remaining free space.

Although most versions of LILO and GRUB will, on modern computers, now boot beyond the 1024th disk cylinder, we’re keeping our boot partition within the first 4 gigs of the drive. (There are other reasons to keep a separate /boot partition, but it often simply depends upon personal perference. At any rate, that is beyond the scope of this guide.)

First, we see what we have

fdisk /dev/hda

This will start the fdisk program. Now, to see what is already there, type

p

The p stands for print, and will show you what exists. At present, you should only have one partition, the one that is holding Windows. (I’ve found that Windows seems to partition disks differently–with Slackware, for example, I also get a warning that the partition doesn’t end where it should–however, it hasn’t caused me problems, so, I shrug it off.)

Now, we want to refresh our memory on the commands so we type

m

(In this case, I assume it stands for manual). It will show me the possible commands.

Firstly, I want to create my swap partition. One could make a new primary partition, but I don’t find it necessary so, I type

n

I’m then asked do I want a primary partition or extended partition. I’m told to type p for primary or e for extended. I choose e for extended. Next I’m asked for a number for the partition, usually given the choice of 1-4. I pick 2 as it’s the next partition.

It will then ask for the first cylinder, showing the default, which is the next cylinder next to the already existing Windows partition. Hit enter to accept the default. Then it asks for the last cylinder–the default is the end of the drive and again I hit enter to accept it.

I then again type p to verify that I did what I wanted. Hopefully it is showing me what I asked for.

Now I type n again for a new partition. This will be my swap partition. I’m asked do I want to make a primary one or a logical one. As you might guess, I’m told to type p for primary and l for logical. I choose l, as I’m making a partition within the extended partition.

I’m then informed that the numbers will begin at 5. I’m then asked for the first cylinder–again I choose the default, which is the first cylinder available.

I’m then asked for the last cylinder–however, I’m also given the option of specifying my size in Megabytes by typing + (desired size)M. I want my swap partition to be 128 Megabytes so I type

+128M

I hit enter. One could type p again to verify that it’s going the way you want it to, that’s up to you. Doing that, I find that this 128 Meg partition is Linux native, which I don’t want, I want Linux swap. So, I then type

t

It will ask me which partition’s type do I want to change. I pick 5, which is my first logical partition. (I can also discover this with the p command–the partition will be /dev/hda5). I’m then asked for the type, and told I can type L for a list of hex codes. I already know that swap is hex code 82, so I type

82

Now, I’m making my boot partition. This can be of various sizes–RH recommends 16 Megs, so I make it 20 Megs just in case. So, I begin by typing

n

Again, I’m presented with the choice for logical or primary and choose logical. Again I’m given the default 1st cylinder, which I accept and again asked for the last cylinder, with the option to specify size in Megabytes.

I type

+20M

This gives me a 20 meg partition to use as boot. It might be slightly different, as like the fdisk found in DOS fdisk will determine cylinder boundries and adjust accordingly.

Once again I type p to see what I have. I now see one Windows partition, and one extended partition. The extended partition has one 128 meg logical partition as Linux swap and a 20 meg Linux native partition.

So, once again, we type n to create the final partition. (If you were making separate partitions for /usr, /home, etc you could make more–however, we’re keeping it simple here.

Again, I’m asked to choose between logical and primary and choose logical. I’m asked for the first cylinder, with the default being the first unused one, which I accept by pressing enter–I’m then asked for the last cylinder, with the default being the last cylinder on the disk. Once again I press enter to accept it.

Lastly, I press

w

This writes the changes to disk–there are various warnings and messages. In most cases, you’re done. In others, you might be told that you have to reboot for the changes to take place.

references

man fdisk