moving partitions and services ... possible without rebuilding?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
moving partitions and services ... possible without rebuilding?
Now that I'm getting a little more comfortable in linux (yeah, over the course of just 2 weeks), I'm ramping up my efforts to use this machine as a major part of my business. I've been working on using it as a web server and file server ... luckily, so far I've only set up the web server. However, now I'm running into some questions. I'm hoping that I don't have to rebuild the machine because I goofed the first time. I got quite a ways with the manuals I found so far (and some well placed tips from members on this board)
I just added a new 40Gb drive, formatted it as ext3, 2 primary partitions of about 20Gb each and mounted them to /www and /export respectively. No problem (I love this about linux). They're in my fstab and mount correctly when I boot (side question ... why is there a "lost+found" folder on each of those mounts?).
Now, I've got MDK 9.2 built up on a 15Gb drive that I want to keep as the master. There's ~6Gb in the root mount and ~9Gb in the /home mount. It looks like I only added 500k of swap. Heck, here's the fdisk -l output:
Disk /dev/hda: 15.3 GB, 15393079296 bytes
255 heads, 63 sectors/track, 1871 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 764 6136798+ 83 Linux
/dev/hda2 765 1871 8891977+ 5 Extended
/dev/hda5 765 827 506016 82 Linux swap
/dev/hda6 828 1871 8385898+ 83 Linux
Disk /dev/hdb: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 2433 19543041 83 Linux
/dev/hdb2 2434 4865 19535040 83 Linux
and mount -l:
/dev/hda1 on / type ext3 (rw) 
none on /proc type proc (rw)
none on /proc/bus/usb type usbdevfs (rw)
none on /dev/pts type devpts (rw,mode=0620)
/dev/hda6 on /home type ext3 (rw) 
/dev/hdb1 on /www type ext3 (rw) 
/dev/hdb2 on /export type ext3 (rw) 
So, what I'd like to do is the following, and I could use some good references:
1) move my /var/www contents onto /www along with the apache / PHP / web services I'm already hosting there. When I installed Mandrake, Apache and PHP came pre-configured into /var/www/ for hosting. I'm not yet sure how easy they are to change.
2) probably extend my swap space ... most likely stealing from my /home mount (I have only 3 users and will not be using this box as a primary workstation, so don't see myself /ever/ needing 8+Gb, 2Gb should be plenty)
3) from my reading, it sounds smart to have a specific partition for boot that's read only for system recovery (God-forbid!)
4) Increase my swap space to at least 1Gb
5) With the leftover space on hda, possibly create a logging partition so I can turn up logging on the web server and file server ... catch my officemates red-handed when they mess something up ... instead of me messing it up .
Another question is with swap space ... I notice that the first drive (hda) has the second partition as extended and then divides that into swap and linux partitions. Should I be doing something similar on hdb, or will hdb utilize the swap on hda?
My last question is in regards to using this as a file server. If I'm going to use it as a fileserver for both linux and windows clients, do I have to have an NTFS mountpoint specified (no one should be /running/ files on this, simply copying to and from ... more of an extended hard drive for this LAN)?
I have to laugh, running on this old A800, my processing speed kicks the Ultra 60 they let me use at my other job squarely in the mommy-daddy button. When I upgrade this PC to more current standards, I'm going to really be shocked!
You may or may not need the extra swap space if all you have is 3 users. Monitor its usage and if your running on the edge you can create an additional swap partition. Swap is similar to XP pagfile or windows 98 386swp file.
A lost+found directory is use by fsck. If it finds corrupted files during a filesystem check thats were they end up.
You do not need a specific NTFS partition for sharing files. samba takes care of everything. The filesystem used for sharing can be any linux fs type.
Congratulations JohnLocke! You did a pretty job in this two weeks. Well, go to the questions now. 1) The lost+found directory is a kind of last resort when things go bad. If the file system gets unstable, for example, when power is off without the proper shutdown proceedings. In this case, when the system starts up again, it detects the situation and starts a file system checking. Normally this will be soon corrected with no problems, mainly because ext3 is a journaled file system. This means, all operations, before taking place, are written in the journal file. However, sometimes, for example, a bad hd and a power outage when it is still rebuilding from previous outage, may corrupt some portions of a file system. Then, for example the checking routine finds some files and sub-directories it can't find the parent directory, it will move these files to this lost+found directory. The names of these files will be lost but, if you know the file by the contents, you can identify it and move it again for its proper location and proper name.
2) The time to reinstall the system is gone. You can do it for fun but, not for fundamental need. Let's talk a few about primary and secondary partitions. Once upon a time, very before Mr. Bill told us his prophetic words "640k should be enough for everybody", hardware was so expensive. PC's ran with 2 floppy diskettes each one with 360kB. And we did our labor. When hard disks were launched they had the astonishing capacity of 5 to 10MB. Their capacity was too great to that pcs, which used FAT12. Everybody was talking about the challenges of the 640k barrier each corner. 512 bytes of data was too expensive. It was unimaginable to spend more than 1 sector to map that wonderful hd to be used by dos. 5/10MB should be enough for everybody. As a compromise, the layout of this very first sector of the hd would have a partition table to up 4 partitions. (4 partitions should be enough ...). Well those partitions are today our honorable "primary partitions". Few years late, the disks grew up in capacity and there was no way to map it with just 4 partitions. So, a new spec gave us a way to get one of this partitions to make room for more partitions. This is our "extended". They are extended because broke the limit of 4 we had before. We use it to map the whole available disk and give it more 12 partitions in each disk. At least in linux, where we can have 16 partitions for each disk. Of course we are talking about IDE disks.
So, if you use primary or extended, it's just upon your needs to divide your whole disk. The once difference between the two mappings is. If you remove a primary partition, no harm happens with the neighbor ones. Suppose, you have partition mapped to cyls 1-10, partition 2 to cyls 11-20, partition 3 to cyls 21-30, if you remove partition 2 and save the partition map, you will have yet partitions 1 and 3. However, if you do this same scheme in partitions 5, 6 and 7, removing partition 6 and you will see there is no more partition 7. There is no number hole in the secondary partition so, partition 7 will become partition 6.
After this little history, you just need to be careful but is nothing to afraid. First we have to stop all activity we can't control as a remote login. To do that, we have to enter single user mode. All you have to do on the console is to enter
This command will close X, stop network in an orderly basis and leave you with one console. After this you will have to copy all the contents of your home file system to a temporary area you can do this by entering this command, using two copies of tar
(cd /home;tar c .)|(cd <path-to-temporary-hold-home>;tar xv)
Untill now nothing special happened. You just duplicated the contents of your home directory. Now we have to free these partitions. We have to do 2 operations: unmount /home and disable swap
Now we will use fdisk and redistribute the partitions without touch /dev/hda1. This partition is running our system. You can even remove the extended partition if you want for repositioning. But don't touch in the partition 1. After conclude the remapping and writing, may be the system asks you to reboot to re-read the partition. As you are using the disk you are already changing the partition table, sometimes the system asks you to do so. If it doesn't ask you, run fdisk -l to see if your changes are there. If they are not, reboot the system. Then, you must make the new swap partition, by entering
and recreate the home partition
mke2fs -j /dev/hda6
If you changed the numbers of these partitions, use the proper partition number in the above commands and don't forget to edit /etc/fstab to point to the correct swap and home partitions. Now you can reactivate the swap partition with the command
and mount again your /home
Time to bring back your /home content
(cd <path-to-temporary-hold-home>;tar c .)|(cd /home;tar xv)
Now if you run the system just in text mode you enter
else if you run X
P.S. if you need to reboot the system just after the fdisk phase, you have to restart it in single user mode. If your boot loader is lilo, in the prompt, you have to enter
. However, if your boot loader is grub, when the menu appears, you enter "e" to edit the menu, then it will appear the line of the kernel specification. Enter "e" again to edit this line. If there is a number "3" or "5" alone in the end of this line, delete it. Add a number "1" at end of the line, separated by space from the other parameters. Enter and press "b" to boot. The system will boot up to level "1", which is single user to complete your operations.
3-For use apache mounted on /www, the best is to mount your partition in "/var/www". All you have to do is, as in the previous operation, enter single user mode, copy with "tar" as in the /home saving procedure all the contents of "/var/www" to "/www". After the copy, unmount /www, edit /etc/fstab to mount this partition in "/var/www", then mount it and return to the previous multi-user state.
Again, congratulations! You are doing very well! The once problem you had was the partition type as I forgot to talk to you. For system performance, there is no problem. However, after some years, you will forget swap is on partition 5 and maybe you could try to boot or check this partition. And the answers it will give will be so strange that you will think about installing the whole mess. So, any time you could enter in maintenance, run again fdisk and use the command "t" (partition type) and set it to number 82, which is "linux swap". After this, initialize swap again and activate it. If your load is not too great, you neither need to enter in single user. The full sequence of commands would be:
I don't have many clues about monitoring the system performance as my biggest customers have approximately 50 users running c applications I develop and that is possible as my applications are text mode. However, as a starting point, you can use "top" and "free". Top is a monitoring program which shows us the load of the system every 3 seconds. Free shows us the memory and swap usage.
Thanks much for both the help and the compliment! I've had exposure to some nix style platforms over the years, but never on the SA level.
I've got the type switched now so I know what the swap space is (useful trick!).
As to monitoring the system, it looks like free simply repeats what's in the top of top, so I'm using top to look at it right now ... and it's telling me (I think) that I ought to buy some more memory!
This shocked me:
top - 09:27:25 up 5:57, 1 user, load average: 0.00, 0.00, 0.00
Tasks: 55 total, 1 running, 54 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.3% user, 0.0% system, 0.0% nice, 99.7% idle
Mem: 514924k total, 453312k used, 61612k free, 59036k buffers
Swap: 2000052k total, 0k used, 2000052k free, 271732k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ Command
14246 apache 9 0 7616 7616 7284 S 0.0 1.5 0:00.04 httpd2
23585 apache 9 0 7608 7608 7288 S 0.0 1.5 0:00.05 httpd2
8304 apache 9 0 7600 7600 7288 S 0.0 1.5 0:00.03 httpd2
7488 apache 9 0 7596 7596 7284 S 0.0 1.5 0:00.04 httpd2
27571 apache 9 0 7588 7588 7292 S 0.0 1.5 0:00.05 httpd2
19553 apache 9 0 7584 7584 7252 S 0.0 1.5 0:00.08 httpd2
22863 apache 9 0 7560 7560 7260 S 0.0 1.5 0:00.01 httpd2
3540 apache 9 0 7556 7556 7260 S 0.0 1.5 0:00.02 httpd2
26603 apache 9 0 7380 7380 7132 S 0.0 1.4 0:00.04 httpd2
19833 apache 9 0 7368 7368 7132 S 0.0 1.4 0:00.01 httpd2
26084 root 9 0 7092 7092 6940 S 0.0 1.4 0:00.80 httpd2
28338 xfs 9 0 3680 3680 936 S 0.0 0.7 0:00.12 xfs
2597 root 9 0 2728 2728 2428 S 0.0 0.5 0:00.17 smbd
12761 named 9 0 2320 2320 1764 S 0.0 0.5 0:00.00 named
17503 named 9 0 2320 2320 1764 S 0.0 0.5 0:00.12 named
32506 named 9 0 2320 2320 1764 S 0.0 0.5 0:00.08 named
8962 named 9 0 2320 2320 1764 S 0.0 0.5 0:00.06 named
21437 named 9 0 2320 2320 1764 S 0.0 0.5 0:00.00 named
11108 amclauth 12 0 2120 2120 1920 S 0.0 0.4 0:00.53 sshd
27427 root 9 0 2092 2092 1384 S 0.0 0.4 0:00.06 advxsplitlogfil
19753 root 9 0 1944 1944 1748 S 0.0 0.4 0:00.03 smbd
8856 root 9 0 1840 1840 1684 S 0.0 0.4 0:00.03 sshd
9383 root 9 0 1812 1812 1660 S 0.0 0.4 0:00.95 nmbd
27804 amclauth 9 0 1748 1748 996 S 0.0 0.3 0:00.08 tcsh
26130 root 11 0 1528 1528 1092 S 0.0 0.3 0:00.08 bash
25378 root 9 0 1504 1504 1404 S 0.0 0.3 0:00.00 nmbd
32069 root 8 0 1388 1388 1256 S 0.0 0.3 0:00.43 sshd
14832 root 9 0 1312 1312 428 S 0.0 0.3 0:00.19 klogd
25513 root 19 0 980 980 784 R 0.2 0.2 0:00.12 top
11375 root 9 0 968 968 792 S 0.0 0.2 0:00.02 su
18881 root 9 0 900 900 748 S 0.0 0.2 0:00.06 xinetd
14102 root 9 0 612 612 512 S 0.0 0.1 0:00.53 syslogd
425 root 4 0 588 588 520 S 0.0 0.1 0:00.13 crond
19478 rpc 9 0 536 536 464 S 0.0 0.1 0:00.00 portmap
31759 daemon 9 0 504 504 444 S 0.0 0.1 0:00.00 atd
1 root 8 0 500 500 444 S 0.0 0.1 0:04.42 init
20362 root 9 0 360 360 316 S 0.0 0.1 0:00.00 mingetty
4743 root 9 0 360 360 316 S 0.0 0.1 0:00.01 mingetty
4805 root 9 0 360 360 316 S 0.0 0.1 0:00.00 mingetty
22812 root 9 0 360 360 316 S 0.0 0.1 0:00.00 mingetty
1619 root 9 0 356 356 316 S 0.0 0.1 0:00.00 mingetty
26849 root 9 0 356 356 316 S 0.0 0.1 0:00.00 mingetty
sorting by how much memory is used ... apache's killing me! Ah well, I'm not digging into my swap yet, but then, I've no real users connected but myself. I'm not sure why these "named" processes have so many copies running. I understood "named" to be the Internet Domain Name Server ... which I'm not exactly sure I even need to be using at this point (I'll look that up later), but to have it running this many times? Hrmmm. The same goes for apache. It's interesting that there's this many instances running.
At least the CPU itself isn't even struggling.
Thanks for all the help! The system's beginning to look good. I've got the sftp, ssh, samba, apache, php servers up and running and accessable from the internet now (minus samba, local net only there!). Next step is looking at beefing up security or at least customizing the MDK level 4 security to do what I /actually/ want.
If you install 2gB of memory, you will see you need more memory. The reason is the following. Every byte linux brings to memory will be discarded only if the memory is full. You will always see this condition. What we gain with this? If you are accessing frequently some files, for example, a database or the pages you are serving, linux will bring from disk just once. The remaining accesses will find it already in memory. It is a visible difference.
"named" is really the dns server. It always start with a minimum of 5 threads. The same happens to apache. Apache is on top because your machine is with 0.3% of load. It is a light application. And you have an athlon 800, as you said.
You will need more memory when the system starts to use heavy swap. In your situation, the first thing which will happen is go down to reality. When linux needs memory it will discard the free buffers. Only after, when there is no more free buffers, it will start to swap the least accessed pages. I think you will demand for more processing power before more memory.
Time and use will tell us.