Setting up disks manually: Difference between revisions
Dubiousjim (talk | contribs) (→Setting up swap: change link to cryptswap to {{Todo}}) |
Dubiousjim (talk | contribs) (Many refinements) |
||
Line 2: | Line 2: | ||
You may have complex needs that aren't handled automatically by the [[Alpine Setup Scripts]]. In those cases, you'll need to prepare your disks manually. | You may have complex needs that aren't handled automatically by the [[Alpine Setup Scripts]]. In those cases, you'll need to prepare your disks manually. | ||
It is possible to have one or more of RAID, encryption, and/or LVM on your {{Path|/}} (root) volume. However, the Arch init script only knows how to handle them when they're layered in that order, and your initram and extlinux.conf file in the {{Path|/boot}} partition are configured properly. | |||
Your {{Path|/boot}} cannot reside on a encrypted or LVM volume, at least not with Alpine's default bootloader (extlinux). (Grub2 can deal with {{Path|/boot}} being on an LVM volume.) The usual practice is to create a small partition for {{Path|/boot}}, and then devote the rest of your disk to a separate partition on which you layer one or more of RAID, encryption, and/or LVM. | |||
Sometimes {{Path|/boot}} is also setup as a mirrored (RAID1) volume, however this is just for post-init access. That way, when you write a new kernel or bootloader config file to {{Path|/boot}}, it gets written to multiple physical partitions. During the pre-init, bootloader phase, only one of those partitions will be read from. | |||
So, typical setups might look like this: | |||
<pre> | |||
One-disk system | |||
--------------- | |||
+------------------------------------------------+ | |||
| small partition (32--100M), holding | | |||
| only /boot, filesystem needn't be journaled | | |||
+------------------------------------------------+ | |||
| rest of disk in second partition | | |||
| +------------------------------------------+ | | |||
| | cryptsetup volume | | | |||
| | +-------------------------------------+ | | | |||
| | | LVM PV, containing single VG, | | | | |||
| | | containing multiple LVs, holding | | | | |||
| | | /, /home, swap, etc | | | | |||
| | +-------------------------------------+ | | | |||
| +------------------------------------------+ | | |||
+------------------------------------------------+ | |||
Two-disk system | |||
--------------- | |||
+------------------------------------------------+ +------------------------------------------------+ | |||
| small partition (32--100M), holding | | small partition (32--100M), holding | These 2 partitions might form a | |||
| only /boot, filesystem needn't be journaled | | only /boot, filesystem needn't be journaled | mirrored (RAID1) volume | |||
+------------------------------------------------+ +------------------------------------------------+ | |||
| rest of disk in second partition | | rest of disk in second partition | | |||
| T================================================================================================T | These 2 partitions form a second | |||
| T +--------------------------------------------------------------------------------------------+ T | mirrored (RAID1) volume | |||
| T | cryptsetup volume | T | | |||
| T | +---------------------------------------------------------------------------------------+ | T | | |||
| T | | LVM PV, containing single VG, | | T | | |||
| T | | containing multiple LVs, holding | | T | | |||
| T | | /, /home, swap, etc | | T | | |||
| T | +---------------------------------------------------------------------------------------+ | T | | |||
| T +--------------------------------------------------------------------------------------------+ T | | |||
| T================================================================================================T | | |||
| | | | | |||
+------------------------------------------------+ +------------------------------------------------+ | |||
</pre> | |||
In a three-disk system, the {{Path|/boot}} would still be RAID1, but the larger partition might in that case be RAID5. | |||
=== RAID === | === RAID === | ||
Line 7: | Line 59: | ||
If you instead want to build your RAID array manually, see [[Setting up a software raid1 array]]. Then you can add additional layers of encryption and/or LVM, or just assemble the RAID array, and supply the {{Path|/dev/md<i>i</i>}} device directly to [[setup-disk]]. When you're finished, be sure to disassemble the RAID array before rebooting. | If you instead want to build your RAID array manually, see [[Setting up a software raid1 array]]. Then you can add additional layers of encryption and/or LVM, or just assemble the RAID array, and supply the {{Path|/dev/md<i>i</i>}} device directly to [[setup-disk]]. When you're finished, be sure to disassemble the RAID array before rebooting. | ||
If <code>setup-disk</code> sees that you're using RAID---either because you gave it the <code>-r</code> switch, or multiple devices, or a {{Path|/dev/md<i>i</i>}} device---then it will setup your initram and extlinux.conf file properly. However, in other cases, such as when you're also using encryption, or you invoke <code>setup-disk</code> with a mounted directory argument, these might not be properly setup for RAID. In that case, you may need to manually edit/rebuild them. The following assumes that <code>$MNT</code> holds the root directory you're installing into: | |||
{{Cmd|1=echo "/sbin/mdadm" > $MNT/etc/mkinitfs/files.d/raid | |||
echo "/etc/mdadm.conf" >> $MNT/etc/mkinitfs/files.d/raid | |||
# edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features="..." includes raid (this field is space-separated and quoted) | |||
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT | |||
# edit $MNT/etc/update-extlinux.conf to make sure modules=... contains raid1 or raid456 (whichever your / is on; this field is comma-separated) | |||
# also check the root= setting | |||
extlinux --raid --install $MNT/boot --update | |||
}} | |||
{{Todo|Does adding the <code>--update</code> option to <code>extlinux ...</code> suffice to make {{Path|/boot/extlinux.conf}} be regenerated? Or do we need to manually tweak that file, or run <code>update-extlinux</code>, as well?}} | |||
You might also need to manually tweak {{Path|$MNT/etc/fstab}}. And you might need to copy {{Path|/usr/share/syslinux/mbr.bin}} to your disk's MBR. | |||
=== Encryption === | === Encryption === | ||
See [[Setting up encrypted volumes with LUKS]]. Then you can add an additional layer of LVM, or just unlock the volume you've created (using <code>cryptsetup luksOpen ...</code>), and supply the {{Path|/dev/mapper/<i>something</i>}} device directly to [[setup-disk]]. When you're finished, be sure to relock the volume (using <code>cryptsetup luksClose ...</code>) before rebooting. | See [[Setting up encrypted volumes with LUKS]]. Then you can add an additional layer of LVM, or just unlock the volume you've created (using <code>cryptsetup luksOpen ...</code>), and supply the {{Path|/dev/mapper/<i>something</i>}} device directly to [[setup-disk]]. When you're finished, be sure to relock the volume (using <code>cryptsetup luksClose ...</code>) before rebooting. | ||
If you install your {{Path|/}} (root) on an encrypted volume, you'll need to manually edit/rebuild your initram and your extlinux.conf file. The following assumes that <code>$MNT</code> holds the root directory you're installing into, that you've created the cryptvolume on the device {{Path|/dev/md2}}, and that you want to unlock the encrypted volume into a virtual volume named "crypt": | |||
{{Cmd|1=# edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features="..." includes cryptsetup (this field is space-separated and quoted) | |||
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT | |||
# edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts="..." contains cryptroot=/dev/md1 and cryptdm=crypt (this field is also space-separated and quoted) | |||
# also check the root= setting | |||
extlinux --install $MNT/boot --update | |||
}} | |||
{{Todo|Does adding the <code>--update</code> option to <code>extlinux ...</code> suffice to make {{Path|/boot/extlinux.conf}} be regenerated? Or do we need to manually tweak that file, or run <code>update-extlinux</code>, as well?}} | |||
You might also need to manually tweak {{Path|$MNT/etc/fstab}}. | |||
=== LVM === | === LVM === | ||
Line 19: | Line 99: | ||
vgchange -an}} | vgchange -an}} | ||
before rebooting. | before rebooting. | ||
If <code>setup-disk</code> sees that you're using LVM---perhaps because you gave it the <code>-L</code> switch---then it will setup your initram and extlinux.conf file properly. However, in other cases, these might not be properly setup. In that case, you may need to manually edit/rebuild them. The following assumes that <code>$MNT</code> holds the root directory you're installing into: | |||
{{Cmd|1=# edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features="..." includes lvm (this field is space-separated and quoted) | |||
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT | |||
# edit $MNT/etc/update-extlinux.conf to make sure root= is set correctly | |||
extlinux --install $MNT/boot --update | |||
}} | |||
{{Todo|Does adding the <code>--update</code> option to <code>extlinux ...</code> suffice to make {{Path|/boot/extlinux.conf}} be regenerated? Or do we need to manually tweak that file, or run <code>update-extlinux</code>, as well?}} | |||
You might also need to manually tweak {{Path|$MNT/etc/fstab}}. | |||
=== Dual-booting === | === Dual-booting === | ||
Line 163: | Line 256: | ||
== Setting up swap == | == Setting up swap == | ||
# create partition with type "linux swap" (82) | # create partition with type "linux swap" (82) (If you're going to use an LVM logical volume for swap, skip this step and <code>lvcreate</code> that instead.) | ||
# <code>mkswap /dev/sda2</code> | # <code>mkswap /dev/sda2</code> | ||
# <code>echo -e "/dev/sda2 none swap sw 0 0" >> /mnt/etc/fstab</code> | # <code>echo -e "/dev/sda2 none swap sw 0 0" >> /mnt/etc/fstab</code> | ||
# <code>swapon /dev/sda2</code> (or <code>rc-service swap start</code>) | # <code>swapon /dev/sda2</code> (or <code>rc-service swap start</code>) | ||
Then {{Cmd|free}} will show how much swap space is available. | Then {{Cmd|free -m}} will show how much swap space is available (in MB). | ||
If you prefer maximum speed, you don't need configure any raid devices for swap. Just add 2 swap partitions on different disks and linux will stripe them automatically. The downside is that at the moment one disk fails, the system will go down. For better reliability, put swap on raid1. | If you prefer maximum speed, you don't need configure any raid devices for swap. Just add 2 swap partitions on different disks and linux will stripe them automatically. The downside is that at the moment one disk fails, the system will go down. For better reliability, put swap on raid1. |
Revision as of 17:33, 20 October 2012
This material is work-in-progress ... Do not follow instructions here until this notice is removed. |
You may have complex needs that aren't handled automatically by the Alpine Setup Scripts. In those cases, you'll need to prepare your disks manually.
It is possible to have one or more of RAID, encryption, and/or LVM on your / (root) volume. However, the Arch init script only knows how to handle them when they're layered in that order, and your initram and extlinux.conf file in the /boot partition are configured properly.
Your /boot cannot reside on a encrypted or LVM volume, at least not with Alpine's default bootloader (extlinux). (Grub2 can deal with /boot being on an LVM volume.) The usual practice is to create a small partition for /boot, and then devote the rest of your disk to a separate partition on which you layer one or more of RAID, encryption, and/or LVM.
Sometimes /boot is also setup as a mirrored (RAID1) volume, however this is just for post-init access. That way, when you write a new kernel or bootloader config file to /boot, it gets written to multiple physical partitions. During the pre-init, bootloader phase, only one of those partitions will be read from.
So, typical setups might look like this:
One-disk system --------------- +------------------------------------------------+ | small partition (32--100M), holding | | only /boot, filesystem needn't be journaled | +------------------------------------------------+ | rest of disk in second partition | | +------------------------------------------+ | | | cryptsetup volume | | | | +-------------------------------------+ | | | | | LVM PV, containing single VG, | | | | | | containing multiple LVs, holding | | | | | | /, /home, swap, etc | | | | | +-------------------------------------+ | | | +------------------------------------------+ | +------------------------------------------------+ Two-disk system --------------- +------------------------------------------------+ +------------------------------------------------+ | small partition (32--100M), holding | | small partition (32--100M), holding | These 2 partitions might form a | only /boot, filesystem needn't be journaled | | only /boot, filesystem needn't be journaled | mirrored (RAID1) volume +------------------------------------------------+ +------------------------------------------------+ | rest of disk in second partition | | rest of disk in second partition | | T================================================================================================T | These 2 partitions form a second | T +--------------------------------------------------------------------------------------------+ T | mirrored (RAID1) volume | T | cryptsetup volume | T | | T | +---------------------------------------------------------------------------------------+ | T | | T | | LVM PV, containing single VG, | | T | | T | | containing multiple LVs, holding | | T | | T | | /, /home, swap, etc | | T | | T | +---------------------------------------------------------------------------------------+ | T | | T +--------------------------------------------------------------------------------------------+ T | | T================================================================================================T | | | | | +------------------------------------------------+ +------------------------------------------------+
In a three-disk system, the /boot would still be RAID1, but the larger partition might in that case be RAID5.
RAID
setup-disk
will automatically build a RAID array if you supply the -r switch, or if you specify more than one device.
If you instead want to build your RAID array manually, see Setting up a software raid1 array. Then you can add additional layers of encryption and/or LVM, or just assemble the RAID array, and supply the /dev/mdi device directly to setup-disk. When you're finished, be sure to disassemble the RAID array before rebooting.
If setup-disk
sees that you're using RAID---either because you gave it the -r
switch, or multiple devices, or a /dev/mdi device---then it will setup your initram and extlinux.conf file properly. However, in other cases, such as when you're also using encryption, or you invoke setup-disk
with a mounted directory argument, these might not be properly setup for RAID. In that case, you may need to manually edit/rebuild them. The following assumes that $MNT
holds the root directory you're installing into:
echo "/sbin/mdadm" > $MNT/etc/mkinitfs/files.d/raid echo "/etc/mdadm.conf" >> $MNT/etc/mkinitfs/files.d/raid # edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features="..." includes raid (this field is space-separated and quoted) mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT # edit $MNT/etc/update-extlinux.conf to make sure modules=... contains raid1 or raid456 (whichever your / is on; this field is comma-separated) # also check the root= setting extlinux --raid --install $MNT/boot --update
--update
option to extlinux ...
suffice to make /boot/extlinux.conf be regenerated? Or do we need to manually tweak that file, or run update-extlinux
, as well?
You might also need to manually tweak $MNT/etc/fstab. And you might need to copy /usr/share/syslinux/mbr.bin to your disk's MBR.
Encryption
See Setting up encrypted volumes with LUKS. Then you can add an additional layer of LVM, or just unlock the volume you've created (using cryptsetup luksOpen ...
), and supply the /dev/mapper/something device directly to setup-disk. When you're finished, be sure to relock the volume (using cryptsetup luksClose ...
) before rebooting.
If you install your / (root) on an encrypted volume, you'll need to manually edit/rebuild your initram and your extlinux.conf file. The following assumes that $MNT
holds the root directory you're installing into, that you've created the cryptvolume on the device /dev/md2, and that you want to unlock the encrypted volume into a virtual volume named "crypt":
# edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features="..." includes cryptsetup (this field is space-separated and quoted) mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT # edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts="..." contains cryptroot=/dev/md1 and cryptdm=crypt (this field is also space-separated and quoted) # also check the root= setting extlinux --install $MNT/boot --update
--update
option to extlinux ...
suffice to make /boot/extlinux.conf be regenerated? Or do we need to manually tweak that file, or run update-extlinux
, as well?
You might also need to manually tweak $MNT/etc/fstab.
LVM
setup-disk
will automatically build and use volumes in a LVM group if you supply the -L switch.
If you instead want to build your LVM system manually, see Setting up Logical Volumes with LVM. Then vgchange -ay
, format and mount your volumes, and supply the root mountpoint to setup-disk. When you're finished, be sure to
umount ... vgchange -an
before rebooting.
If setup-disk
sees that you're using LVM---perhaps because you gave it the -L
switch---then it will setup your initram and extlinux.conf file properly. However, in other cases, these might not be properly setup. In that case, you may need to manually edit/rebuild them. The following assumes that $MNT
holds the root directory you're installing into:
# edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features="..." includes lvm (this field is space-separated and quoted) mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT # edit $MNT/etc/update-extlinux.conf to make sure root= is set correctly extlinux --install $MNT/boot --update
--update
option to extlinux ...
suffice to make /boot/extlinux.conf be regenerated? Or do we need to manually tweak that file, or run update-extlinux
, as well?
You might also need to manually tweak $MNT/etc/fstab.
Dual-booting
See Install to HDD with dual-boot
Other needs
Setting up swap
- create partition with type "linux swap" (82) (If you're going to use an LVM logical volume for swap, skip this step and
lvcreate
that instead.) mkswap /dev/sda2
echo -e "/dev/sda2 none swap sw 0 0" >> /mnt/etc/fstab
swapon /dev/sda2
(orrc-service swap start
)
Then
free -m
will show how much swap space is available (in MB).
If you prefer maximum speed, you don't need configure any raid devices for swap. Just add 2 swap partitions on different disks and linux will stripe them automatically. The downside is that at the moment one disk fails, the system will go down. For better reliability, put swap on raid1.