From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.gentoo.org ([140.105.134.102] helo=robin.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1IRqe5-0004t6-PH for garchives@archives.gentoo.org; Sun, 02 Sep 2007 14:41:50 +0000 Received: from robin.gentoo.org (localhost [127.0.0.1]) by robin.gentoo.org (8.14.0/8.14.0) with SMTP id l82EY3KC026266; Sun, 2 Sep 2007 14:34:03 GMT Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by robin.gentoo.org (8.14.0/8.14.0) with ESMTP id l82ETMNW020651 for ; Sun, 2 Sep 2007 14:29:23 GMT Received: from localhost (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 763106603E for ; Sun, 2 Sep 2007 14:29:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at gentoo.org X-Spam-Score: -0.153 X-Spam-Level: X-Spam-Status: No, score=-0.153 required=5.5 tests=[AWL=-0.289, BAYES_50=0.001, FORGED_RCVD_HELO=0.135] Received: from smtp.gentoo.org ([127.0.0.1]) by localhost (smtp.gentoo.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MvQXNRyooBSi for ; Sun, 2 Sep 2007 14:29:19 +0000 (UTC) Received: from mailout1.igs.net (mailout1.igs.net [216.58.97.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTP id 64DCA659D9 for ; Sun, 2 Sep 2007 14:29:16 +0000 (UTC) Received: from waltdnes.org (i209-195-93-235.cia.com [209.195.93.235]) by mailout1.igs.net (Postfix) with SMTP id 648A45A70 for ; Sun, 2 Sep 2007 05:16:46 -0400 (EDT) Received: by waltdnes.org (sSMTP sendmail emulation); Sun, 2 Sep 2007 10:32:33 -0400 From: "Walter Dnes" Date: Sun, 2 Sep 2007 10:32:33 -0400 To: Gentoo Users List Subject: [gentoo-user] 500 meg / partition (including /boot) *WITHOUT USING LVM* Message-ID: <20070902143233.GA9496@waltdnes.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.16 (2007-06-09) X-Archives-Salt: 577bcc26-1737-4665-b2fa-913dbfd785e2 X-Archives-Hash: a8c3d21af35f505150d29d0450e3f790 While installing Gentoo recently, I managed to pull off a cute stunt 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 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@gentoo.org mailing list