| |||||||||||||||||||||||||||||||
|
that... a) minimizes wasted disk space b) retains the ability to wipe and re-install the OS, without wiping user data I'm considering doing a Gentoo Wiki entry, if one hasn't already been done. First, I'll run it past the list for comments and any problems you may find. (Update: after a read-through, it occurs to me that I should probably bindmount /opt similarly to /tmp, /usr, and /var). The example below uses /dev/sda. Substitute as appropriate for your system (hda or wharever) Step 1) Partition a blank hard drive. - partition the entire hard drive (500 gigabytes in my case) as one gigantic extended partition (partition 1) - create a 500 megabyte logical linux (type 83) partition of at the beginning of the extended partition (partition 5). This will be the / partition - next, create a logical linux swap (type 82) partition approx twice the size of your ram (partition 6). - next, create a logical linux (type 83) partition using the remainder of the drive (partition 7). This will be mounted as /home. Here's what my drive looks like, according to "fdisk -l" Disk /dev/sda: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 1 60801 488384001 5 Extended /dev/sda5 1 62 497952 83 Linux /dev/sda6 63 549 3911796 82 Linux swap / Solaris /dev/sda7 550 60801 483974158+ 83 Linux Step 2) File system creation... *WARNING* the following script wipes all data on partitions 5, 6, and 7. Use this only when you want to wipe everything, *INCLUDING ALL YOUR DATA*, and start fresh. For mounting the drive after a reboot during install (or booting off the install CD for rescue work) use the script in step 3. #!/bin/bash mke2fs /dev/sda5 mkswap /dev/sda6 mkreiserfs /dev/sda7 swapon /dev/sda6 mount /dev/sda5 /mnt/gentoo -o noatime mkdir /mnt/gentoo/home mount /dev/sda7 /mnt/gentoo/home -o noatime,notail mkdir /mnt/gentoo/tmp chmod 1777 /mnt/gentoo/tmp mkdir /mnt/gentoo/usr chmod 755 /mnt/gentoo/usr mkdir /mnt/gentoo/var chmod 755 /mnt/gentoo/var mkdir /mnt/gentoo/home/bindmounts mkdir /mnt/gentoo/home/bindmounts/tmp chmod 1777 /mnt/gentoo/home/bindmounts/tmp mkdir /mnt/gentoo/home/bindmounts/usr chmod 755 /mnt/gentoo/home/bindmounts/usr mkdir /mnt/gentoo/home/bindmounts/var chmod 755 /mnt/gentoo/home/bindmounts/var mount --bind /mnt/gentoo/home/bindmounts/tmp /mnt/gentoo/tmp mount --bind /mnt/gentoo/home/bindmounts/usr /mnt/gentoo/usr mount --bind /mnt/gentoo/home/bindmounts/var /mnt/gentoo/var Again, substitute as appropriate if your harddrive is not /dev/sda. Let's examine the script in detail... mke2fs /dev/sda5 mkswap /dev/sda6 mkreiserfs /dev/sda7 swapon /dev/sda6 The first 4 commands format the partitions and activate the swapdrive. Partition 5 really should be ext2fs for a few reasons... - Partition 5 will rarely be written to during normal operation; only when you are installing/updating programs/scripts that reside in /bin or /sbin so journalling isn't that important. - Journalling requires disk space, which we're trying to conserve. - Given the small size of the / partition, ext2fs is sufficient - ext2fs is the easiest filesystem to shrink/grow. If you ever need to grow the / partition in future, you can take space from the swap partition. Unless you're doing a suspend-to-swap, you can screw around with the swap partition with impunity. - partition 7 will require a (preferably journalling) filesystem that can handle a large partition. I currently use reiserfs. There are several competent filesystems. The choice is yours. mount /dev/sda5 /mnt/gentoo -o noatime mkdir /mnt/gentoo/home mount /dev/sda7 /mnt/gentoo/home -o noatime,notail The next 3 statements - mount partition 5 as / - create directory /home on partition 5 - mount partition 7 as /home. All physical partitions are now mounted. mkdir /mnt/gentoo/tmp chmod 1777 /mnt/gentoo/tmp mkdir /mnt/gentoo/usr chmod 755 /mnt/gentoo/usr mkdir /mnt/gentoo/var chmod 755 /mnt/gentoo/var The next 6 statements create /tmp, /usr, and /var, and set permissions. mkdir /mnt/gentoo/home/bindmounts mkdir /mnt/gentoo/home/bindmounts/tmp chmod 1777 /mnt/gentoo/home/bindmounts/tmp mkdir /mnt/gentoo/home/bindmounts/usr chmod 755 /mnt/gentoo/home/bindmounts/usr mkdir /mnt/gentoo/home/bindmounts/var chmod 755 /mnt/gentoo/home/bindmounts/var The next 7 statements create /home/bindmounts/ on partition 7, and then create mirrors of /tmp, /usr, and /var in /home/bindmounts, and set permissions. mount --bind /mnt/gentoo/home/bindmounts/tmp /mnt/gentoo/tmp mount --bind /mnt/gentoo/home/bindmounts/usr /mnt/gentoo/usr mount --bind /mnt/gentoo/home/bindmounts/var /mnt/gentoo/var And now, the connection between the directories in /home/bindmounts and their equivalents on /, which makes the whole thing work. If you ever need to re-install Gentoo, or another linux distro, you can wipe the contents of (*DO NOT* rmdir)... /tmp /usr /var And then wipe everything in / except the 4 directories... /home /tmp /usr /var Step 3) OK, so you've set up the partitions and subdirectories. There are re-boots during the linux install process. Ditto for installing a new distro, or for doing rescue work. Use the following script to mount the directories... #!/bin/bash swapon /dev/sda6 mount /dev/sda5 /mnt/gentoo -o noatime mount /dev/sda7 /mnt/gentoo/home -o noatime,notail mount --bind /mnt/gentoo/home/bindmounts/tmp /mnt/gentoo/tmp mount --bind /mnt/gentoo/home/bindmounts/usr /mnt/gentoo/usr mount --bind /mnt/gentoo/home/bindmounts/var /mnt/gentoo/var The advantages of my setup... - a minimum of wasted disk space - you can create lots of files, and use almost the entire hard drive flexibly, because all the really variable stuff goes on the big partition - with a little care, you can wipe the OS files and keep your data, and re-install the same or another linux distro. Disadvantages... - "find" will show duplicate results if the target file physically exists in /home/bindmounts - in Gentoo, /etc/localtime is a physical file, not a symlink into /usr/share/zoneinfo. If it is a symlink in your distro, scripts that execute early in the boot process might get confused about what time it is. -- Walter Dnes <waltdnes> In linux /sbin/init is Job #1 Q. Mr. Ghandi, what do you think of Microsoft security? A. I think it would be a good idea. -- gentoo-user mailing list
| ||||||||||||||||||||||||||||||
© 2004-2008 readlist.com