Drew wrote:
>> Edit /etc/fstab ...
>> ... configure it appropriately ...
> 1) Edit it how?
> 2) Define "appropriately".
That's kind of a Religious Question<tm>. Epic jihads have been lauched over the matter of system partitioning. Here's my wacky, somewhat over-complex entry into the sweepstakes, from my main server:
\nuncle-enzo:~# cat /etc/fstab\n# /etc/fstab: static file system information.\n#\n# filesys mountpoint type options dump pass \n/dev/sda5 / ext3 defaults,errors=remount-ro 1 1\n/dev/sda7 none swap sw 0 0\n/dev/sdb6 none swap sw 0 0\nproc /proc proc defaults 0 0\n/dev/fd0 /mnt/floppy auto defaults,user,noauto 0 0\n/dev/sda1 /boot ext2 ro,noauto,noexec,nosuid,nodev 1 2\n/dev/sda6 /mnt/recovery ext2 rw,noauto 0 2\n/dev/sdb7 /var ext3 rw,nodev,nosuid,noatime 1 2\n/dev/sda8 /var/log ext3 rw,nodev,nosuid,noatime 0 2\n/dev/sdb8 /usr ext2 ro,nodev 1 2\n/dev/sda9 /usr/local ext3 rw 1 2\n/dev/sdb1 /home ext3 rw,nodev,nosuid 1 2\n/dev/sdb5 /tmp ext3 rw,nosuid,nodev,noatime 0 2\nuncle-enzo:~# df -H\nFilesystem Size Used Avail Use% Mounted on\n/dev/sda5 985M 166M 769M 18% /\n/dev/sdb7 2.0G 1.2G 745M 61% /var\n/dev/sda8 985M 139M 797M 15% /var/log\n/dev/sdb8 3.0G 848M 2.0G 31% /usr\n/dev/sda9 5.0G 2.2G 2.6G 46% /usr/local\n/dev/sdb1 985M 781M 154M 84% /home\n/dev/sdb5 291M 9.2M 267M 4% /tmp\n/dev/sda1 97M 10M 82M 11% /boot\nuncle-enzo:~# \n
Since the machine has two physical disks (sda and sdb), I've put some swap space on each of them, and split pieces of the system filesystem between them, hoping to split head-seeking activity between them, to maximise mass-storage performance. Parts of the tree at risk for explosive file growth (/home, /var, /tmp) are carefully kept off the root filesystem to protect the latter. The separate /boot partition is a bit of an archaism, and I probably won't do that with future system builds.
The "noatime" flag is a performance aid on parts of the tree where I figure the atime date stamp isn't really needed or useful. The other "no*" flags are perhaps feeble measures at greater system security. (Don't try "noexec" on /tmp; packages often try to run preinst or postinst scripts in there!) Note that /boot and /usr are the only non-journaled filesystems: Being mounted read-only, there's no point in journaling overhead.
The read-only flag ("ro") on the /usr filesystem helps prevent accidental system catastrophe at the sysadmin's hands or equivalent, but you'll want some mechanisms to remount it read/write for package installation/removal, such as the shell scripts I call from /etc/apt/apt.conf:
\nDPkg {\n // Auto re-mounting of a readonly /usr\n Pre-Install-Pkgs {"/home/rick/aptdpkgro.sh";};\n Pre-Invoke {"mount -o remount,rw /usr";};\n Post-Invoke {"/home/rick/aptdpkgclean.sh; mount -o remount,ro /usr";};\n}\nuncle-enzo:/etc/apt# cd /home/rick \nuncle-enzo:/home/rick# cat aptdpkgro.sh \n#!/bin/sh\n\npathmatch="^/usr"\n\nwhile read debname; do\n pkg=$(dpkg --info $debname | sed -n 's/^ Package: *//p' | head -1)\n (dpkg -L "$pkg" 2>/dev/null || true) | grep "$pathmatch" |\n while read file; do\n [ -f "$file" -a ! -L "$file" ] || continue\n dir=`dirname "$file"`;\n base=`basename "$file"`;\n inode=`find "$file" -printf "%i\\n"`\n (cd "$dir" && ln "$base" ".${base}.dpkg-ro-used.$inode")\n echo "$dir/.${base}.dpkg-ro-used.$inode"\n done >>/var/lib/my_ro_hack.todel\ndone\n\nuncle-enzo:/home/rick# cat aptdpkgclean.sh \n#!/bin/sh\n\npathmatch="^/usr"\n\ncat /var/lib/my_ro_hack.todel | while read file; do\n [ -f "$file" ] || continue\n N1=`find "$file" -printf "%i\\n"`\n\n b=`basename $file`; d=`dirname $file`\n XF="${b#.}"; XF="$d/${XF%.dpkg-ro-used.*}"\n N2=`find "$XF" -printf "%i\\n"`\n\n if [ "$N1" != "$N2" ] && ! fuser -s "$file"; then\n rm -f "$file"\n else\n echo "$file"\n fi\ndone >/var/lib/my_ro_hack.todel.new\nmv /var/lib/my_ro_hack.todel.new /var/lib/my_ro_hack.todel\n\nuncle-enzo:/home/rick#\n
Anyhow, the first thing you have to decide is which parts of your system tree will need their own partitions, and how big each will be. Then, decide which will be journaled using your journaling religion of choice (ext3, XFS, ReiserFS, JFS). Boot the Knoppix disk. Open a terminal and do "sudo bash" to get a root shell. Type "mount" to see what Knoppix might have automounted at boot time; umount anything it mounted from the target hard drive. Fire up /sbin/fdisk or /sbin/cfdisk (your choice) to create desired partitions. Keep notes on paper of what you're doing and which partition is which. When you're done, save and exit, then use mkfs.ext3, mkreiserfs, mkfs.xfs, mkfs.ext2, or whatever is approriate to high-level format the various partitions. Don't forget to mkswap for the swap partition(s). When you're done with that, mount the target root filesystem onto /mnt (or wherever you prefer), then mount the various other target filesystems to their respective mountpoints underneath /mnt. Now, you're ready to copy files from some other machine across the network. (Examples of how to do so using various tools such as tar, rsync, etc. are given in [link|http://linuxmafia.com/~rick/linux-info/kb/200|http://linuxmafia.co...linux-info/kb/200] .) Last, don't forget to construct an appropriate /etc/fstab (which at that moment will be /mnt/etc/fstab) using a text editor, to reflect the new filesystems you've created.
The table of filesystems I posted above is probably way, way overcomplex for most people's needs, but I've posted it because it illustrates some partitioning concepts. The one from my laptop is a bit more modest:
\nrick@guido:~$ cat /etc/fstab \n# /etc/fstab: static file system information.\n#\n# file system mount point type options dump pass \n/dev/hda3 / ext3 defaults,errors=remount-ro 0 1\n/dev/hda2 none swap sw 0 0\nproc /proc proc defaults 0 0\n/dev/fd0 /floppy auto defaults,user,noauto 0 0\n/dev/cdrom /cdrom iso9660 defaults,ro,user,noauto 0 0\nnone /proc/bus/usb usbdevfs defaults 0 0\n/dev/sda /mnt/fob vfat rw,uid=1000,gid=1000,user,noauto,noatime 0 0\n/dev/hda1 /boot ext2 rw,noauto 0 2\nrick@guido:~$ \n
When in doubt, go with something simple (maybe something really simple, more than the laptop example above). When you need something more complex, you'll know it, and can reconfigure your system at that time.
Rick Moen
rick@linuxmafia.com