Using the self-serve net installer/Advanced partitioning

From BitFolk
Jump to: navigation, search

If you're one of the few customers with multiple block devices and you're wanting to use a self-serve net installer then you may need some help with advanced partitioning topics, including LVM.

Debian

The issue is that you're best off putting filesystems (or LVM) directly onto a block device without a partition table, but partman doesn't support this. It's still pretty easy to do though. All you need to do is make use of the installer's shell prompt to create the filesystems or whatever yourself, and then go back to partman.

Here's some examples.

Multiple mount points

Let's say you've decided that out of your 10GiB of disk space you'd like 4GiB on / as ext3, and then you'd like 6GiB on /srv as xfs. / must be ext3 but other block devices can have any filesystem that Debian supports. You've already instructed BitFolk that you require an xvda of 4GiB and a xvdb of 6GiB and it's been confirmed to you that this is ready.

You would now kick off a net install as usual, and specify in partman that xvda is to be formatted as ext3 as normal.

Once you've done that, you'll be looking at a partman dialog a bit like this:

  ┌────────────────┤ [!!] Partition disks ├─────────────────────────┐
  │                                                                         │ 
  │ This is an overview of your currently configured partitions and mount   │ 
  │ points. Select a partition to modify its settings (file system, mount   │ 
  │ point, etc.), a free space to create partitions, or a device to         │ 
  │ initialize its partition table.                                         │ 
  │                                                                         │ 
  │       Guided partitioning                                               │ 
  │       Help on partitioning                                              │ 
  │                                                                         │ 
  │       Virtual disk 1 (xvda) - 4.3 GB Xen Virtual Block Device           │ 
  │       >     #1    4.3 GB    F  ext3    /                                │ 
  │       Virtual disk 2 (xvdb) - 6.4 GB Xen Virtual Block Device           │ 
  │                                                                         │ 
  │       Undo changes to partitions                                        │ 
  │       Finish partitioning and write changes to disk                     │ 
  │                                                                         │ 
  │     <Go Back>                                                           │ 
  │                                                                         │ 
  └─────────────────────────────────────────────────────────────┘

Here you can see that you have an xvdb device but it has no partition table or partitions. If you added a partition to xvdb now as you would for a normal machine then partman would create a partition table and make that xvdb1, which would be undesirable. You're going to have to create the filesystem yourself.

Select <Go Back>. You're now at the main installer menu. Go down to Execute a shell and select. Create your filesystem:

BusyBox v1.10.2 (Debian 1:1.10.2-2) built-in shell (ash)
Enter 'help' for a list of built-in commands.

~ # mkfs.xfs /dev/xvdb
meta-data=/dev/xvdb              isize=256    agcount=4, agsize=393216 blks
         =                       sectsz=512   attr=2
data     =                       bsize=4096   blocks=1572864, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096  
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=0
realtime =none                   extsz=4096   blocks=0, rtextents=0
~ # exit

Navigate back to Partition disks and now it looks slightly different:

  ┌────────────────┤ [!!] Partition disks ├─────────────────────────┐
  │                                                                         │ 
  │ This is an overview of your currently configured partitions and mount   │ 
  │ points. Select a partition to modify its settings (file system, mount   │ 
  │ point, etc.), a free space to create partitions, or a device to         │ 
  │ initialize its partition table.                                         │ 
  │                                                                         │ 
  │       Guided partitioning                                               │ 
  │       Help on partitioning                                              │ 
  │                                                                         │ 
  │       Virtual disk 1 (xvda) - 4.3 GB Xen Virtual Block Device           │ 
  │       >     #1    4.3 GB    F  ext3    /                                │ 
  │       Virtual disk 2 (xvdb) - 6.4 GB Xen Virtual Block Device           │ 
  │       >     #1    6.4 GB                                                │ 
  │                                                                         │ 
  │       Undo changes to partitions                                        │ 
  │       Finish partitioning and write changes to disk                     │ 
  │                                                                         │ 
  │     <Go Back>                                                           │ 
  │                                                                         │ 
  └─────────────────────────────────────────────────────────────┘

You can now move to the line:

  │       >     #1    6.4 GB                                                │ 

select it and format it as xfs, /srv as a mount point and so on as you like.

The install now proceeds normally.

LVM

The above example was rather unrealistic. Normally people choose multiple partitions because the different parts of their filesystems have differing needs. While BitFolk can carve up your disk space into as many different block devices as you like, managing them all gets tedious and resizing them will require action from BitFolk and a shut down / boot from you. Enter LVM. A tutorial on the use of LVM is beyond the scope of this wiki, so we'll assume that you already know the basics of its use.

