diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2011-01-12 20:49:46 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2011-01-12 20:49:46 +0000 |
commit | c0f28ffe2d1c89f2642277ad7a35f53633f2f469 (patch) | |
tree | a833c258e0d6e56cc46e3c7222dee0e1424e19a0 /setup-disk.in | |
parent | 494c77df159bc792f8673e7f87f859e5ac2ee135 (diff) | |
download | alpine-conf-c0f28ffe2d1c89f2642277ad7a35f53633f2f469.zip |
setup-disk: detect if root device is lvm
We need to add the lvm feature to initramfs image if root is lvm
Diffstat (limited to 'setup-disk.in')
-rw-r--r-- | setup-disk.in | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/setup-disk.in b/setup-disk.in index 3b6b340..d7fa12d 100644 --- a/setup-disk.in +++ b/setup-disk.in @@ -60,6 +60,11 @@ is_xen() { [ -d /proc/xen ] } +# return true (0) if given device is lvm +is_lvm() { + lvs "$1" >/dev/null 2>&1 +} + # Find the disk device from given partition disk_from_part() { # we need convert cciss/c0d0* cciss!c0d0*... @@ -134,7 +139,7 @@ supported_boot_fs() { install_mounted_root() { local mnt="$1" mnt_boot="$1" boot_fs= root_fs= - local features="ata base bootchart cdrom ext2 ext3 ext4 ide scsi usb" + local initfs_features="ata base ide scsi usb virtio" rootdev=$(find_mount_dev "$mnt") if [ -z "$rootdev" ]; then @@ -142,6 +147,12 @@ install_mounted_root() { return 1 fi root_fs=$(find_mount_fs "$mnt") + initfs_features="$initfs_features $root_fs" + + if is_lvm "$rootdev"; then + initfs_features="$initfs_features lvm" + fi + bootdev=$(find_mount_dev "$mnt"/boot) if [ -z "$bootdev" ]; then @@ -156,7 +167,7 @@ install_mounted_root() { mbrdisk=$(disk_from_part $bootdev) if [ -e "/sys/block/${rootdev#/dev/}/md" ]; then local md=${rootdev#/dev/} - features="$features raid" + initfs_features="$initfs_features raid" raidmod=$(cat /sys/block/$md/md/level) raidmod=",$raidmod" raidopt="-r" @@ -186,6 +197,10 @@ install_mounted_root() { unpack_apkovl "$APKOVL" "$mnt" || return 1 fi + # generate mkinitfs.conf + mkdir -p "$mnt"/etc/mkinitfs + echo "features=\"$initfs_features\"" > "$mnt"/etc/mkinitfs/mkinitfs.conf + # generate the fstab if [ -f "$mnt"/etc/fstab ]; then mv "$mnt"/etc/fstab "$mnt"/etc/fstab.old |