A common LVM setup at BitFolk is to have a small xvda (say, 1GiB) and then the rest of the space on xvdb which is used as an LVM physical volume. A volume group is then created on xvdb and multiple logical volumes created, one for each additional filesystem or swap device desired. It's good practice to use the minimum amount of disk space that is thought to be required, so as to leave free space in the volume group for later expansion of whichever filesystems require it. The nice thing is that growing a logical volume can be done by you, online, for ext3 and xfs (and probably others).

Should you require the volume group itself resizing later then BitFolk can do this either by resizing your xvdb or providing you with additional block devices you can add in. That will still require a shutdown / boot, but at least it's just one block device to resize.

So, here is an example for the following requirements:

  • / on xvda, 1GiB, ext3

Everything else on LVM from a 9GiB xvdb:

  • /home, 1GiB, ext3
  • /usr, 3GiB, ext3
  • /var, 1GiB, xfs
  • swap, 512MiB

This leaves ~3.5GiB unused on the xvdb volume group for later expansion.

As before you need to set up your root filesystem in partman on xvda then Go back and drop to a shell from the installer menu. You then do all your LVM stuff manually:

BusyBox v1.10.2 (Debian 1:1.10.2-2) built-in shell (ash)
Enter 'help' for a list of built-in commands.

~ # pvcreate /dev/xvdb
File descriptor 3 left open
File descriptor 4 left open
File descriptor 5 left open
File descriptor 6 left open
  Physical volume "/dev/xvdb" successfully created
~ # vgcreate myvg /dev/xvdb
File descriptor 3 left open
File descriptor 4 left open
File descriptor 5 left open
File descriptor 6 left open
  Volume group "myvg" successfully created
~ # lvcreate -L1g -n /dev/myvg/homelv
File descriptor 3 left open
File descriptor 4 left open
File descriptor 5 left open
File descriptor 6 left open
  Logical volume "homelv" created
~ # lvcreate -L3g -n /dev/myvg/usrlv
File descriptor 3 left open
File descriptor 4 left open
File descriptor 5 left open
File descriptor 6 left open
  Logical volume "usrlv" created
~ # lvcreate -L1g -n /dev/myvg/varlv
File descriptor 3 left open
File descriptor 4 left open
File descriptor 5 left open
File descriptor 6 left open
  Logical volume "varlv" created
~ # lvcreate -L512m -n /dev/myvg/swaplv
File descriptor 3 left open
File descriptor 4 left open
File descriptor 5 left open
File descriptor 6 left open
  Logical volume "swaplv" created
~ # exit

(The File descriptor X left open lines are harmless warnings)

Once back in partman, there are all your logical volumes:

  ┌────────────────┤ [!!] Partition disks ├─────────────────────────┐
  │                                                                         │ 
  │ This is an overview of your currently configured partitions and mount   │ 
  │ points. Select a partition to modify its settings (file system, mount   │ 
  │ point, etc.), a free space to create partitions, or a device to         │ 
  │ initialize its partition table.                                         │ 
  │                                                                         │ 
  │    >     #1      1.1 GB                                            ↑    │ 
  │    LVM VG myvg, LV swaplv - 536.9 MB Linux device-mapper (linear)  ▒    │ 
  │    >     #1    536.9 MB                                            ▒    │ 
  │    LVM VG myvg, LV usrlv - 3.2 GB Linux device-mapper (linear)     ▒    │ 
  │    >     #1      3.2 GB                                            ▒    │ 
  │    LVM VG myvg, LV varlv - 1.1 GB Linux device-mapper (linear)     ▒    │ 
  │    >     #1      1.1 GB                                            ▮    │ 
  │    Virtual disk 1 (xvda) - 1.1 GB Xen Virtual Block Device         ▒    │ 
  │    >     #1      1.1 GB    F  ext3    /                            ▒    │ 
  │    Virtual disk 2 (xvdb) - 9.7 GB Xen Virtual Block Device         ↓    │ 
  │                                                                         │ 
  │     <Go Back>                                                           │ 
  │                                                                         │ 
  └─────────────────────────────────────────────────────────────┘

You can now go through them setting the filesystem, mount point, options, label, etc.. You can now proceed with the installation normally, and once booted again:

debtest1:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda            1008M  124M  834M  13% /
tmpfs                 121M     0  121M   0% /lib/init/rw
udev                   10M  540K  9.5M   6% /dev
tmpfs                 121M     0  121M   0% /dev/shm
/dev/mapper/myvg-homelv
                     1008M   34M  924M   4% /home
/dev/mapper/myvg-usrlv
                      3.0G  200M  2.7G   7% /usr
/dev/mapper/myvg-varlv
                     1014M  423M  592M  42% /var